Import table from R into PostgreSQL DB -


i loaded spatial data postgresql db r of rpostgresql-package , st_astext:

dbgetquery(con, "select id, st_astext(geom) table;") 

after having done analyses want go way. geom column stil formated character / wkt. unfortunately dbwritetable doesn't accept similar arguments dbgetquery.

  • what best way import spatial data r postgresql?

up way found, importing data db , using st_geomfromtext in additional step geometry data type.

i created table on db using dbwritetable() , postgistools-package insert data (it must spatialpolygonsdataframe).

## create empty table on db dbwritetable(con, name=c("public", "<table>"), value=(dataframe[-c(1:nrow(dataframe)), ])) require(postgistools) ## insert postgis_insert(con, df=spatialpolygonsdataframe, tbl="table", geom_name="st_astext") dbsendquery(con, "alter table <table> rename st_astext geom;") dbsendquery(con, "alter table <table> alter column geom type geometry;") 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -