Using the OpenCage Geocoding API from within QGIS
QGIS is a popular open-source desktop application for viewing an processing geospatial data. With the OpenCage plugin you can convert addresses to coordinates (forward geocoding) and vice-versa (revere geocoding) from within the desktop application.
Installing the OpenCage Geocoder QGIS plugin
In the menu go to "Plugins"
=> "Manage and Install Plugins ..."
.
In the list named "All"
search for "OpenCage"
, then click "Install Plugin"
.
Configuring the OpenCage geocoding plugin
In the menu go to "Settings"
=> "Options..."
.
In the list of settings select OpenCage
and add
your OpenCage geocoding API key
You can create an API key by by
signing up for an account.
Activating the Processing Toolbox
Make sure you have the "Processing Toolbox" panel active. You can activate it in the menu either
"Processing"
=>"Toolbox"
"View"
=>"Panels"
- or right-click any toolbar
Convert addresses to coordinates in QGIS (forward geocoding)
In the Processing Toolbox select the 'OpenCage / Geocode Addresses' algorithm. A new dialog window opens:
First select a CSV file containing addresses or placenames. For example
id, address
1, "Via Allende 8, Cascina, Toscana, Italia"
2, "Via Coppi, 17, Formigine, Emilia-Romagna, Italia"
3, "Via Dei Salici 20, Gallarate, Lombardia, Italia"
4, "Via Vittorio Veneto N7, San Giuliano Terme, Toscana, Italia"
5, "Via Tiro A Segno 8, Gallarate, Lombardia, Italia"
6, "Urne Di Sopra 3, Bagnolo Mella, Lombardia, Italia"
7, "Via San Francesco D'assisi 84, Nichelino, Piemonte, Italia"
8, "Via Corletto, 10/A, Formigine, Emilia-Romagna, Italia"
9, "Via Beppe Fenoglio 17, Canale D'alba, Piemonte, Italia"
10, "Via 2 Giugno 19, Ponsacco, Toscana, Italia"
11, "Via Per Sassuolo, 74, Formigine, Emilia-Romagna, Italia"
You can also select an existing data layer. In the advanced options (behind the wrench symbol) you can limit the number of rows that will be processed, that's good when testing.
You should have your addresses formatted as we recommend in our guide to formatting your geocoding query.
Next, select the Address field
. In this case it's 'address'
Set the remaining optional parameters. You can learn more about the parameters in the "Optional Parameters" section of our geocoding API documentation.
Setting the Geocoded addresses layer
is not required.
If empty then a new temporary layer will be created.
After clicking Run
the addresses get geocoded.
Behind the scenes QGIS sends each entry to the OpenCage geocoding API.
Convert coordinates to addresses (reverse geocoding) in QGIS
In the Processing Toolbox select the 'OpenCage / Geocode Coordinates' algorithm. A new dialog window opens:
What is the plugin doing?
No need to wonder, just like QGIS itself the OpenCage QGIS plugin is fully open source. Contributions and fixes gladly received!