In this article, we'll be using QGIS and the Nearmap Tile API to demonstrate how you can view and compare pre- and post-catastrophe imagery.
Before you start
- Ensure you have downloaded and installed QGIS
- Ensure you have a Nearmap API key
Part 1: Configure pre- and post-catastrophe imagery in QGIS
Step 1
Inside QGIS, open the Data Source Manager by clicking on the Layer, Data Source Manager on the top menu bar. You can also click on the 'Open Data Source Manager' icon in the tool bar.
Step 2
Click on 'XYZ' on the left side pane.
Step 3
Click on 'New' under the drop down on the right side pane to add a new connection.
Step 4a
Name the new connection 'Nearmap Excluding Catastrophe', and enter the URL with the following format:
https://api.nearmap.com/tiles/v3/Vert/{z}/{x}/{y}.jpeg?apikey={YOUR_API_KEY}&exclude=disaster
Replace '{YOUR_API_KEY}' with your Nearmap API key.
Understanding the URL
The first part of the URL is the standard Nearmap Tile API, which displays Vertical images with x, y and z coordinates parameterised. It also contains the query parameter 'apikey', which authenticates your application with the Nearmap API.
The query parameter 'exclude' is where the magic happens. As Nearmap endeavours to fly over disaster-affected areas as quickly as possible, the post-catastrophe imagery is usually the most recent available survey. By using the 'exclude' parameter, the most recent survey is excluded and you can see what the impacted area looked like prior to the catastrophic event.
Step 4b
- Leave the 'Authentication' section with the default settings.
- Enter '21' as the Max.Zoom Level
- Leave the rest as default and click 'OK' to close the New XYZ connection window.
In the Data Source Manager window, press 'Add' to add this connection to the list under 'XYZ Tiles' in the connections browser in the main window.
Step 5a
Now let's add another XYZ Tile connection to bring in the post-catastrophe imagery.
Click on 'New' connection under the drop down on the right side pane to add a new connection.
Name the new connection 'Nearmap Latest Including Catastrophe' and enter the URL with the following format:
https://api.nearmap.com/tiles/v3/Vert/{z}/{x}/{y}.jpeg?apikey={YOUR_API_KEY}&include=disaster
Replace '{YOUR_API_KEY}' with your Nearmap API key.
Just like above, the query parameter 'include' is where the magic happens. We're instructing the Nearmap Tile API to include the latest survey (in this case, the post-catastrophe survey) so we get to see how the affected area looks after the catastrophic event.
Step 5b
- Leave the 'Authentication' section with the default settings.
- Enter '21' as the Max.Zoom Level
- Leave the rest as default and click 'OK' to close the New XYZ connection window.
In the Data Source Manager window, press 'Add' to add this connection to the list under 'XYZ Tiles' in the connections browser in the main window.
Step 6
Press 'Close' to go back to the main QGIS window.
Part 2: Compare pre- and post-catastrophe imagery
Step 1
Add two layers to your map using the XYZ Tile connections created in Part 1.
Expand 'XYZ Tiles' on the connection browser and double click on 'Nearmap Excluding Catastrophe' and 'Nearmap Latest including Catastrophe'.
Once this is complete, you will have successfully loaded both the pre- and post-catastrophe imagery into QGIS.
Part 3: Compare imagery side-by-side in QGIS
QGIS has a plugin called 'MapSwipe Tool' which can be used to compare imagery side by side. This is useful when you wish to view an affected area before and after a catastrophic event.
Step 1
To install the plugin, select 'Plugins' ? 'Manage and Install Plugins' from the top menu.
Step 2
Search for 'mapswipe' in the search bar.
Step 3
Click 'Install Plugin'. When the plugin finishes installing, you can start to work with the imagery.
Step 4
As you have already added both the pre- and post-catastrophe imagery layers in Part 2 above, the last part is to enable the 'swiping' feature.
Select the layer you want to 'swipe' in the Layers panel.
Step 5
Activate the MapSwipe tool by clicking on the MapSwipe icon on the tool bar, or by clicking on Plugins, MapSwipe Tool, MapSwipe Tool.
Step 6
Drag your mouse to swipe the selected layer. You can swipe to compare horizontally or vertically.
Step 7
Once you've finished comparing the imagery, click the MapSwipe Tool icon again to deactivate.
Need more help?
Learn more about the Nearmap Tile API