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

[FEATURE] Data trimming on OP server side #256

Closed
Mashin6 opened this issue Dec 4, 2021 · 4 comments
Closed

[FEATURE] Data trimming on OP server side #256

Mashin6 opened this issue Dec 4, 2021 · 4 comments

Comments

@Mashin6
Copy link
Contributor

Mashin6 commented Dec 4, 2021

As suggested in #178 trimming by area polygon using Overpass is fast and useful way of data filtering.

Note: OP now treats all closed ways as areas thus allowing filtering by features like parks or buildings.
Overpass-turbo uses {{geocodeArea:"name"}} shorthand to query Nominatim and takes the first retrieved object for area filtering. We could use this behavior here as well.

Ok. I took a look on the existing code and though of a solution. But before I write any code I want to check if the solution is in line with overall spirit of the package structure and any long term visions:

  1. getbb(... , format_out = "data.frame") will be used to query Nominatim for geocoded area.
  2. Resulting data.frame can be then passed into new function overpass_trim(dat, osm_area) in a similar way as it is used for trim_osmdata() and format_out = "polygon".
    osm_area = data.frame from getbb()
  3. overpass_trim() will then take only the very first result of Nominatim output for filtering. (maybe show warning if multiple results?)
  4. overpass_trim() can also take two other parameters osm_id and type that can be used to trim by a specific osm object instead of relying on Nominatim search.
    osm_id = single id or vector of ids
    type = single type or vector of types (w|r)
  5. overpass_trim will parse and set opq$bbox=NULL and new $trim_area= list( c(id_1, id_2), c("r", "w"))
  6. opq_string_intern() will detect presence of $trim_area in opq object and modify query buildup.
    So from this:
opq() |>
    trim_osmdata(osm_id = c(id_1, id_2), type = c("r", "w")) |>
    add_osm_feature(key = "natural", value = "tree") |>
    osmdata_sf()

we get

(
rel(id:id_1);
way(id:id_2);
);

map_to_area->.a;

(
nwr[natural=tree](area.a);
);

It would work the same with getbb nominatim search but the osm_id and type will be taken from the passed data.frame.

@jmaspons
Copy link
Collaborator

jmaspons commented Dec 6, 2022

Can be closed as per #286

@mpadge
Copy link
Member

mpadge commented Dec 6, 2022

Then please do so @jmaspons, so you'll be recorded as the having done the work required to close this. Thanks!

@jmaspons
Copy link
Collaborator

jmaspons commented Dec 6, 2022

Then please do so @jmaspons, so you'll be recorded as the having done the work required to close this. Thanks!

Can I? I think I have no perms

@mpadge
Copy link
Member

mpadge commented Dec 6, 2022

Oh, sorry about that, then i'll do it.

@mpadge mpadge closed this as completed Dec 6, 2022
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

3 participants