1

If I export a GeoTiff from PostGIS (which is essentially a gdal operation), it loads into QGIS using the VRT driver but works fine.

When I right click and export without making any changes it imports back into QGIS using GTiff driver and this file is 0.6kb larger.

Gdalinfo gives exactly the same output for both files.

The reason for the question is when I send the file from PostGIS to someone they cannot load it into their old software, but no worries with the one exported from QGIS.

Is there some extra header information that gdalinfo does not show? I want to be able to generate a GeoTiff file similar to the exported type from QGIS.

EDIT: SQL:

SELECT lo_from_bytea(1234,(
WITH 
rast as ...
SELECT ST_AsGDALRaster((SELECT * FROM rast), 'GTiff', ARRAY['PROFILE=GeoTIFF','TFW=YES']) as tif))


SELECT lo_export(1234,'/tmp/tif.tif')

Driver: GTiff/GeoTIFF Files: RGB_2017-2-24 (5)__.tif Size is 512, 160 Coordinate System is: PROJCS["WGS 84 / UTM zone 55N", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]], PROJECTION["Transverse_Mercator"], PARAMETER["latitude_of_origin",0], PARAMETER["central_meridian",147], PARAMETER["scale_factor",0.9996], PARAMETER["false_easting",500000], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["Easting",EAST], AXIS["Northing",NORTH], AUTHORITY["EPSG","32655"]] Origin = (815896.631598158506677,-3239186.335398061200976) Pixel Size = (10.000000000000000,-10.000000000000000) Metadata: AREA_OR_POINT=Area Image Structure Metadata: INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( 815896.632,-3239186.335) (150d14'59.93"E, 29d14'31.50"S) Lower Left ( 815896.632,-3240786.335) (150d15' 1.57"E, 29d15'23.40"S) Upper Right ( 821016.632,-3239186.335) (150d18' 9.30"E, 29d14'26.85"S) Lower Right ( 821016.632,-3240786.335) (150d18'10.97"E, 29d15'18.75"S) Center ( 818456.632,-3239986.335) (150d16'35.44"E, 29d14'55.13"S) Band 1 Block=512x5 Type=Byte, ColorInterp=Red NoData Value=0 Band 2 Block=512x5 Type=Byte, ColorInterp=Green NoData Value=0 Band 3 Block=512x5 Type=Byte, ColorInterp=Blue NoData Value=0

  • 1
    A VRT is not a TIFF, it's a link to a TIFF (or other format).. I'd say the reason it works for you and not for others is the VRT can 'find' the raster on your system (network) but not on other systems (or networks). How are you exporting the TIFF from PostGIS? – Michael Stimson Mar 2 '17 at 23:36
  • St_asgdalraster to large object then I have a large object export function that exports to .tif then it is sent to client via webserver. – Ben Mar 2 '17 at 23:52
  • Where's that code? It would explain a lot about what's actually happening here. what format are you using in ST_AsGDALRaster? What list does postgis.net/docs/manual-2.2/RT_ST_GDALDrivers.html give you? – Michael Stimson Mar 2 '17 at 23:56
  • Ok on mobile now. Ill paste it in when I get back. It was all working perfectly while using srid 4326 then I wanted to use UTM type CRS and this started happenning. – Ben Mar 2 '17 at 23:59
  • From which image the gdalinfo report is? Could you add that also from the other? And I do not quite understand what you talk about VRT. Is the PostGIS function writing out a .vrt file? – user30184 Mar 3 '17 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.