Closed ibarraespinosa closed 6 years ago
I solved in a non-elegant way
osm <- osmdata_sf(
add_osm_feature(
opq(bbox = st_bbox(gCO)),
key = 'highway'))$osm_lines[, c("highway")]
format(object.size(osm), units = "Mb")
[1] "3.6 Mb"
Thanks for using the package. As you discovered, using add_osm_feature(key = "highway")
is the best way to restrict to highways alone. The package is intentionally designed not to allow restricting to osm_lines
alone, rather to return all OSM data associated with a given query. In your example, highways are made of points, so those are returned as osm_points
, often with additional data, and highways may also form defined polygons, or higher-level multi-way entities ($osm_multiline
).
You can also easily pipe queries to make them possibly more elegant, so the above could be written
opq(bbox = st_bbox(gCO)) %>%
add_osm_feature(key = "highway") %>%
osmdata_sf() %>%
magrittr::extract2("osm_lines") %>%
magrittr::extract("highway")
That should do the job
I'm starting to use your excellent package but I found that it download the whole information, consuming too much RAM. I just need osm_lines with the attributes "highway" and "maxspeed".
Is it possible to do that?
Thanks!
My sessionInfo:
And my screenfetch
Thanks!