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

Support polyline(s) in the same way we support points? #413

Open
jordansread opened this issue Mar 8, 2022 · 1 comment
Open

Support polyline(s) in the same way we support points? #413

jordansread opened this issue Mar 8, 2022 · 1 comment

Comments

@jordansread
Copy link
Contributor

Behind the scenes, GDP does operations on polygons. We get around this for points (which are "zero area") by creating a tiny little diamond centered on the point.

For reasons similar to why we'd want to access data at points, we're also interested in data along a zero-area polyline, such as a river reach. Is this something the package would support in a simple way? Such as restricting to collections of "line" classes instead of more complicated multi-lines?

@dblodgett-usgs
Copy link
Collaborator

You can create your own polygon sampling areas and pass them in, I think...

Yeah, see below -- you can just pass an sf data.frame with polygons and an ID field to simplgeom()

geoknife::simplegeom(data.frame('point1'=c(-89, 46), 'point2'=c(-88.6, 45.2)))
#> An object of class "simplegeom":
#> Simple feature collection with 2 features and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.0001 ymin: 45.1999 xmax: -88.5999 ymax: 46.0001
#> Geodetic CRS:  WGS 84
#>       ID                           geom
#> 1 point1 POLYGON ((-89.0001 46, -89 ...
#> 2 point2 POLYGON ((-88.6001 45.2, -8...
sg <- geoknife::simplegeom(data.frame('point1'=c(-89, 46), 'point2'=c(-88.6, 45.2)))
sg@sf
#> Simple feature collection with 2 features and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.0001 ymin: 45.1999 xmax: -88.5999 ymax: 46.0001
#> Geodetic CRS:  WGS 84
#>       ID                           geom
#> 1 point1 POLYGON ((-89.0001 46, -89 ...
#> 2 point2 POLYGON ((-88.6001 45.2, -8...
sg <- geoknife::simplegeom(sg@sf)
sg
#> An object of class "simplegeom":
#> Simple feature collection with 2 features and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -89.0001 ymin: 45.1999 xmax: -88.5999 ymax: 46.0001
#> Geodetic CRS:  WGS 84
#>       ID                           geom
#> 1 point1 POLYGON ((-89.0001 46, -89 ...
#> 2 point2 POLYGON ((-88.6001 45.2, -8...

Created on 2022-03-09 by the reprex package (v2.0.1)

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