if (Sys.getenv("USER") %in% c("edzer", "travis")) { # load meuse to postgis
library(sp)
example(meuse, ask = FALSE, echo = FALSE)
st_write(st_as_sf(meuse), "PG:dbname=postgis", "meuse", driver = "PostgreSQL",
options = "OVERWRITE=true")
(s = st_read("PG:dbname=postgis", "meuse"))
summary(s)
}
# nc = st_read(system.file("gpkg/nc.gpkg", package="sf"), "nc.gpkg", crs = 4267)
nc = st_read(system.file("shape/nc.shp", package="sf"), "nc", crs = 4267)
summary(nc)
if (Sys.getenv("USER") %in% c("travis", "edzer")) {
library(RPostgreSQL)
conn = dbConnect(PostgreSQL(), dbname = "postgis")
st_read_db(conn, query = "select * from meuse limit 3;")
dbDisconnect(conn)
}
Run the code above in your browser using DataLab