ThinkR-open / blogs-comments

Comments on our blog posts with Utterances
1 stars 0 forks source link

https://rtask.thinkr.fr/interact-with-postgis-from-r-with-dbi-and-sf/ #5

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Interact with PostGIS from R - Rtask

Connect and interact with a PostGIS database from R. PostGIS extends capabilities of PostgreSQL database. Find out how to deal with PostGIS with {sf}.

https://rtask.thinkr.fr/interact-with-postgis-from-r-with-dbi-and-sf/

statnmap commented 2 years ago

Dhiraj Khanna says: on 21 June 2020 at 7 h 03 min

Thank you for the article. I am macOS Catalina and my st_drivers() doesn’t show the Postgresql driver installed. I tried brew install gdal –with-postgresql but got an error saying that it is not a valid option. Any idea how to install the driver?

statnmap commented 2 years ago

David says on 18 November 2020 at 23 h 25 min

Thank you for this interesting article.

How could you read a layer from a schema different than public?

I can do it with SQL, layer1 <- st_read(con, query = 'select * from module2.roads'), but I don’t know how to do it only with st_read.

Neither of these works:

layer1 <- st_read(con, layer = "module2.roads")

layer1 <- st_read(con, layer = in_schema("module2", "roads"))
statnmap commented 2 years ago

Thank you. You can do it like this:

world_sf <- read_sf(con, layer = DBI::Id(schema = "tiger", table = "ne_world2"))