sf (version 0.2-8)

st_write_db: Write simple feature table to a spatial database

Description

Write simple feature table to a spatial database

Usage

st_write_db(conn = NULL, obj, table = substitute(obj), geom_name = "wkb_geometry", ..., drop_table = FALSE, try_drop = FALSE, append = FALSE, binary = TRUE, debug = FALSE)

Arguments

conn
open database connection
obj
object of class sf
table
name for the table in the database
geom_name
name of the geometry column in the database
...
arguments passed on to dbWriteTable
drop_table
logical; should table be dropped first?
try_drop
logical; should we try() to drop table first?
append
logical; append to table? (NOTE: experimental, might not work)
binary
logical; use well-known-binary for transfer?
debug
logical; print SQL statements to screen before executing them.

Examples

Run this code
if (Sys.getenv("USER") %in% c("edzer", "travis")) {
  library(sp)
  data(meuse)
  sf = st_as_sf(meuse, coords = c("x", "y"), crs = 28992)
  library(RPostgreSQL)
  conn = dbConnect(PostgreSQL(), dbname = "postgis")
  st_write_db(conn, sf, "meuse_tbl", drop_table = FALSE)
}

Run the code above in your browser using DataCamp Workspace