Ticket #1139 (closed defect: fixed)

Opened 2 years ago

Last modified 16 months ago

[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: trunk
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

Changed 2 years ago by pracine

  • summary changed from [raster] Clamping should ignore nodata value to [raster] Values, when clamped, should not be set to nodata value

Changed 16 months ago by dustymugs

  • owner changed from pracine to dustymugs
  • status changed from new to assigned
  • type changed from enhancement to defect
  • milestone changed from PostGIS Raster Future to PostGIS 2.0.0

Changing as I'd consider this a defect that should be addressed in 2.0

Changed 16 months ago by dustymugs

  • status changed from assigned to closed
  • resolution set to fixed

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:

1. If boolean type, value other than NODATA value.

2. 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.

3. 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.

Note: See TracTickets for help on using tickets.