It is easy to export a raster file as a georeferenced images with e.g., GRASS, QGIS or gdal. It becomes more complicated if you want to export a map, composed of different layers. In QGIS, you can create very nice maps with the ‘print composer’, but these maps are not geo-referenced. A solution by Underdark is to use the QGIS command line to create a snapshot of a map, which will give you an image of any size and with corresponding world file. It works like a charm, except for the “any size” part. The function, on my system, does not handle very large image sizes very well.
But why not creating the World file myself?It is nothing but a text file with six lines defining the resolution and extent of the image. All that is required is the resolution of your images (number of pixels per mapping unit) and the coordinates of the upper left raster cell, one value per row:
Line 1: A: pixel size in the x-direction in map units/pixel Line 2: B: rotation about y-axis Line 3: C: rotation about x-axis Line 4: D: pixel size in the y-direction in map units Line 5: E: x-coordinate of the center of the upper left pixel Line 6: F: y-coordinate of the center of the upper left pixel
The steps below help you to create your own georeferenced map (image + world file) in QGIS and an image viewer.
First, create your map in print composer at the required resolution. Make sure to note the map extent (X min, X max, Y min and Y max)
Export the image and open in your favorite image viewer and get the image size (width and height) in pixels (actually, right click on the image in the nautilus file browser will give you the image width and height, and I guess in most file browsers).
Now, if: maxx and minx are the minimum and maximum X, maxy and miny the minimum and maximum Y Xpix is the width in pixesl Ypix is height in pixels
A = (maxx-minx)/Xpix D = -(maxy-miny)/Xpix E = minx F = maxy In most cases, you can set B and C to 0
Create a text file and copy the value for A to the first line, B to the second, C to the third, D to the fourth, E to the fifth and F to the sixth. Make sure to save the file with the same name as your map image, but change the extension to “wld”. Thus, if the name of your image is “My_map.png”, then your world file is “My_map.wld”.
To make this a slightly faster process, I wrote a small function in R, which you can download here. You still will have to get and fill in maxx, maxy, minx, miny, Xpix and Ypix, after which the function will create the text file for you.