Georeferencing Raster Imagery in QGIS using Vector Data

From CUOSGwiki
Jump to navigationJump to search

Purpose

The purpose of this tutorial is to learn how to conduct a georeferencing process on a non-georeferenced air photo in QGIS. Also, you will learn how to navigate through QGIS and learn how to use its basic functions. For the purpose of this tutorial, a basic understanding of GIS is assumed.

Introduction

QGIS: An Introduction

QGIS
QGIS Logo

QGIS is an open-source, cross-platform GIS Software. This means it is able for Mac OS, Linux, UNIX, Android, and Microsoft Windows. QGIS, previously known as Quantum GIS, was initially created by the Open Source Geospatial foundation in 2007 and is maintained by the QGIS Development Team. The software integrates many plugins that are written in either C++ or Python. Other open-source software packages are also integrated into the QGIS environment, such as: SQLite, GDAL, GRASS GIS, PostGIS and PostgreSQL.

Other open source GIS software packages such as PostGIS, GRASS and MapServer can be used in conjunction with QGIS, as to extend the software’s capabilities. Users also have access to Python plugins and plugins that are able to geocode using the Google Geocode API as well as an array of geoprocessing tools that are similar to those found in the well-known software package ArcGIS. QGIS is free open-source geographic information system (GIS) software that provides users with the ability to view, edit and analyse data. Users are able to generate maps using a variety of map layers using different projections. QGIS is compatible with both vector and raster data as well as geodatabases.

Georeferencing

Geo-referencing in GIS allows the user to use a known coordinate system to align geospatial data so that it may be viewed, queried or analyzed with other geospatial data. This process involves manipulating the data through shifting, scaling, rotating or skewing in order to align the datasets.

Satellite imagery can be affected by geometric distortions as a consequence of sensor geometry, inconsistency in the scanner or platform, earth rotation or earth curvature. These issues can be corrected by referencing the imagery to existing maps. Since satellite imagery and aerial photographs do not contain reference information to a location when in their original format. In order to use this information in combination with other geospatial datasets it is necessary to correct the imagery so that it has a similar resolution and projection as the data you wish to work with.[1]

Acquiring Data

Before beginning to aquire the data necessary for this exercise, it is best to create a folder to organize all of your project elements into. Somewhere on your computer that is easy to access (preferably in your C: drive on windows, or HOME directory on Linux), create a folder named Georeferencing Exercise'. This will be the location where we store all our data, as well as the QGIS project files.

The air photo used for this example can be located here: [2]. At this link, scroll about a third of the way down to the section labelled Available Themes. Select the bottom-most link 1930s - 1945 air photos from uOttawa. Refer to the figure on the right of this section of the tutorial to visualize the location of the desired photo. Click the dot, then the link that appears. Once on a screen with the photo as per figure, right click the photo and select Save Image As.... Save it to the folder made earlier.

In terms of reference vector data, study the image selected and locate as much reference vectore data as possible. This includes roads [3] (select Roads and Sidewalks under Ottawa-Gatineau section of this page), the railway line [4] (Select Direct Download - Carleton University campus datasets, followed by Construction_Services_GIS/, then rail.ZIP), and the river [5]. Download these three vector datasets, and extract them into your project folder made earlier.

Since this particular photo was taken in 1933, there will be sections of the data that do not exist in the image, but do not let this discourage you, as the sections that do will still be accurate, though created over 80 years later.


Table 1. Data Used in Geo-referencing Aerial Photography and Satellite Imagery
Data Used Data Format Data Source
Rail Vector Polygon Layer: Rail, 2010 / Producer: Carleton University Construction Services
Carleton Boundary Vector Polygon Layer: Carleton Boundary, 2010 / Producer: Carleton University Construction Services
Canal Vector Polygon Layer: Canal, 2010 / Producer: Carleton University Construction Services
Buildings Vector Polygon Layer: Buildings, 2010 / Producer: Carleton University Construction Services
Rideau River Vector Polygon Layer: Rideau River, 2010 / Producer: Carleton University Construction Services
Roads Vector Polygon Layer:Roads, 2010 / Producer: Carleton University Construction Services
Satellite Imagery Portable Network Graphics (PNG) Layer: Carleton University Campus, 2010 / Producer: Digital Globe (Google)


Figure 1.
Figure 1. Data Set.
  • Figure 1 shows the data set from the link provided. The link of course brings you to the Carleton Library GIS data page and therefore requires your Carleton login information. Make sure to save the data used in this tutorial to your computer and extract all of them to a file that you will be working with.



Installation

You can download QGIS from the following link [6] using the green Download Now button. Choose your platform: Windows, Mac OS X, Linux, BSD, or Android from the various drop-down menus on the download page (Windows will be used for this tutorial. If you have Windows, check your specifications and either you will use 32 bit or 64 bit. Select the latest standalone version and download the .exe istaller. Once downloaded, go to the location the .exe installer downloaded to, run it, and use the Setup Wizard that appears to configure the program.

Once QGIS is fully installed onto your computer, run it either via the desktop icon, or the start-menu launcher. Once opened, a program window like figure should appear. To create a project file for our project, click Project in the upper left corner, and Save As. Browse to the folder created in the earlier step, give the project a name, like Georeferencing Tutorial, and hit Save.

Adding Geospatial Data in QGIS

Vector Data

  • To add vector data into QGIS navigate to the toolbar situated at the top of the window, as demonstrated in Figure 4.
    Figure 5.
    Figure 5. Toolbar
  • Select the Add Vector Layer icon. Figure 5. Adding Vector Layer Files


  • A window will appear that prompts you to choose your file.
  • Toggle on the appropriate source type and set the coding option using the drop down menu.
  • Next, browse to the source of your vector file by clicking the Browse button on the window as seen in Figure 6.
Figure 6.
Figure 6. Vector File Window.


*This will bring up the search window.

  • Navigate to your folder and change the All Files drop down to ESRI Shapefiles to help narrow your search. If you want to be fast and efficient, you can hold the Ctrl key and select all of the desired files you wish to add. This will save your selection and add all of the files at once rather than you having to continuously clicking on the Add Vector Layer Icon and repeating this process over and over again.


Figure 7.
Figure 7. Browsing Files.


  • Your files will appear in the Layer Panel section and the files will be drawn in the white to the right of the Layer Panel.


Figure 8.
Figure 8. Vector Layers.


  • If want to look at the properties associated with each layer and change their symbology, right-click on the appropriate file in the Layer Panel as seen in Figure 9. Make sure the layers are in the appropriate order. This can be subjective but in this case you want to make sure buildings, roads, and rails are not under the Carleton Boundary for example.


Figure 9.
Figure 9. Properties.


  • To view data associated with your vector layer, select Open Attribute Table.
Figure 10.
Figure 10. Attribute Table Values'.





  • A window will open that will provide users with a variety of options associate with the layer as seen in Figure 11. In Properties, you can see the symbology of the layer but selecting the Styles tab. Users are able to change how their data is represented using this tab. Additional tabs such as General, Labels, Fields, Rendering, Display, Action, Joins, and so on which allow users to manipulate their data to their liking.
Figure 11.
Figure 11. Properties and Symbology'.



  • Select the General tab in order to view the layers coordinate system and file name.
    This is particularly useful whenever you need to georeference a raster file to match the projection of your vector layers.
Figure 12.
Figure 12. General Tab Under Properties.






Raster Data

  • To add a raster file into QGIS navigate to the toolbar at the top of the window and select the Add Raster Layer icon. RasterLayerIcon.PNG
  • Follow the same steps provided for adding a vector file.

Accessing a Plugin

  • To access the plugins available in QGIS navigate to the main toolbar near the top of the program and under Plugins select Manage Plugins.
Figure 13.
Figure 13. Plugins Toolbar.
  • A window will open providing you with several options for plugins. Scroll through them until you come across Georeferencer DGAL.
  • Toggle the Georeferencer DGAL on and you can close the menu.
Figure 14.
Figure 14. Available Plugins.


Using Georeferencer GDAL

The Georeferencer allows you to reference rasters to geographic coordinates or projections by creating a new GeoTiff file by adding a world file to the existing raster image. To reference a raster you are to locate points on the image that you can accurately identify their coordinates. X and Y coordinates can be Degrees Minutes Seconds (dd mm ss.ss), Decimal Degrees (dd.dd) or projected coordinates (mmmm.mm) depending on your data.

Opening the Georeferencer

  • Navigate to the main toolbar, and select the Raster Menu. You will notice that Georeferencer can be found at the bottom of the menu. Open the Georeferencer...
  • The Georeferencer window will appear and you will be able to add the file you wish to georeference, in our case it is the satellite image of the Carleton Campus.
Figure 15.
Figure 15. Georeferencer Plugin.


Adding a Raster

  • To georeference your image, you must first add it into the georeferencing window.


Figure 17.
Figure 17. Georeferencer Toolbar.
  • Navigate to the main toolbar of the Georeferencer and select the Add Raster Layer icon. RasterLayerIcon.PNG
  • Follow the steps provided for adding a vector file to navigate to and add the appropriate raster file.
Figure 16.
Figure 16. Georeferencer Toolbar.
  • Once you find your image and select it to be added, the Coordinate Reference System Selector will pop up. Since the image you are using must be georeferenced, you therefore do not have to select the coordinate system. If you did know what coordinate system your image was in then you will want to select the correct coordinate system.
Figure 18.
Figure 18. Raster Image'.


Adding Control Points

If you already have control points saved, you can load the file by selecting the Load Points icon Loadpts1.png Otherwise… Select the add control point icon AddIcon.PNG.

  • A window will appear prompting you to add the coordinates of the point, or find it on the referenced file within the main window of QGIS.
  • If you know the coordinates, enter them. Otherwise select From Map Canvas
Figure 19.
Figure 19. Adding a Point.
  • To delete a point, select the Delete Point icon Deletept1.png
  • You can move points by selecting the Move Points icon on the toolbar. Movept1.png




Zooming In and Out

  • To zoom in on the image in the georeferencer window select the Zoom In icon. Zoomin1.png
  • To zoom out on the image in the georeferencer window select the Zoom Out icon. Zoomout1.png
  • To move around the image, select the Pan icon Pan1.png

Points Table

  • The points which you have placed on your map image will appear below the raster image in the window.
  • To save your points select the Save Points icon on the toolbar.Savegcppts.png
  • This will save your points to an .aux.xml file for later viewing, or to add back into the Georeferencer.
  • If the residuals are high for some of your points, you should go back and move the point to be more accurate.


Transformation Settings

To access the transformation settings navigate to the toolbar on the Georeferencer and select the Transformation Settings icon. Trans1.png
After adding the Geographic Control Points (GCPs) you will need to define the settings for the georeferencing procedure.

  • Depending on how many points you have added to your image you may want to choose different transformation algorithms for your image.
Figure 20.
Figure 20. "Transformation Settings"


Transformation Type

Choose an appropriate transformation type.

  • The transformation types available to you include:
    • Linear: This is used to generate a world-file that will be different from the other algorithms available because it does not actually transform your image. This probably won't be the best option if you are using scanned imagery.
    • Helmert: This transformation will run simple scaling and rotation transformations.
    • Polynomial Algorithms: These will match source and destination control points. The 2nd order polynomial transformation allows for some curvature in your transformation. Using a 1st order polynomial transformation (affine) will perserve collinearity and will only permit scaling, translation and rotation on the image.
    • Thin Plate Spline: This transformation is able to introduce local deformations in the data. This is good if the original image being georeferenced is of poor quality.
    • Projective: The projective transformation is a linear rotation and translation of coordinates.

Defining the Resampling Method

  • Select one of the resampling method options by clicking on the drop down list. Your choice will vary depending on the objectives of your task.
  • Choose one of the following options:
    • Nearest neighbour
    • Linear
    • Cubic
    • Cubic Spline
    • Lanczos

Compression

  • Select the type of compression you wish to occur on your image.
  • The options include:
    • NONE
    • LZW
    • PACKBITS
    • DEFLATE

Output Raster

  • Select the location for the output file by selecting the Output Raster icon and navigating to the appropriate folder.

Target Spatial Reference System (SRS)

  • Choose the target coordinate system for your raster image by clicking the Target SRS icon [[7]]
  • A window will appear prompting you to choose a coordinate system for your image.

Generating a pdf map and report

  • To save a map or report to disk as a .pdf file, select the .pdf document icon next to Generate pdf map and/or Generate pdf report.
  • Navigate to the appropriate directory to save your files.

Set Target Resolution

Toggle on Set Target Resolution to set the pixel resolution for your output raster.

Additional Options

  • Toggle on Use 0 for transparency when needed to make areas with the value of 0 transparent.
  • Toggle on Load in QGIS when done to add the image into QGIS as a layer whenever the georeferencing process is complete.
  • Toggle on Create world file for linear transformations.

Select OK when complete.

Running the Georeferencer

Once all of the GCPs have been added and the Transformation Settings have been selected you can now georeference your raster image.

  • Select the Start Georeferencing icon on the main toolbar. Savegeo1.png
  • Make sure to check the box to add the image to your project.
  • This will create a new georeferenced image.

Georeferenced Raster

  • The file will appear in the Layers Panels. Move your layers so that the vector polygon layers appear on top of the raster image.
Figure 21.
Figure 21. "Georeferenced Raster with Vector File Overlay"


  • There you have it, a fully georeferenced image of the Carleton University Campus with Vector Data Associated with it.


  • Hope you took something from this tutorial.







References

52°North Initiative for Geospatial Open Source Software. (2013). ILWIS Open. Retrieved December 10, 2013, from 52°North: http://52north.org/communities/ilwis/ilwis-open
esri. (2013). GIS Dictionary. Retrieved December 10, 2013, from esri support: http://support.esri.com/en/knowledgebase/GISDictionary/term/vector
ESRI. (2008, September 22). What is a raster data? Retrieved December 10, 2013, from ArcGIS 9.2 Desktop Help: http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=What_is_raster_data%3F
Geomatics Solutions. (2011). NAD83 / MTM zone 9. Retrieved 2013, from Georepository: http://georepository.com/crs_32189/NAD83-MTM-zone-9.html
GNU. (2013, September 12). GNU General Public License. Retrieved December 10, 2013, from GNU Operating System : https://gnu.org/licenses/gpl.html
Python Software Foundation. (2013). Python Programming Language – Official Website. Retrieved December 10, 2013, from Python: http://python.org