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

Add an active = NULL argument to st_coordinates.sfnetwork #215

Closed
agila5 opened this issue Jun 26, 2022 · 1 comment
Closed

Add an active = NULL argument to st_coordinates.sfnetwork #215

agila5 opened this issue Jun 26, 2022 · 1 comment

Comments

@agila5
Copy link
Collaborator

agila5 commented Jun 26, 2022

Is your feature request related to a problem? Please describe.
I think st_coordinates may adopt the same shortcut as st_geometry or st_as_sf, i.e.

library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(sfnetworks)

sfc <- st_sfc(st_linestring(rbind(c(0, 0), c(1, 1), c(2, 2), c(3, 3))))
sfn <- as_sfnetwork(sfc)
st_geometry(sfn, "edges") # works
#> Geometry set for 1 feature 
#> Geometry type: LINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 0 xmax: 3 ymax: 3
#> CRS:           NA
#> LINESTRING (0 0, 1 1, 2 2, 3 3)
st_coordinates(sfn, "edges") # doesn't work since st_coordinates always return the active table
#>   X Y
#> 1 0 0
#> 2 3 3

Created on 2022-06-26 by the reprex package (v2.0.1)

Describe the solution you'd like
We could add an active = NULL argument such that a call like st_coordinates(sfn, "edges") returns the coordinates of the edges table.

Describe alternatives you've considered
We can just modify the active table, but also this addition shouldn't be really difficult. Moreover, IMO, it's surprising that the same pattern works only for st_geometry and sf_as_sf()

@luukvdmeer
Copy link
Owner

Added in v0.6.0. Also for st_bbox()

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