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 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

share|improve this question
    
Just some constructive criticism to help the site work at its best potential. Instead of editing the title to say "solved", you should mark the answer as accepted. This increases reputation for you and nhopton (as the person with the accepted answer), and also increases the likelihood of getting good answers to other questions you may ask. The list of questions notes which ones have accepted answers, meaning no need for "solved" in the title. Thanks. –  user3461 Jul 23 '12 at 19:37
add comment

1 Answer

up vote 7 down vote accepted

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.

share|improve this answer
    
Thanks Nick. Just the ticket. Batch converted a sample of the OS VMD rasters and loaded into PostGIS. Rasters display correctly in full colour. –  mixedbredie Jul 23 '12 at 13:43
    
Thanks Nick, had the same issue and your solution works. It looks like there a new option in QGIS menus Raster > Convert > PCT to RGB which also work in Batch Mode and only does the color conversion Fabien –  fnicollet Aug 7 '12 at 12:26
    
is there linux commandline for this? I have Windows desktop and linux server –  simplexio Nov 29 '12 at 7:42
add comment

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.