User Tools

Site Tools


gis:osm_queries_in_qgis_using_overpass_ql

OSM Queries in QGIS using Overpass QL

QGIS comes with many localizations, I assume that the user interface speaks American English and that locales are set to en_US.

To use Overpass QL to access the OSM database in the way described in the previous section we will use QuickOSM.

Open the Plugins menu and click Manage and Install Plugins…

The Plugins window displays. On the left click on Installed and in the Search… field enter QuickOSM. If the middle column shows QuickOSM, the required plugin has already been installed and you can skip the next step.

If the column however is empty, click on Not installed. Now install QuickOSM by klicking on QuickOSM and then on the Install Plugin button.

When QuickOSM is installed, make sure that is active (this is displayed by the checkbox being checked), click Close to close the Plugins window.

QuickOSM comes with two buttons:

The one on the right loads the data for the area that is currently displayed in QGIS into JOSM provided that a) you have enabled the latter's remote control feature and b) size limitations permit. If you are an OSM contributor that's a cool feature but we are interested in the other one.

So let's click on the magnification glass. The QuickOSM window displays. Per default it shows the Quick Query tab. We'll come back to that in just a moment but first let's try the Query tab.

The huge white area at the top of this tab allows you to enter queries in the same way as the overpass API so let's try the stolperstein query from the previous section:

[bbox:50.6,7.0,50.8,7.2];
area[name=Bonn][admin_level=6]->.bonnarea;
node(area.bonnarea)["memorial:type"="stolperstein"];
out meta;

Enter it in the input field, then click Run query Close the QuickOSM window by just hitting the ESC key. A new layer named OsmQuery has occurred. Zoom to it.

Les voilà, all stolpersteine in Bonn in QGIS. And not only their position, if you use the Identify Feature tool you see that all the attributes fom the OSM database are also present.

Again open the QuickOSM window, this time let's try the Quick query. As Key enter memorial:type, as Value enter stolperstein, in the pulldown menu select In and in the A village, a town, … input field enter Bonn. Finally click Run query and when it is done hit ESC.

Another layer named memorial:type_stolperstein_Bonn has occurred. If nothing has gone wrong, the result should be identical to the one of the more complex query.

Persistence

So far the query results are stored in what is temporary layers, layers that are lost when quitting QGIS. This is shown by the stylized chip right to these layers. The (memory) chip serves as a reminder that the layers in question only exist in the computer's volatile memory.

However, the symbols do not only serve as a warning sign, they come with functionality. Click on the symbol and a window will pop up that allows you to configure where to store the layer's data. The use is quite straightforward but depends on what output format you select.

My suggestion is that you use KML (Keyhole Markup Language) as it is widely supported and for the given, relatively small number of geographical features performance is not an issue (but never forget: these relatively few geographical features mean hundreds of murdered men, women and children).

If you have layers that contain considerably more entries I suggest using GeoPackage. It essentially is a standardized way to store geographical data in an SQLite database. Please only use the quite commonly used ESRI Shapefile format if you absolutely must. It has quite a number of practical issues that are understandable given that the format is almost 30 years old: http://switchfromshapefile.org

Note that besides using formats that allow you to save the data in a form that QGIS can read in again there are also some like CSV that allow you to easily extract the attribute data.

gis/osm_queries_in_qgis_using_overpass_ql.txt · Last modified: 2020/06/19 23:30 by admin