This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

use polygon for an overpass turbo query

0

Hey, is it possible to add a polygon (for example the shape of a city) in overpass turbo, so that the output only contains data from the city (inside of the polygon)? Can I drag and drop or open a shapefile in overpass turbo for that? Or is there a way to draw one? Thanks for your help!

asked 07 Jun '22, 11:00

milo22948392's gravatar image

milo22948392
11335
accept rate: 0%


One Answer:

0

Edit: You can't import data into overpass & it doesn't really understand true polygons, just closed ways, but you can use existing OSM data.

There's quite a few ways to achieve this depending on what data you have for the area to be searched:

{{geocodeArea:Greater London}};
rel(pivot)->.Bound; //change to way to render
way(r.Bound)->.Bound;
.Bound out geom;
nwr[amenity=police](area);
out center;

These three lines are only to display the search area's boundary & can be removed if desired:

rel(pivot)->.Bound; //change to way to render
way(r.Bound)->.Bound;
.Bound out geom;

The boundary's ID:

rel(175342); map_to_area;
nwr[amenity=police](area);
out center;

The IDs for relations start at 3600000000 so by adding the id value to it allows

area(3600175342);
nwr[amenity=police](area);
out center;

Note the different brackets used:

area[name='Greater London'];
nwr[amenity=police](area);
out center;

answered 07 Jun '22, 14:32

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 07 Jun '22, 15:52