1

The problem

I have one JPEG encoded raster that works in GDAL and QGIS. The original file 05-D Braga.jpg is available online. The CRS is EPSG:20790.

To upload it to Postgis, I use:

raster2pgsql -s 20790 -d -I -C -F -t 512x512 -l 2,4,8,16,32,64,128,256,512 "05-D Braga.jpg" raster.geologica  | psql service=pg_geotuga

The raster table and overview tables are created. But I'm not able to see the resulting raster in QGIS. The original image works well (from the file system), but from Postgis, it does not work.

I have several other rasters on the same database. This is just the one that does not work.

Any clues about the problem?

gdalinfo details

gdalinfo of the resulting Postgis raster:

jgr@zoe:~/bonn/ownCloud/ShareGeomaster/Dados/05-D$ gdalinfo PG:"service=pg_geotuga dbname=geotuga schema=raster table=geologica mode=2"
Driver: PostGISRaster/PostGIS Raster driver
Files: none associated
Size is 10619, 7761
Coordinate System is:
BOUNDCRS[
    SOURCECRS[
        PROJCRS["Lisbon (Lisbon) / Portuguese National Grid",
        (...)
Data axis to CRS axis mapping: 1,2
Origin = (161494.310841620987048,523702.407182264025323)
Pixel Size = (4.248602672300000,-4.236062656300000)
Corner Coordinates:
Upper Left  (  161494.311,  523702.407) (  0d32'15.25"E, 41d40'48.54"N)
Lower Left  (  161494.311,  490826.325) (  0d32'22.83"E, 41d23' 2.97"N)
Upper Right (  206610.223,  523702.407) (  1d 4'45.79"E, 41d40'51.79"N)
Lower Right (  206610.223,  490826.325) (  1d 4'44.49"E, 41d23' 6.19"N)
Center      (  184052.267,  507264.366) (  0d48'32.08"E, 41d31'58.53"N)
Band 1 Block=2048x2048 Type=Byte, ColorInterp=Red
  Overviews: 5309x3881, 2655x1940, 1327x970, 664x485, 332x243, 166x121, 83x61, 41x30, 21x15
Band 2 Block=2048x2048 Type=Byte, ColorInterp=Green
  Overviews: 5309x3881, 2655x1940, 1327x970, 664x485, 332x243, 166x121, 83x61, 41x30, 21x15
Band 3 Block=2048x2048 Type=Byte, ColorInterp=Blue
  Overviews: 5309x3881, 2655x1940, 1327x970, 664x485, 332x243, 166x121, 83x61, 41x30, 21x15

gdalinfo of the original raster:

jgr@zoe:~/bonn/ownCloud/ShareGeomaster/Dados/05-D$ gdalinfo '05-D Braga.jpg'
Driver: JPEG/JPEG JFIF
Files: 05-D Braga.jpg
       05-D Braga.jpg.aux.xml
       05-D Braga.jgw
Size is 10614, 7739
Coordinate System is:
PROJCRS["Lisboa_Hayford_Gauss_IGeoE",
  (...)
Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (  161514.667,  523608.581) (  8d35'38.71"W, 41d40'45.50"N)
Lower Left  (  161494.311,  490825.692) (  8d35'32.04"W, 41d23' 2.95"N)
Upper Right (  206609.336,  523702.407) (  8d 3' 9.11"W, 41d40'51.79"N)
Lower Right (  206588.980,  490919.518) (  8d 3'11.28"W, 41d23' 9.21"N)
Center      (  184051.824,  507264.050) (  8d19'22.80"W, 41d31'58.52"N)
Band 1 Block=10614x1 Type=Byte, ColorInterp=Red
  Overviews: 5307x3870, 2654x1935, 1327x968
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 2 Block=10614x1 Type=Byte, ColorInterp=Green
  Overviews: 5307x3870, 2654x1935, 1327x968
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 3 Block=10614x1 Type=Byte, ColorInterp=Blue
  Overviews: 5307x3870, 2654x1935, 1327x968
  Image Structure Metadata:
    COMPRESSION=JPEG

More info

gdal is able to read the image, for example, and save it as tiff. The resulting image (from the file system) displays well in QGIS. If I insert the converted GTiff image, it does not work.

gdal_translate -of GTiff "05-D Braga.jpg" 05-D.tiff

QGIS image preview

In the screen shot below, both the image from the file system and from Postgis as shown. Using map swipe, we can see that only one displays properly.

Postgis raster image not displaying properly

1
  • I'm using Ubuntu 18.04, with postgis 2.5.2, gdal 3.0.1 and QGIS 3.8
    – jgrocha
    Sep 27 '19 at 16:17

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.