[postgis-devel] ST_AddBand for out-db raster bug

Tomasz Bielinski tombieli at pg.gda.pl
Fri Jan 23 01:49:00 PST 2015


Hello
I’m writing this message, because of bug i found in posgis raster.
(I was unable to create user id on osgeo trac, and as result to create 
ticket)

The bug occurs in ST_AddBand function for out-db raster.
I used this function in fallowing way:

select ST_AddBand(null,'D:\\Mapy\\hrpt_test_12_01_2015.tif',ARRAY[1, 2, 
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);

And I received such error:
rt_raster_add_band: Can't add a 1200x1200 band to a 1200x1600 raster

Where hrpt_test_12_01_2015.tif is 1200px x 1600px valid GeoTiff with 14 
bands, and it gdalinfo is as fallows:
Driver: GTiff/GeoTIFF
Files: hrpt_test_12_01_2015.tif
Size is 1200, 1600
Coordinate System is:
PROJCS["Mercator, WGS 84, Bands: Solar zenith°,Solar azimuth°,Nadir to 
pixel°,Satellite inclination°,AVHRR channel 1 - raw,AVHRR channel 1 - 
albedo%,AVHRR channel 2 - raw,AVHRR channel 2 - albedo%,AVHRR channel 3 
- raw,AVHRR channel 3 - temperature°C,AVHRR channel 4 - raw,AVHRR 
channel 4 - temperature°C,AVHRR channel 5 - raw,AVHRR channel 5 - 
temperature°C",
     GEOGCS["Unknown datum based upon the WGS 84 ellipsoid",
         DATUM["Not_specified_based_on_WGS_84_ellipsoid",
             SPHEROID["WGS 84",6378137,298.257223563,
                 AUTHORITY["EPSG","7030"]],
             AUTHORITY["EPSG","6030"]],
         PRIMEM["Greenwich",0],
         UNIT["degree",0.0174532925199433],
         AUTHORITY["EPSG","4030"]],
     PROJECTION["Mercator_1SP"],
     PARAMETER["central_meridian",0],
     PARAMETER["scale_factor",1],
     PARAMETER["false_easting",0],
     PARAMETER["false_northing",0],
     UNIT["unknown",1]]
Origin = (1500000.000000000500000,7799999.999998852600000)
Pixel Size = (1000.000000000000000,-1000.000000000000000)
Metadata:
   AREA_OR_POINT=Area
   TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
   TIFFTAG_XRESOLUTION=96
   TIFFTAG_YRESOLUTION=96
Image Structure Metadata:
   INTERLEAVE=BAND
Corner Coordinates:
Upper Left  ( 1500000.000, 7800000.000) ( 13d28'29.03"E, 57d22'10.14"N)
Lower Left  ( 1500000.000, 6200000.000) ( 13d28'29.03"E, 48d44'51.33"N)
Upper Right ( 2700000.000, 7800000.000) ( 24d15'16.25"E, 57d22'10.14"N)
Lower Right ( 2700000.000, 6200000.000) ( 24d15'16.25"E, 48d44'51.33"N)
Center      ( 2100000.000, 7000000.000) ( 18d51'52.64"E, 53d16'34.72"N)
Band 1 Block=1200x1 Type=Float32, ColorInterp=Gray
Band 2 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 3 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 4 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 5 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 6 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 7 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 8 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 9 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 10 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 11 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 12 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 13 Block=1200x1 Type=Float32, ColorInterp=Undefined
Band 14 Block=1200x1 Type=Float32, ColorInterp=Undefined


As you can see bug occurs for non square rasters.

I tired to track this bug in source code, and I found somethig. It is 
located in rtpg_create.c file in RASTER_addBandOutDB() function, line 776.
http://trac.osgeo.org/postgis/browser/trunk/raster/rt_pg/rtpg_create.c#L776
Width of raster is written to height variable, which causes problem.

I hope this will be helpful.

I’m using postgis:
“POSTGIS="2.1.5 r13152" GEOS="3.4.2-CAPI-1.8.2 r3924" PROJ="Rel. 4.8.0, 
6 March 2012" GDAL="GDAL 1.11.1, released 2014/09/24" LIBXML="2.7.8" 
LIBJSON="UNKNOWN" RASTER”,
and postgres:
"PostgreSQL 9.4.0, compiled by Visual C++ build 1800, 64-bit"

Best Regards
Tomasz Bieliński
Gdańsk University of Technology


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20150123/902fdbd0/attachment.html>


More information about the postgis-devel mailing list