Georeference an unreferenced image with QGIS

Introduction

It is important to learn how to georeference an unregistered image such as an air photo or planimetric map so that you could use it with your GIS data. If you are using OpenDroneMap or Agisoft Photoscan to process the air photos from the drone you will get a georeferenced orthophoto as an output.

This referenced or rectified image can be imported into QGIS and it will automatically be positioned in the coordinate reference system (CRS) that you used to process the photos. For example UTM Zone 49 for the Sukhbaatar aimag area. You should use a projected coordinate system for air photos instead of geographic coordinates.

If you used Microsoft Image Composite Editor (ICE) to mosaic the photos, the exported image will not have a coordinate reference system attached to it. To use it with a GIS application you will need to georeference or register the map to a CRS. You can georeference your image with the Georeferencer GDAL plugin for QGIS.

To georeference an image you will need to select ground control points (GCPs) on the image. A GCP is a point on the image which has a coordinate value associated with it. You will need at least four GCPs to georeference an image. The more GCPs the better the result could be.

How do you get GCPs?

  1. You can use a satellite image from Google Map or Bing Map and try to match features from them to features on your image. Note: The coordinates from Google Map is based on the Pseudo Mercator coordinate reference system (CRS).  You will need to reproject to get UTM coordinates. Also you should check the accuracy of the Google Map image. I have found errors of 2 to 15 m in different locations around the world.
  2. Use an existing orthophoto to match features on your image.
  3. Use a hand held GNSS (GPS) receiver to determine the coordinates of the features in your image. Note: hand held single phase receivers are accurate to between 1 to 10 m only.
  4. Use professional survey grade GNSS receivers with a base station at known coordinate point to get sub-centimetre accuracy for your GCPs.
  5. As a challenge you can also use the centre of your image from the drone for geo-registration. The coordinate is stored in the EXIF data on the jpg image from the GNSS receiver in the drone. If you know how to complete the exercise using this let me know (gus@gwnsys.ca).
Instead of feature matching you could set targets on the ground before you fly you mission. Survey the coordinates of those targets and use it for georeferencing. This is a traditional approach used by aerial mapping companies.

Using QGIS Georeferencer GDAL

It is recommended that you install and use QGIS 2.18x instead of 3.x because not all of the plugins have been upgraded to work with 3.x.  You can download and install QGIS 2.18.x for your operating system and workstation with the following link: https://www.qgis.org/en/site/forusers/download.html

Install and run QGIS. Select Plugins from the menu bar and select Manage and Install Plugins... Scroll down to Georeferencer GDAL and activate it by clicking on the box on the left and Close the Plugin dialog. The plugin should be installed and ready to be used.


Also add OpenLayers plugin to enable Google Satellite from Google Maps to be displayed in QGIS.

Note: QGIS defaults to Google's Pseudo Mercator projection if Google Satellite is displayed regardless of what your default projection is set to.

 This means that if you are using features on the Google Satellite image the XY coordinates you are registering your map to is in Pseudo Mercator coordinates not UTM if that is your project CRS. You will have to re-project the image back to UTM if you want that CRS.


A sample data set using a Mavic Pro drone for this tutorial is available at: Sample drone images & kml file for tutorial  Download the 14 images if you want to use it in this tutorial. There is also a Google Earth kml polygon file that shows the limits of the flight mission. All kml points are in geographic coordinates.

The files in the download folder include: Baruun-Urt_Square.kml, DJI_0004.jpg to DJI_0021.jpg.

You can create a map mosaic of the flight mission using Microsoft Image Composite Editor (ICE). See web blog tutorial at: ICE Mosaic Tutorial

Use the sample data set and follow the ICE tutorial to create a stitched or mosaic map of the aimag square in Sukhbaatar, Mongolia. Next you will use that image and georeference it with QGIS. Your stitched image should look like this output:


Next step is to add the kml polygon file which contains the geographic (latitude and longitude) coordinates of the project area. Zooming into this polygon will define the area for you to use the OpenLayers plugin to retrieve the Google satellite image of the square.


From QGIS Menu Bar select Project > New to create a new project, then select Layer > Add Layer > Add Vector Layer. You will get an Add vector layer dialog. Select Browse and go to the folder where you have downloaded the tutorial files. Select Baruun-Urt_Square.kml and Open. The polygon file will be imported into QGIS.

Note: the coordinates will be in geographic units because kml files are stored as latitude and longitude.

Next select Web > OpenLayers plugin > Google Maps > Google Satellite to display the Google Earth image of the project area.

QGIS Georeferencer

In this tutorial you will use Google satellite to obtain ground control points for georeferencing based on image features you can identify on the mosaic and the Google satellite image.

Note: when you use OpenLayers to display Google satellite in QGIS the project coordinate reference system (CRS) is changed to Pseudo Mercator. This is the CRS which is used by Google Earth.

Next select Raster > Georeferencer > Georeferencer to initiate the plugin dialog. From the menu bar select File > Open Raster and select your ICE stitched file.


Start georeferencing by selecting a feature point on your image that can be identified on the Google image in QGIS. An easy example will be the statue of Sukhbaatar in the middle of the square.  To do that you select Edit > Add Point or Ctrl-A from the keyboard. Your cursor will change to a + symbol. Click on the point in georeferencer. Once you do that an Enter map coordinates dialog will be displayed.


If you know the coordinates you can enter them directly in the dialog. In our example you will select From map canvas. When you do that you can select the point on QGIS and the coordinates will automatically be entered into the dialog. Click OK and the results of the first point will be shown in the GCP table in Georeferencer.


A red dot for the GCP in Georeferencer and QGIS will be displayed. Repeat the same process for four additional points. Try to spread out the points top left, top right, bottom left and bottom right of the mosaic to get a good distribution of GCPs.  When you are satisfied you should save the points with File > Save GCP points as, in case you need to reload them later.

Note: it is recommended that you do not select roof tops and that GCP points should be on the ground if possible. Buildings will be distorted based on the focal length and height of your camera. It will naturally be different than that of the satellite. 

When you are ready select File > Start georeferencing, you will get a dialog which says Please set transformation type. Click OK.  You will get a Transformation settings dialog.  Select Transformation type: Linear, Helmert,  Polynomial1, etc. Enter the name of your Output raster, select Load in QGIS when done and then OK to process.

When the process is complete the output tif file will be displayed in QGIS. You can decide if the georeferenced image is satisfactory. If not you can edit the GCPs to get a better fit or add more points. It is recommended that you try using different points to see what is the best fit for you.



Augusto Ribeiro
2018.08.18


Comments

Post a Comment

Popular posts from this blog

Microsoft Image Composite Editor (ICE)

DJI Phantom 3 - Flight Logs

FOSS4G GIS for Mining Monitoring - MN