Opened 13 years ago
Closed 13 years ago
#1537 closed defect (fixed)
[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: | master |
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 (3)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
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).
comment:3 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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...