Find drinking water amenities on a GPX track?

With the following query I can find drinking water amenities within a polygon:

[out:json];node["amenity"="drinking_water"](poly:"51.47 -0.01 51.477 0.01 51.484 -0.01");out;

I would now like to use the data from a GPX-file to search for drinking water amenities on the track (or up to 500 metres off the track). I know how to transform the GPX-file into a Linestring or whatever but I don’t know how to tell Overpass to search on the track.

Does somebody know how to achieve this?

Thanks!
Danke!
:slight_smile:

– Edit:

I found this:

How can I filter the found POIs to only drinking water amenities?

1 Like

Blog post author here. The second query example in the blog post includes node[place=city], which you can easily adjust to your tag. Remove most everything else from the query so that the query looks like:


[out:json];node["amenity"="drinking_water"]
  (around:20000,50.16634404911624, 8.633879241943358,
   49.01715821614669, 8.374327239990235,
   48.288676648581344, 7.775572357177735,
   47.768872096323875, 7.503656616210939,
   47.53482074712603, 7.630003509521484
 );
out meta;

overpass turbo

1 Like

You could write the result of your query to a GPX waypoint file and then use the arc filter of GPSBabel to filter by distance to the GPX track:

gpsbabel -i gpx -f track.gpx -o arc -F track.arc
gpsbabel -i gpx -f waypoints.gpx -x arc,file=track.arc,distance=500  -o gpx -F waypoints_on_track.gpx

Thank you very much, works like a charm! Already tried it with around but didn’t work because I used spaces as separators like in the poly example lol.

Is it possible somehow to not only retrieve the information which lat,lon the water amenity has but also how much the distance to the track is and maybe even to which “track point” it’s nearest to or are that all things I would have to calculate manually afterwards?

Yeah, syntax is sometimes a bit tricky, and not 100% consistent across all filters. I think for the nearest-neighbor calculation, you’d need to use some post processing, as this algorithm hasn’t been implemented so far.

Other question, I tried to combine node[amenity=drinking_water] and node[shop=supermarket] via or-filter, for this I had to give both nodes the complete list of positions again.
I did not find a way to use a {{position_list}} Variable for the around-Logic, is it possible somehow?

Something like

[out:json];
node["amenity"="drinking_water"](around:20000,{{position_list}});
node["shop"="supermarket"](around:20000,{{position_list}});
out meta;

{{position_list=50.16634404911624, 8.633879241943358,
   49.01715821614669, 8.374327239990235,
   48.288676648581344, 7.775572357177735,
   47.768872096323875, 7.503656616210939,
   47.53482074712603, 7.630003509521484}}

Hey, did you manage to get this script to work? I am trying to store the coordinates in a list too, but i cant get it to work yet.

Unfortunately not :confused: