Using OpenStreetMap's points of interest in QGIS
OpenStreetMap has an API called Overpass that lets you access OSM data dynamically. In this recipe, we'll add some OSM tourism points of interest to a map.
Getting ready
You will need to use the QGIS Plugin Manager to install the Quick OSM plugin.
You will also need to download the following shapefile and unzip it to your qgis_data/ms
directory:
How to do it...
We will load our base layer that defines the area of interest. Then, we'll use the Processing Toolbox to build a query for OSM, download the data, and add it to the map. To do this, we need to perform the following steps:
- First, we need to import the
processing
module:import processing
- Next, we need to load the base layer:
lyr = QgsVectorLayer("/qgis_data/ms/MSCoast_geo.shp", "MS Coast", "ogr")
- Then, we'll need the layer's extents for the processing algorithms:
ext = lyr.extent...