Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#498 closed defect (fixed)

[wktraster] Gdal export of some files gives blank image

Reported by: robe Owned by: jorgearevalo
Priority: medium Milestone: WKTRaster 0.1.6
Component: raster Version: master
Keywords: Cc:

Description

I think my mapserver problems may be related to my export issues, and I'm not quite sure where the problem lies.

I tried this example from http://trac.osgeo.org/gdal/wiki/frmts_wtkraster.html

C:\python25\python gdal2wktraster.py -r small_world.tif -t ch13.small_world -l 1 -k 40x20 -o small_world.sql -s 4326 

Then tried to export it with

gdal_translate -of PNG PG:"host=localhost dbname=
'wktraster_postgis15' user='postgres' password='whatever' schema='ch13' table=sm
all_world" C:\small_world.png

gdal_translate -of JPEG -band 1 PG:"host=localhost dbname=
'wktraster_postgis15' user='postgres' password='whatever' schema='ch13' table=sm
all_world" C:\small_world_bw.jpg

And those both work fine, but if I try to do the same thing with the PostGIS elepant, I just get a blank or black screen output.

C:\python25\python gdal2wktraster.py -r pele.png -t ch13.pele2 -l 1 -k 40x20 -o pele2.sql 
psql -h localhost -d wktraster_postgis15 -U postgres -f pele2.sql

gdal_translate -of PNG PG:"host=localhost dbname=
'wktraster_postgis15' user='postgres' password='whatever' schema='ch13' table=pele2" C:\pelefromdb.png

Just gives me a black box or blank image of the right dimensions.

I had the same issue with a georefenced MrSID file I had converted to georeferenced JPEG and then loaded in, but I thought maybe it was my conversion statement.

I tried on an ArcView Raster file (BIL) and exported that and that seemed to work fine.

So now I'm beginning to thinks its either the pixel types or original file type. Quick scan of pixel values in db look right to me well they are definitely all differnt numbers.

Attached is the PostGIS elephant to test with.

Attachments (3)

utm.tif (256.8 KB ) - added by jorgearevalo 14 years ago.
stock_elephant.png (125.1 KB ) - added by jorgearevalo 14 years ago.
wonderpostgis_banner.png (152.0 KB ) - added by jorgearevalo 14 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by robe, 14 years ago

Okay probably easier for me to provide link to file

http://www.postgis.org/download/logo_suite/stock_elephant/stock_elephant.png

(that's the one I called pele.png in code above)

comment:2 by robe, 14 years ago

Summary: Gdal export of some files gives blank image[wktraster] Gdal export of some files gives blank image

comment:3 by jorgearevalo, 14 years ago

This is a GDAL WKT Raster driver issue. Thanks for the info. Working on it.

comment:4 by pracine, 14 years ago

Owner: changed from pracine to jorgearevalo

comment:5 by jorgearevalo, 14 years ago

Hello,

Basically, the problem is the tiles of the second image (the elephant) don't have the same size. The image is 299x439 px and the tiles are 40x20 px. The GDAL driver still can't work properly with irregularly tiled raster coverages. But good news are I'm currently working on it, to add complete support for all kinds of raster arrangements defined in http://trac.osgeo.org/postgis/wiki/WKTRaster/Documentation01 (section 3.1.2).

At same time, I'm working on fixing the errors on functions like ST_DumpAsPolygons, to finish the tasks for Objective 0.1.6e.

I'm very sorry for these problems. And many thanks for the testing job!

comment:6 by jorgearevalo, 14 years ago

I think the bug in GDAL WKT Raster is only with non-referenced rasters (srid = -1). Still debugging…

by jorgearevalo, 14 years ago

Attachment: utm.tif added

by jorgearevalo, 14 years ago

Attachment: stock_elephant.png added

by jorgearevalo, 14 years ago

Attachment: wonderpostgis_banner.png added

comment:7 by jorgearevalo, 14 years ago

Resolution: fixed
Status: newclosed

Fixed in r5577. I've rewritten a lot of code of GDAL WKT Raster driver (update your gdal library), because sometimes the raster properties weren't properly read. On the other hand, it's not necessary to make pixelsize y (from GDALGetGeoTransform) negative. This GDAL function takes into account if is necessary to make it, and do make it. So, I deleted this part from gdal2wktraster script.

I've tested the code with the following (attached) images:

$ gdal2wktraster.py -r stock_elephant.png -t gis_schema.stock_elephant -k 40x20 
-l 1 -o stock_elephant.sql

$ psql -d gisdb -f stock_elephant.sql

$ gdal_translate -of PNG PG:"host=localhost dbname=gisdb user=gis password=gis
 schema=gis_schema table=stock_elephant" stock_elephant_fromdb.png
$ gdal2wktraster.py -r wonderpostgis_banner.png -t gis_schema.wonderpostgis_banner -k 40x20
 -l 1 -o wonderpostigs_banner.sql

$ psql -d gisdb -f wonderpostigs_banner.sql

$ gdal_translate -of PNG PG:"host=localhost dbname=gisdb user=gis password=gis 
schema=gis_schema table=wonderpostigs_banner" wonderpostigs_banner_fromdb.png
$ gdal2wktraster.py -r utm.tif -t gis_schema.utm -k 40x20 -s 26711 -l 1 -o utm.sql

$ psql -d gisdb -f utm.sql

$ gdal_translate -of PNG PG:"host=localhost dbname=gisdb user=gis password=gis
 schema=gis_schema table=utm" utm_fromdb.png

comment:8 by robe, 14 years ago

sorry put my comment in wrong ticket - repasted here


Jorge,

Which version of GDAL should we be using? I was using I think GDAL 1.6.1 because that's the only working already compiled version for Python for windows that I got from cheeseshop. The 1.7 doesn't seem to exist binaries for and I haven't explored compiling with python bindings.

If I'm going to go that far, should I just use trunk which I think is 1.8dev or is it better to stick with 1.7 branch and even latest stable release (1.7.1 I think).

in reply to:  8 comment:9 by jorgearevalo, 14 years ago

Replying to robe:

sorry put my comment in wrong ticket - repasted here


Jorge,

Which version of GDAL should we be using? I was using I think GDAL 1.6.1 because that's the only working already compiled version for Python for windows that I got from cheeseshop. The 1.7 doesn't seem to exist binaries for and I haven't explored compiling with python bindings.

If I'm going to go that far, should I just use trunk which I think is 1.8dev or is it better to stick with 1.7 branch and even latest stable release (1.7.1 I think).

I'm using last version from repository (1.8dev) because I'm developing GDAL WKT Raster driver too. But it should work with any GDAL version ≥ 1.6.0.

comment:10 by jorgearevalo, 14 years ago

Oh, sorry. My changes are on version 1.8.0dev, of course. I merged 2 tickets, because I was considering polygonize function, that it's present since GDAL 1.6.0.

So, you'll need the last GDAL version from SVN. To compile with python bindings, I simply do:

./configure —with-python

but I've not tested it in Windows.

Note: See TracTickets for help on using tickets.