Adding a world file to a map image
Exporting a map as an image removes all of its spatial information. However, you can create an external text file, called a world file, which provides the georeferencing information for the raster image so that it can be used by GIS software, including QGIS, as a raster layer. In this recipe, we'll export a map composition as an image and create a world file along with it.
Getting ready
You will need to download the zipped shapefile from https://github.com/GeospatialPython/Learn/raw/master/Mississippi.zip and extract it to your qgis_data
directory in a subdirectory named ms
.
In addition to the shapefile, you will also need the MapComposer
class, to simplify the code needed to add this one element. If you have not already used it in a previous recipe, you can download it from https://github.com/GeospatialPython/Learn/raw/master/MapComposer.py.
This file must be accessible from the QGIS Python console; for this, you need to ensure that it is in the Python...