write spatial table to a PostGIS db table (simple wrapper around sf::st_write_db with automatic casting to sf objects and argument checks)

write_vector_to_pgres(in_vect, con, table_name, schema = "public",
  make_valid = FALSE, drop = FALSE, update = FALSE,
  row.names = FALSE, verbose = TRUE)

Arguments

in_vect

either an "sf" or "sp" R object, or the full path of a valid vector file

con

a PostgreSQLConnection object to a PostGIS DB, created by a call to DBI::DBI::dbConnect(PostgreSQL(),....

table_name

character name of the table to be used for storage in the db

schema

character name of the schema to be used for storage in the db

make_valid

logical If FALSE, the function aborts in case invalid geometries are found. If TRUE, an automatic correction based on lwgeom::st_make_valid is attempted, Default: FALSE

drop

logical indicating if existing tables should be overwrittern, Default: FALSE

row.names

logical indicating if an additional row containing row numbers, should be added to the DB table, Default: FALSE

drop

logical indicating if data should be appended to existing tables, Default: FALSE

Value

The function is called for its side effects

See also

Examples

# NOT RUN {
# establish a connection with a postGIS DB
con <- DBI::dbConnect(PostgreSQL(),
                     host = "xx.xxx.xx.xx", dbname = "xxxxx", user = "xxxxx",
                     password = "xxxxx", port = 5432)
> con


 # write a vector object in a table of the DB
 write_vector_to_pgres(in_vect,
                  con        = con,
                  table_name = "my_table",
                  schema     = "public",
                  drop       = TRUE)
# }