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 with it.
Getting ready
You will need to download the zipped shapefile from https://geospatialpython.googlecode.com/svn/Mississippi.zip and extract it to your qgis_data
directory, to 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://geospatialpython.googlecode.com/svn/MapComposer.py.
This file must be accessible from the QGIS Python console; for this, you need to ensure that it is in the python path directory. Place...