[GIS] How to Extract data from OSM within a polygon

openstreetmaposmosisoverpass-api

Although I am a Openstreetmap's regular user for quite some time, I am pretty new to GIS, so I assume this is an easy question: I would like to know how can I extract data (eg: all schools) from OSM within a certain area defined by a polygon (eg: a city boundary or a city's neighbourhood) using QGIS.

Extracting data

I have searched a bit about it and I found out (correct me if I am wrong) that there are different ways to perform queries on OSM, although I don't understand how/when do I have to use each one:

  1. Osmosis
  2. Overpass
  3. XAPI

Using polygons

The problem is that as far (or as little) as I know all these methods rely on a square area, and I would like to know how can I do that within two types of polygons:

  1. A city's boundary (this polygon exists in OSM, since is the one you see when searching for an specific city)
  2. An arbitrary area, which would require to draw a new polygon using an external software (possibly QGIS? JOSM?).

Best Answer

Overpass API allows you to extract by polygon:

http://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Select_Region_by_Polygon

which should fill your needs.

You can use QGIS to draw the desired polygon, then extract the coordinates with the MMQGIS plugin.

Related Question