Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to use Ordnance Survey base mapping in QGIS. I would like to set up something like a seamless table in MapInfo. I think that the equivalent in QGIS is a Virtual Raster Table. The files are in tif format as they were when I download them.

I have built a VRT but it seems slow to load when I open the layer. I have also tried building pyramids for the data and this doesn't seem to speed it up that much.

Is there a way to speed this up? Am I missing something? Are there any good resources about steps to take to prepare raster data for use in QGIS?

Would I be best to start to load this information into a PostGIS database with PostGIS Raster installed?

share|improve this question
    
In the last couple of days I've created two Rasterlite databases using OS OpenData raster imagery. Each one covered one 100 x 100 km OS grid square, the first (Vector Map District Rasters) using one hundred tiles and the second (Streetview) using four hundred tiles. I could talk you through doing this if you are interested. Nick. –  nhopton Apr 16 '12 at 16:09
    
That would be really useful to get the instructions on how to do that. I am thinking about adding them to a PostGIS database when I update my PostGIS to 2.0. –  James S Apr 18 '12 at 8:37
    
Okay James, which OS raster dataset will you be using? Just so that I can tailor the command lines to suit. Nick. –  nhopton Apr 18 '12 at 9:33
    
I am using VectorMap District Raster and also the StreetView rasters as well. Mainly interested in VectorMap District to start with. –  James S Apr 18 '12 at 12:46

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
    
Would building pyramids as well as tiling the images be beneficial? –  James S Jul 6 '11 at 11:47
1  
Yes, absolutely. You may need to try different algorithms depending on your data, some produce better results than others. "nearest" is generally worst, "cubic" usually provides good results in a reasonable time, but you may find "cubic spline" or "lanczos" gives better results. I suggest you try the different algorithms on the same image and do a simple visual check in QGIS for whichever one looks the best. This is a fairly subjective thing though. –  MerseyViking Jul 6 '11 at 12:31

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.

share|improve this answer
    
thanks for this. I shall try this out in the next couple of days. –  James S Apr 20 '12 at 8:30
    
I really do suggest that you download my sample db first, to see what you can expect. In QGIS it is possible to play about with this to make it look a little less washed-out. Nick. –  nhopton Apr 20 '12 at 11:03
    
Just opened it using Add Raster Layer. That really is rather quick to load. I shall look at doing this then. If not using rasterlite then using PostGIS 2.0 –  James S Apr 20 '12 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.