[postgis-users] raster2pgsql fail with JPEG encoded image

Jorge Gustavo Rocha jgr at di.uminho.pt
Tue Oct 1 16:05:35 PDT 2019


Hi,

For now, I use this something like this (before raster2pgsql):

gdalwarp -of vrt '05-D Braga.jpg' /vsistdout/ | gdal_translate -co
compress=jpeg /vsistdin/ '05-D Braga.tif'

Using gdalwarp, the "GeoTransform" is applied and raster2pgsql does not
have to handle it.

Best regards,

Jorge

Às 23:32 de 01/10/19, Jorge Gustavo Rocha escreveu:
> Hi,
> 
> Thank you Pierre and Jim for your comments.
> 
> It is definitely related with the raster "GeoTransform". raster2pgsql
> does handles it properly, but not in all circumstances.
> 
> I've looked at GDAL GetGeoTransform. It reads properly the necessary
> transformation. I've wrote a small python script to iterate all over the
> files just to report:
> print("GetGeoTransform={}".format(dataset.GetGeoTransform()))
> 
> All (failing in raster2pgsql) test files have GeoTransform matrices. If
> I open these rasters directly in QGIS, for example, the matrix is
> respected and applied.
> 
> When I load those rasters into Postgis with raster2pgsql, the
> GeoTransformation is not applied correctly.
> 
> There are several calls to GDALApplyGeoTransform in rasper2pgsql code. I
>  need more detailed verbose/debug output to see exactly which
> transformation is applied (and how the math is done).
> 
> Next step: debug raster2pgsql for such matrices. It is not my expertise,
> but I need raster2pgsql running for all kind of rasters.
> 
> I'll keep looking at this issue and I'll report back.
> 
> Tanks for the comments.
> 
> Regards,
> 
> Jorge
> 
> Às 20:25 de 30/09/19, Jim Klassen escreveu:
>> It's been awhile, but I think when I ran into this last, running the
>> image through gdal_warp first rewrote the image as North up.
>>
>> On 9/30/19 12:26 PM, Pierre Racine wrote:
>>> GDAL is complaining that your image is rotated and that it does not
>>> support it yet. What if you erase (or just rename) the .jgw,
>>> temporally to remove the rotation?
>>>
>>> Pierre
>>>
>>> -----Message d'origine-----
>>> De : postgis-users <postgis-users-bounces at lists.osgeo.org> De la part
>>> de Jorge Gustavo Rocha
>>> Envoyé : 27 septembre 2019 18:18
>>> À : PostGIS Users Discussion <postgis-users at lists.osgeo.org>
>>> Objet : [postgis-users] raster2pgsql fail with JPEG encoded image
>>>
>>> Hi Postgisers,
>>>
>>> I'm trying to find out why a particular JPEG image does not work with
>>> raster2pgsql.
>>>
>>> I've described the problem as a question in gis.stackexchange:
>>>
>>> https://gis.stackexchange.com/questions/337127/raster2pgsql-fail-with-jpeg-encoded-image
>>>
>>>
>>> There are no errors when inserting the raster in the database.
>>> gdalinfo works fine, both with the original image and the Postgis raster.
>>>
>>> The only error I got is if I try to save the Postgis raster back to a
>>> file system image, like:
>>>
>>> gdal_translate -of JPEG PG:"service=pg_geotuga dbname=geotuga
>>> schema=raster table=geologica mode=2" 05.jpg
>>>
>>> When I do this, I get the error: "GDAL PostGIS Raster driver can not
>>> work with rotated rasters yet." (but the image is written, but I'm not
>>> able to render it).
>>>
>>> I suspect that the encoding/compression of this specific image is not
>>> supported.
>>>
>>> identify '05-D Braga.jpg'
>>> 05-D Braga.jpg JPEG 10614x7739 10614x7739+0+0 8-bit sRGB 11.1453MiB
>>> 0.000u 0:00.000
>>>
>>> This is just one of the many geological rasters of the country. I
>>> would like to upload them all to Postgis. I can recode the images, if
>>> necessary, but even changing them from JPEG to GTiff is not enough.
>>>
>>> Preferably, I would like to identify and maybe fix the issue in
>>> raster2pgsql.
>>>
>>> The GDAL version reported by Postgis is 2.3.2 (does it use static
>>> libs?). The GDAL version on the system is 3.0.1.
>>>
>>> raster2pgsql -?
>>> RELEASE: 2.5.2 GDAL_VERSION=23 (r17328)
>>>
>>> gdalinfo --version
>>> GDAL 3.0.1, released 2019/06/28
>>>
>>> select postgis_full_version();
>>> POSTGIS="2.5.2 r17328" [EXTENSION] PGSQL="110" GEOS="3.7.0-CAPI-1.11.0
>>> 673b9939" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.3.2,
>>> released 2018/09/21" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.3.1"
>>> RASTER
>>>
>>> The database has raster support enabled and I can upload other rasters
>>> to the database without any issues.
>>>
>>> Best regards,
>>>
>>> Jorge Gustavo
>>> -- 
>>> Jorge Gustavo Rocha
>>> Departamento de Informática
>>> Universidade do Minho
>>> 4710-057 Braga
>>> Gabinete 3.29 (Piso 3)
>>> Tel: +351 253604480
>>> Fax: +351 253604471
>>> Móvel: +351 910333888
>>> skype: nabocudnosor
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
> 
> J. Gustavo
> 

J. Gustavo
-- 
Jorge Gustavo Rocha
Departamento de Informática
Universidade do Minho
4710-057 Braga
Gabinete 3.29 (Piso 3)
Tel: +351 253604480
Fax: +351 253604471
Móvel: +351 910333888
skype: nabocudnosor


More information about the postgis-users mailing list