Tuesday 26 January 2016

qgis - Why do TIF loaded into PostGIS lose their colormap?


I have successfully loaded a TIF image (using raster2pgsql) into my PostGIS 2.0.1 database. I can load the raster image into QGIS and it displays in the correct space. However, it has lost all colour and appears as a greyscale image. (Layer Properties > Style > Single band gray, colormap = grayscale)


If I load the same image directly from file into QGIS it displays colours correctly.(Layer Properties > Style > Single band gray, colormap = colormap)


If I convert the TIF to JPG and load the JPG to PostGIS and then display in QGIS the colours render correctly. (Layer Properties > Style > Three band color)


I can save the colourmap from an image and apply it to the greyscale images but the colours aren't quite right.


What do I need to do to get the TIF images to retain their colourmap when I load to PostGIS?


Windows 7 32-bit PostgreSQL 9.1.4 PostGIS 2.0.1 QGIS 1.8.0 raster2pgsql -s 27700 -I -C -M *.tif -F -t 200x200 gis_rasters.osvmd > vmd.sql


Thanks in advance



Ross



Answer



I suspect that your TIFFs might be Ordnance Survey Vector Map District rasters? I've not loaded any of these into Postgres/PostGIS but I have loaded some into a Rasterlite DB. The secret is to batch translate the TIFFs from indexed to RGB GeoTIFFs before loading them into the database. Raster -> Conversion -> Translate (Convert Format), tick 'Batch mode' and also tick 'Expand' (select 'RGB' from the drop down list).


Nick.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...