QGIS and Raster Mapping in 'Seamless' layer

Are the TIFs tiled? The OS Vector District raster images I have aren't. To find out using QGIS, load one of the rasters and select Information in the Raster menu. Click OK, and somewhere after the projection and metadata you should see a line something like: Band 1 Block=4000x65 Type=Byte, ColorInterp=Palette

If, as in this case the block size is the width of the image x some number of lines, then converting it to a tiled TIF can give you a good speedup in most cases. This is because we tend to want to look at rectangular areas of an image, and it avoids QGIS having to load an entire row of pixels only to discard most of them because they fall outside the view.

To do that, use the Translate menu item in the Raster menu. You can convert an entire directory, or just one file at a time. The key setting is the Creation Options which you should enable, and enter TILED for the name, and YES as the value. This defaults to a tile size of 256x256 which should be fine for most purposes, but it is possible to specify other sizes by adding BLOCKXSIZE and BLOCKYSIZE to the creation options and specifying the size you want.

Settings for the Translate tool


Addendum

When you tile your images, you will notice an increase in file size because the width and height of you image is probably not a multiple of the tile size. So with the OS Vector District raster the effective size will be 4096x4096, an increase of just under 5% of the file size, but QGIS and other tools will transparently treat it as 4000x4000.


Loading OS OpenData raster images into a Rasterlite database.

There are pre-compiled Rasterlite/Spatialite binaries for Windows (32 and 64-bit) so I took this route.

Step 1, install the software. For 32-bit Windows go here: http://www.gaia-gis.it/gaia-sins/windows-bin-x86/ or for 64-bit Windows go here: http://www.gaia-gis.it/gaia-sins/windows-bin-amd64/

Download (as a minimum) the following files and unzip them to a directory (I used C:/spatialite).

rasterlite_load-1.1c-win-xxx.zip

rasterlite_pyramid-1.1c-win-xxx.zip

rasterlite_topmost-1.1c-win-xxx.zip

spatialite-3.0.1-DLL-win-xxx.zip

spatialite_gui-1.5.0-stable-win-xxx.zip

You will also need a recent version of sqlite3.dll (the one that comes with OSGEO4W is too old), get it here: http://www.sqlite.org/sqlite-dll-win32-x86-3071100.zip

Unzip this to the C:/spatialite folder.

Finally, add C:/spatialite to your path.

Step 2, prepare the raster images. OpenData rasters are indexed TIFFs with world files. To be loaded into a Rasterlite database these need to be batch converted to geotiffs. Do this in QGIS, Raster -> Conversion -> Translate. Use batch mode and (most important) tick 'Expand' and set 'RGB'.

Step 3, load the directory of GeoTIFFs into a Rasterlite database. Go to your C:/spatialite directory, click on spatialite_gui and then create a new spatialite database in the directory containing the GeoTIFFs, you could call this 'vmd.sqlite' for example.

Next, open a command line window in the directory containing the GeoTIFFs and type this command:

rasterlite_load -d vmd.sqlite -T vmd -D . -i wavelet -q 25

This should load all of the GeoTIFFs in the directory into vmd.sqlite, in a table called 'vmd'. It will take a while, but the progress will be reported.

Next, build pyramids:

rasterlite_pyramid -d vmd.sqlite -T vmd -i wavelet -v

When this finishes, set topmost:

rasterlite_topmost -d vmd.sqlite -T vmd -v

That should be it, load the new Rasterlite database into QGIS via Layer -> Add Raster Layer.

See: www.gaia-gis.it/gaia-sins/rasterlite-docs/rasterlite-how-to.pdf for more on Rasterlite.

In closing. You can download one of my Rasterlite VectorMap District (VMD) databases from here (about 500 KB):

http://dl.dropbox.com/u/45121071/vmd.sqlite

Right-click on the link to download the db, don't try to open it in a browser.

Ordnance Survey VMD rasters are of course a blurry, washed-out, badly-styled, badly-labelled disgrace and you can't make a silk purse out of a pig's ear. The db should however load into QGIS with no problems, it looks best at about 1:10000. The QGIS screen rendering isn't that good either, but you can obtain the best quality available by exporting images from the print composer.

If you have problems loading the db let me know, it works here in QGIS 1.7.4 (Win) and in Master (Ubuntu). Nick.