Estimated reading time: 13 minutes
Georeferencing in QGIS 3 is a three step process […]
Table of contents
- The best way to scan an image for georeferencing in QGIS
- How to use the Qgis georeferencer – 10 steps
- Step 1: Open the QGIS map that you’ll be Georeferencing to.
- Step 2: Give your QGIS map contrast.
- Step 3: Open the Qgis georeferencer
- Step 4: Open the scanned image you want to georeferenced.
- Step 5: The scan is open
- Step 6: Find ground control points
- Step 7: Match at least 3 ground control points
- Step 8: Start the Qgis georeferencer.
- Step 9: The Transformation Settings dialog
- Step 10: The image has been georeferenced in QGIS
Georeferencing in QGIS is a three-step process…
- Ideally you’ll start with a scan of a map that has north at the top.
The scan may also be an air photo. The closer you can get your scan to facing north, the more likely you are to get a good result on your first QGIS georeferencing try.
- Find features that are common to your scan and the QGIS maps on your QGIS canvas.
These common features are called Ground control points (GCPs). Road intersections, and property boundaries are commonly used as GCPs. Urban areas tend to be GCP rich. Rural areas are often GCP poor. In GCP poor areas, sometimes you need to resort to using fences, trees, buildings and even distinct shapes in water feature maps as GCPs.
- Finally, you run the Qgis georeferencer to convert your image from scanner coordinates into GIS coordinates.
When you’re georeferencing in QGIS, you’ll get the best results if you’re Georeferencing scans that are already geographically correct. By that I mean scans of maps that are already in a coordinate system. Distorted images like air photos and poorly maintained old maps can present a challenge for georeferencing in QGIS. In such cases, sometimes you need to use the output from one Georeferencing attempt as the input for another attempt, and so-on, until you get a result that you’re happy with.
In my GIS consultancy, I often use base maps. Basemaps are custom maps that I print out for field scientists to take into the field and draw their field work on. As an example, for a soil survey I would produce a basemap with four map layers – roads and cadastre for orientation purposes, and geology and contours for interpretation purposes. I take the scientist’s field map (eg. soil survey, vegetation survey, census survey, …) and scan it. I then use the Qgis georeferencer to turn the scan into a QGIS map. After that I use the georeferenced scan as a backdrop for onscreen digitizing.
I use paper basemaps for fieldwork because GIS and GPS are not always the best tools for some jobs. Technology can be distracting in the field and often fieldworkers relate better to printed maps.
Most times, scans of maps produced by government survey departments already have a grid printed on them that you can use for ground control points.
A good way to guarantee the accurate Georeferencing of a basemap is to incorporate ground control points (GCPs) prior to printing it out. The best way to achieve that is to overlay a rectangular clip-region onto the basemap before you print it out. That way, when you scan your fieldwork map, the four corners of the clip region are common to both the scanned field map AND the GIS clip region map. These four corners are the Ground control points that you georeference against.
The best way to scan an image for georeferencing in QGIS
Before we get into the nitty gritty of how to scan an image for georeferencing in QGIS, I want to talk about the best way to scan a map or air photo.
Do your best to lay your map or air photo flat and square in your scanner with north oriented at the top. The closest you can get your scan to how it should look as a digitizing backdrop, the better. Usually a scan resolution of 300 Dots Per Inch (DPI) is sufficient.
Although the Qgis georeferencer accepts many image file formats, ideally you should save the scan in jpg file format. Tif format would be OK too. Sometimes you need to do a few experiments. The file format that works best can sometimes depend on your equipment. The proprietary software that often comes bundled with scanners sometimes saves files in slightly different file formats than QGIS is expecting.
Once you’ve worked out a scanning process that works well with the equipment you have, document the process and then use that process all the time.
If you don’t have a scanner, many office stores have scanning services. Some even have large format scanners for bigger maps.
If necessary, use photo editing software to ensure your scan is oriented north and alter its brightness and contrast. Two free photo editors you can use for that are fotor.com (cloud) and gimp.org (download).
How to use the Qgis georeferencer – 10 steps
Now I want to take you through the ten steps that I use to georeference a scanned map or air photo in QGIS. The example is taken from my HD video follow-along-with-me QGIS georeferencing and digitizing course. Click here to enrol.
In this case the scan is a map that I created in QGIS and printed out. It is a map of air photos that are overlaid by a rectangular clip region. I turned the printout into a field map showing a five class land use interpretation (commercial land, salt marsh, forest, open space and urban land). The “before” version of the map is shown in figure 1a.
The version in figure 1b has the land use interpretation drawn on it, and has been scanned at 300dpi. It is a dumb scan and is in scanner coordinates. Because I printed the clip region onto it, the scan can easily be related back to the GIS version of the clip region in QGIS.
Step 1: Open the QGIS map that you’ll be Georeferencing to.
Click the Open Data Source manager button and from the dialog (LandUseInterpretationClipRegion.shp)
Step 2: Give your QGIS map contrast.
In the Layers area, right-click the GIS map you’re Georeferencing to (LandUseInterpretationClipRegion).
Launch the Layer properties dialog. In the Symbology tab, change the Fill Style to be no brush and the stroke color to be bright pink (pink is a good color for contrast).
Step 3: Open the Qgis georeferencer
From the Raster drop-down menu, click on Georeferencer and the Georeferencer dialog box will appear.
Step 4: Open the scanned image you want to georeferenced.
Click the Open raster button to open the scan that you want to georeference. Scans are also known as rasters and bitmaps.
From the drop-down menu, open the scan that you want to georeference. Take the time to explore this menu. There’s a bunch of raster file types that QGIS can use.
Step 5: The scan is open
The scanned Land Use interpretation opens in the Qgis georeferencer and its ready to be geo-referenced.
Step 6: Find ground control points
Now we need to find common points in both the scan and the GIS maps in QGIS. In this case, we’re matching the surrounding rectangle on the scan, to its GIS version. So be sure that the GIS map is open in the main QGIS map canvas.
Begin by zooming into a corner of the clip region on the scan.
Then click the Add point button…
On the scan, click your left mouse button on the top-left corner of the clip region.
The Enter map coordinates box will appear.
From the Enter map coordinates dialog you can either manually enter the coordinates of the Ground control points OR you can get them interactively from the QGIS map canvas. To get them from the map canvas…
- Click the From map canvas button (red square in the figure) and the map canvas will display.
- Place your mouse over a corner of the clip region in the QGIS main map canvas with your mouse. Use your mouse wheel to zoom in close.
- Click the left mouse button to add a point and the X and Y coordinates will be populated.
- Click the OK button and dots appear in both the QGIS georeferencer and main QGIS map windows.
Repeat these steps for each of the four corners of the clip region.
Step 7: Match at least 3 ground control points
Georeferencing in QGIS involves mapping a scan’s pixel coordinates to GIS coordinates.
You can see our four GCPs and GCP table in Figure 2 as a red dot in each corner of both images. GCPs are simply places in the scan on the left (in pixel coordinates) that you can also find in the GIS map on the right.
There’s some things to note in the GCP table…
- The Visible checkboxes allow you to enable or disable a GCP. This is important functionality, especially if you accidently digitize one in the wrong place.
- The id of the GCP starts at zero, not one!
- The Source X and Source Y columns refer to the Pixel Coordinates of the scanned map interpretation.
- The Dest.X and Dest.Y columns refer to the Destination Coordinates in the GIS map on the right. In this example they are in the Massachusetts Mainland coordinate system.
- The dX (pixels), dY (pixels), and residual (pixels) columns refer to error. In other words, is one of your GCPs in the wrong place? In this example all are zero so the match is perfect! Zero residuals don’t occur very often. But they can when you use the clip region technique that I’ve used here. Its common to have errors of two or three (when you’ve got good control) or up to ten or fifteen when the control is poor such as when your GCPs are trees, wide road intersections or other poorly defined features. Depending on your project, you might get away with errors up to say around twenty. There are no hard and fast rules here. There are often many factors in play. You should always test to see if your georeferencing results are acceptable. After I run the GIS georeferencer, I will overlay cadastral maps. That way I can see how well the GIS property boundaries overlay onto the rectified image.
I could write paragraphs and paragraphs about this stuff.
Step 8: Start the Qgis georeferencer.
Once you’ve digitized the four Ground control points then click the green arrow to start the georeferencer.
Step 9: The Transformation Settings dialog
Next, the Transformation settings dialog box will appear. This dialog looks a bit daunting at first glance, but because we’ve got a good quality scan to georeference (the basemap and its border was printed from QGIS and was scanned pointing north), all you really need to do is to…
- Set the Transformation Type: Polynominal 1
- Set the resampling method: Nearest neighbor
- Set the target Spatial Reference System (SRS): In this case it’s the Massachusetts Mainland. Avoid disaster and make sure the SRS you choose is the same coordinate system as the other GIS maps you’re using.
- Ensure that you nominate an Output raster. Give it a name (YarmouthLandUseInterpretation_rectified.tif)
- Check the Load in QGIS when done box.
The rest will look after itself.
We can take these defaults because we’re starting off with a basemap that…
- has already been photogrammetrically corrected, and
- has been carefully placed in the scanner so it faces north.
We only need to geo-reference our interpretation and we don’t need to geo-rectify it. Click the OK button and the settings are loaded. Then click the program runs and the processed image will load in QGIS.
Step 10: The image has been georeferenced in QGIS
And, there it is. Done!
The GIS clip region overlays the clip region that was printed on top of the base map perfectly. The cadastre (property map) overlays perfectly too.
So there you are. A ten step process to georeferencing in QGIS. Turning a scanned map or photo from being in scanner coordinates to being in GIS coordinates. The process I showed you works well because I started out with a GIS map surrounded by a rectangular clip region that I could relate back to after the printed version of the map had an interpretation drawn on it and was scanned back in.
Having said that, I have used the exact same process (minus the rectangular clip region) with scanned air photos many times. It just takes more time and effort to find ground control points that you can match to GIS maps of themes like roads, rivers and cadastre (property boundaries).
See also my post on how to set the QGIS snapping options.
If you would like to watch the videos that accompany this overview, and follow along with the dataset on your own computer, click this link to enrol.