5

I have an OSM map of a larger region. Inside that region is a city with a boundary specified by a polygon.

I want to retrieve IDs of all ways (ideally - of all buildings) inside that boundary (inside the red polygon in the screenshot below).

Artyom city

How can I do it (ideally - in Java) ?

  • Do you want to do it locally? There are APIs (e.g. overpass) that can do this from a server; which you could install yourself if you need to. – BradHards Nov 1 '13 at 10:38
  • @BradHards Actually, it's irrelevant whether this happens online or locally. For now, I intend to download the data within the bounding box ( openstreetmap.org/api/0.6/… ), then read all buildings from there and filter out those, which lie inside the polygon boundary (as described on stackoverflow.com/questions/12083093/… ). I'm not finished yet, so if you know an easier way, I'll be glad to hear it. – DP_ Nov 1 '13 at 10:47
1

I have same need. Till now i have this overpass query

way(poly:"50.7 7.1 50.7 7.2 50.75 7.15")[building];
>;
out ids;

http://overpass-turbo.eu/s/1oB

2

Instead of downloading all the data, you can use the Overpass API to do a selective extract based on a bounding box and certain properties (for example, a key-value search for certain properties).

What properties you choose to use is (of course) your choice - I assume you already have something you're using as the definition of a "building" based on the key-value pairs in the API output, since this is a bit qualitative (e.g. is a bus shelter a building?)

If you'd like to install that system locally, see http://wiki.openstreetmap.org/wiki/Overpass_API/versions

  • Very interesting. I'll try to formulate a query for getting a list of all buildings inside the polygon. Regarding buildings: By "building" I mean any way, which has a node <tag k="building" v="..."/>. – DP_ Nov 1 '13 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.