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_sf should mention what column it used as geometry #255

Closed
etiennebr opened this issue Mar 10, 2017 · 3 comments
Closed

st_as_sf should mention what column it used as geometry #255

etiennebr opened this issue Mar 10, 2017 · 3 comments

Comments

@etiennebr
Copy link
Member

When it guesses the geometry column, I think the message could be more precise by mentionning the name of the column it picked.

st_as_sf(df)
#> more than one geometry column: ignoring all but first

I suggest something like:

st_as_sf(df)
#> more than one geometry column: picked `geom`, use `coords=` to specify a different column.
edzer added a commit that referenced this issue Mar 12, 2017
adds a parameter to st_sf, "sf_column_name" to specify the column with the simple feature geometries to consider "active", in case there are multiple of such columns.
@etiennebr
Copy link
Member Author

I think this issue is mostly resolved, however the warning still feels weirder now that sf support for multiple columns. Should a warning even be provided?

# test multiple geom columns
library(sf)
library(tidyverse)

#> lag():    dplyr, stats

nc <- st_read(system.file("shape/nc.shp", package="sf"), "nc", crs = 4267, quiet = TRUE)
nc <- nc %>% 
    mutate(geog = st_transform(geometry, 4326))
#> Warning in st_sf(x, ..., agr = agr): more than one geometry column: taking
#> `geometry'; use `sf_column_name=' to specify a different column.

Also not clear to me what sf_column_name= option it refers to.

@edzer
Copy link
Member

edzer commented Mar 22, 2017

What did you expect to be the active geometry of nc after this command?

The warning message reveals from which function it was called, did you look up its docs?

edzer added a commit that referenced this issue Mar 22, 2017
support for reading (st_read, read_sf) objects that have more than one geometry column, without dropping any; concerns #255 and #257.
@etiennebr
Copy link
Member Author

It's true that st_sf is mentioned, but it was not directly called and I don't believe it can be accessed via mutate. So I wonder what action should be taken by the user after that warning.

If the universal sf rule is to keep the geometry column until it is explicitly changed using st_geometry(x) <- "new_col" or st_sf(x, sf_column_name="new_col"), then maybe there is no need for a warning?

@edzer edzer closed this as completed in 7b07643 Apr 30, 2017
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