DOI-USGS / geoknife

R tools for geo-web processing of gridded data via the Geo Data Portal. geoknife slices up gridded data according to overlap with irregular features, such as watersheds, lakes, points, etc.
https://doi-usgs.github.io/geoknife/
Other
69 stars 23 forks source link

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

Open jordansread opened 2 years ago

jordansread commented 2 years ago

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 commented 2 years ago

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)