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.
You will need to use the QGIS plugin manager to install the QuickOSM plugin.
You will also need to download the following shapefile and unzip it to your qgis_data/ms
directory:
https://github.com/GeospatialPython/Learn/raw/master/MSCoast_geo.zip
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:
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 extent for the processing algorithms:
ext = lyr.extent() w = ext.xMinimum...