Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEATURE] Around function #238

Closed
maellecoursonnais opened this issue Jul 23, 2021 · 3 comments
Closed

[FEATURE] Around function #238

maellecoursonnais opened this issue Jul 23, 2021 · 3 comments

Comments

@maellecoursonnais
Copy link

maellecoursonnais commented Jul 23, 2021

Hello,

In the overpass API, it is possible to use the around parameter to get nodes, ways or relations that specify a certain criterion under a limited radius (see, e.g., here).

For instance, a query that tries to find the closest school within a 400-meter radius around the point with coordinates (48.06435,-1.718673) is
"[out:json][timeout:80];(way(around:400,48.06435,-1.718673)[amenity=school]; node(around:400,48.06428,-1.718692)[amenity=school]; );(._;>;); out;"

It feels like it's not possible to do that with osmdata; but it would be a very cool feature to add. I found it okay to find the way to do it, but I find it very hard to turn that into an actually usable dataframe in R, and this is where your (wonderful) package could be helpful!

EDIT: I see here that you've started to work on that, so tell me if you need help on this one!

Best,
Maël

@mpadge
Copy link
Member

mpadge commented Jul 23, 2021

Thanks @maellecoursonnais, this has finally worked its way to very high on priority list, and will be done very soon via #199. kkeep an eye on that issue and you'll start to see the commits which implement it. Feel free to help at any stage!!

@mpadge
Copy link
Member

mpadge commented Nov 4, 2021

@maellecoursonnais thanks again for this. Took a while to get there, but here it is in action, direct from example code of new osm_around function:

library (osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
packageVersion ("osmdata")
#> [1] `0..1.8.10`
lat <- 53.94542
lon <- -2.52017
key <- "amenity"
value <- "bench"
radius <- 100
opq_around (lon, lat, radius, key, value) |>
    osmdata_sf ()
#> Object of class 'osmdata' with:
#>                  $bbox : 
#>         $overpass_call : The call submitted to the overpass API
#>                  $meta : metadata including timestamp and version numbers
#>            $osm_points : 'sf' Simple Features Collection with 5 points
#>             $osm_lines : NULL
#>          $osm_polygons : 'sf' Simple Features Collection with 0 polygons
#>        $osm_multilines : NULL
#>     $osm_multipolygons : NULL

Created on 2021-11-04 by the reprex package (v2.0.1.9000)

@maellecoursonnais
Copy link
Author

Thank you for the hard work @mpadge! You're making research so much easier!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants