Freehand raster georeferencer plugin for QGIS

Source code

The source code is on github: https://github.com/gvellut/FreehandRasterGeoreferencer 

Usage

The plugin installs the following UI element:

Above, the toolbar, with all tools enabled.

“Add a raster for interactive georeferencing” tool

This tool adds a raster to the map. It uses Qt to read and and manipulate the raster and is therefore limited to the formats supported by that library (almost none of the GDAL raster formats are supported and very large rasters should be avoided). Note that the raster layer added by this tool does not have all the capabilities of a normal QGIS raster layer: It is limited to visualization and modification using the provided tools. One additional limitation is its lack of support for changing CRS.. If more is needed, a georeferenced raster can be exported using the “Export raster with world file” tool: This raster can then be reimported using the standard “Add Raster” QGIS command and will behave like a normal QGIS raster layer (its georeferencing will be fixed however).

Click on “Browse…” to select a file (JPEG, PNG or BMP) and OK to load the raster.

As a result, a new layer is created in the Table of Content and is displayed on the map canvas. When first created, the raster has the following characteristics:

Properties of the layer can be visualized by double-clicking on the entry in the TOC: A dialog opens where some details about the layer are displayed, including the location of the image file and the transformation parameters that are applied to it (position of the center, scale in X and Y and rotation angle). It is also possible to modify the transparency of the layer: The change of transparency is applied immediately to the raster on the map.

When a raster layer created with this tool is selected in the TOC, the other tools are enabled and can be used to change the transformation parameters applied to the raster. If modified, those parameters are saved along with the QGS project file.

“Move raster” tool

This tool allows the user to change the center of the raster. To use, select the tool in the toolbar then click on the map canvas and move the mouse while holding the mouse button. This defines a translation vector from the first point clicked to the point where the mouse was released: The center of the canvas will be transformed using this vector.

“Rotate raster” tool

This tool allows the user to change the orientation of the raster. To use, select the tool in the toolbar then click anywhere on the map canvas and move the mouse in the vertical direction (in the coordinate system of the screen): If the mouse moves up, the raster will rotate counter-clockwise around its center. Otherwise, the raster will rotate in a clockwise manner.

“Scale raster” tool

This tool allows the user to scale the raster independently in both X and Y (in the coordinate system of the raster). To use, select the tool in the toolbar then click anywhere on the map canvas and move the mouse in with the vertical or horizontal direction (in the coordinate system of the screen): If the mouse moves up, the height of the raster is scaled up. Otherwise it is scaled down. It works the same way for the horizontal direction and the width of the raster.

“Adjust sides of raster” tool

This tool allows the user to adjust the sides of the raster, one at a time. To use, select the tool in the toolbar then click on the map near the side that needs adjusting: The side closest to the click becomes highlighted in bold red. Then move the mouse in the direction of adjustment (depending on the chosen side, vertically or horizontally in the coordinate system of the raster). The chosen side is moved to the new position while the others stay where they are.

“Decrease transparency” tool

This tool allows the user to decrease the transparency level of the raster, by increment of 10%.

“Increase transparency” tool

This tool allows the user to increase the transparency level of the raster, by increment of 10%.

“Export raster with world file” tool

This tool allows the user to export a version of the raster along with a world file. This raster can then be imported in QGIS or any GIS software that supports georeferencing with world files. Note that since most GIS software (including QGIS and ArcGIS) do not support rotations in world files, the output raster will be exported with the rotation as well as the scaling factor between the axis (since scaling inside a world file can only be along the X or Y axis). The world file will then include the displacement and scaling to world coordinates.

When launched, this tool simply asks the user the location of the exported file.