From a cppRosm data table, make the geometries.
Arguments
- cpprnet_dt
a data table obtained with cppRosm extract_data()
- complete
bool. TRUE to reconstruct Polygons, else use just points.
- cores
integer. Run the computation on multiple cores using
parallel
.
Value
Modifies the provided cpprnet_dt object and adds an sf
geometry column to it, with either full geometries or just the centroids.
Full geometries typically contain polygons and points.
Examples
cpprnet_filepath <- system.file(package = 'cppRosm','extdata','map.osm')
cpprnet_dt <- cppRosm::extract_data(filename = cpprnet_filepath)
#> → Using main keys `amenity`,`shop`,`tourism`.
cppRosm::construct_geom(cpprnet_dt,complete=TRUE)
#> id key value lon lat attrs
#> <char> <char> <char> <num> <num> <list>
#> 1: 227734022 amenity fuel 10.51265 43.84976 <list[10]>
#> 2: 227808627 amenity fuel 10.49478 43.84065 <list[7]>
#> 3: 227817156 amenity fuel 10.49499 43.84476 <list[7]>
#> 4: 227817516 amenity fuel 10.51571 43.84797 <list[12]>
#> 5: 227821623 amenity fuel 10.51632 43.84604 <list[8]>
#> ---
#> 1023: 1156050023 amenity parking 10.51492 43.84978 <list[4]>
#> 1024: 1160398321 amenity parking 10.50511 43.83832 <list[3]>
#> 1025: 1160426516 amenity parking 10.50510 43.83842 <list[2]>
#> 1026: 1160426517 amenity parking 10.50406 43.83837 <list[1]>
#> 1027: 1188795305 shop ticket 10.49671 43.84190 <list[10]>
#> geometry
#> <sfc_GEOMETRY>
#> 1: POINT (10.51265 43.84976)
#> 2: POINT (10.49478 43.84065)
#> 3: POINT (10.49499 43.84476)
#> 4: POINT (10.51571 43.84797)
#> 5: POINT (10.51632 43.84604)
#> ---
#> 1023: POLYGON ((10.51491 43.84965...
#> 1024: POLYGON ((10.50466 43.83833...
#> 1025: POLYGON ((10.50576 43.83838...
#> 1026: POLYGON ((10.50375 43.83837...
#> 1027: POLYGON ((10.49665 43.84195...
head(cpprnet_dt$geometry)
#> NULL