Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st_as_sfc.pq_geometry #1195

Closed
SymbolixAU opened this issue Nov 19, 2019 · 2 comments
Closed

st_as_sfc.pq_geometry #1195

SymbolixAU opened this issue Nov 19, 2019 · 2 comments

Comments

@SymbolixAU
Copy link

SymbolixAU commented Nov 19, 2019

If a table is read from a postgis database as a regular data.frame using RPostgres::dbGetQuery the geometry column is returned as class pq_geometry.

This can be converted to sfc by

sf:::st_as_sfc.WKB( df$geom, EWKB = TRUE )

Can we have a sf_as_sfc.pq_geometry method which does this automatically as part of sf?

For example

#' @export
sf_as_sfc.pq_geometry <- function(x, ..., EWKB = FALSE, spatialite = FALSE, pureR = FALSE, crs = NA_crs_) {
  st_as_sfc.WKB(x, ..., EWKB = TRUE, spatiallite = spatialite, pureR = pureR, crs = crs)
}
@SymbolixAU SymbolixAU changed the title sf_as_sfc.pq_geometry st_as_sfc.pq_geometry Nov 19, 2019
@edzer
Copy link
Member

edzer commented Nov 19, 2019

Makes sense (@etiennebr ?) - doesn't it make more sense to use

#' @export
sf_as_sfc.pq_geometry <- function(x, ..., EWKB = TRUE, spatialite = FALSE, pureR = FALSE, crs = NA_crs_) {
  st_as_sfc.WKB(x, ..., EWKB = EWKB, spatiallite = spatialite, pureR = pureR, crs = crs)
}

or is the column guaranteed to be EWKB?

@dcooley
Copy link
Contributor

dcooley commented Nov 19, 2019

@edzer sorry yes, that makes more sense. I missed setting the EWKB argument to TRUE.

@edzer edzer closed this as completed in ede09c9 Nov 19, 2019
edzer added a commit that referenced this issue Feb 20, 2020
edzer added a commit that referenced this issue Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants