Reputation: 434
I'm fairly new at using overpass API, I finally managed to generate a query to retrieve all nodes within an area by using overpass-turbo wizard.
Using highway=* in "Paulino Navarro"
in the wizard generates me the following query.
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“highway=* in "Paulino Navarro"”
*/
[out:json][timeout:25];
// fetch area “Paulino Navarro” to search in
{{geocodeArea:Paulino Navarro}}->.searchArea;
// gather results
(
// query part for: “highway=*”
node["highway"](area.searchArea);
way["highway"](area.searchArea);
relation["highway"](area.searchArea);
);
// print results
out body;
>;
out skel qt;
However, how could I use a polygon as a search area? maybe something like highway=* in poly([lat,lon],[lat,lon],...,[lat,lon])
or how can I do that on the query itself.
I don't quite understand the documentation in overpass wiki nor overpass-turbo wizard.
Upvotes: 2
Views: 4310
Reputation: 386
If the polygon you want to query inside of is an OSM feature, you can also query using an area ID.
Area IDs are generated by the Overpass server to make querying data within existing polygons easier. You can determine the area ID for a way by adding 2400000000
to the way ID and the area ID for a relation by adding 3600000000
to the relation ID (assuming that the way or relation is a valid area feature).
Example:
[out:xml][timeout:30];
way[highway=primary](area:2400000001);
(._;>;);
out;
Upvotes: 3
Reputation: 21469
The polygon filter is explained in the Overpass QL documentation.
[out:xml][timeout:30];
way[highway=primary](poly:"50.7 7.1 50.7 7.2 50.75 7.15");
(._;>;);
out;
Upvotes: 3