Opened 13 years ago
Closed 13 years ago
#1139 closed defect (fixed)
[raster] Values, when clamped, should not be set to nodata value
Reported by: | pracine | Owned by: | dustymugs |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | raster | Version: | master |
Keywords: | Cc: |
Description
When clamping values, if the clamped value becomes equal to the nodata value, it should be incremented or decremented by 1.
For example, setting 2 in a 1BB raster having 0 as nodata value:
SELECT ST_Value(ST_SetValue(ST_AddBand(ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0, -1), '1BB'::text, 1, 0), 1, 1, 2),1, 1)
works fine but setting -1 in the same raster stores a nodata value:
SELECT ST_Value(ST_SetValue(ST_AddBand(ST_MakeEmptyRaster(1, 1, 0, 0, 1, 1, 0, 0, -1), '1BB'::text, 1, 0), 1, 1, -1),1, 1)
should return 1, not NULL.
Nodata values should be set only when explicitly setting the exact nodata value (in this case 0) or NULL. Other values must be clamped to something different than the nodata value.
Change History (3)
comment:1 by , 13 years ago
Summary: | [raster] Clamping should ignore nodata value → [raster] Values, when clamped, should not be set to nodata value |
---|
comment:2 by , 13 years ago
Milestone: | PostGIS Raster Future → PostGIS 2.0.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Type: | enhancement → defect |
comment:3 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed in r9380. This is only in effect for rt_band_set_pixel(), not rt_band_set_pixel_line().
The criteria used for correcting a clamped value is:
- If boolean type, value other than NODATA value.
- If integer type, value is decremented by 1 unless the clamped value IS the minimum value possible for that pixel type where the value incremented by 1.
- If 32-bit floating point, value is decremented by FLT_EPSILON (minimum positive floating point number of type float) unless the clamped value IS the minimum value possible for that pixel type where the value incremented by FLT_EPSILON.
Changing as I'd consider this a defect that should be addressed in 2.0