Ticket #1537 (closed defect: fixed)

Opened 16 months ago

Last modified 16 months ago

[raster] Impossible to set the nodata value of a raster returned by ST_Intersection(raster, geometry, extenttype)

Reported by: pracine Owned by: pracine
Priority: medium Milestone: PostGIS 2.0.0
Component: raster Version: trunk
Keywords: Cc:

Description

This is a strange bug.

The first query shows the pixel type of the first band of the result of a ST_Intersection(raster, geometry, extent) operation:

SELECT ST_BandPixelType(
          ST_Intersection(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2), 
                          ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2)::geometry, 
                          'SECOND'), 1);

The pixel type is '8BSI' so I should be able to reset the nodata value of the resulting raster to whatever between -128 and 127 (say -3) but I can't set it to something smaller than 0:

SELECT ST_BandNodataValue(
        ST_SetBandNodataValue(
          ST_Intersection(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2), 
                          ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2)::geometry, 
                          'SECOND'), -3));

If I try to set it to something greater than -1 it works:

SELECT ST_BandNodataValue(
        ST_SetBandNodataValue(
          ST_Intersection(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2), 
                          ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2)::geometry, 
                          'SECOND'), 15))

and if I set the extent of the result of the intersection to 'FIRST' I can do what I want:

SELECT ST_BandNodataValue(
        ST_SetBandNodataValue(
          ST_Intersection(ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2), 
                          ST_AddBand(ST_MakeEmptyRaster(2, 2, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2)::geometry, 
                          'FIRST'), -15))

There might be something I don't get here...

Change History

Changed 16 months ago by pracine

I am pretty sure that if you replace the ST_Intersection call by the equivalent ST_MapAlgebraExpr call you get the same problem. Can test more as I have to leave...

Changed 16 months ago by dustymugs

Fixed in r9024. Though the band being returned is specified, the band pixel type was not being specified thus triggering the default estimation of the pixel type based upon the requested extent. Band pixel type is now explicitly specified for returnband in (FIRST|SECOND|BOTH).

Changed 16 months ago by pracine

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.