Set single pixel's value.
- Parameters
-
band | : the band to set value to |
x | : x ordinate (0-based) |
y | : y ordinate (0-based) |
val | : the pixel value |
converted | : (optional) non-zero if value truncated/clamped/converted |
- Returns
- ES_NONE on success, ES_ERROR on error
Definition at line 841 of file rt_band.c.
References ovdump::data, ES_ERROR, ES_NONE, FALSE, rt_band_t::hasnodata, rt_band_t::height, rt_band_t::isnodata, rt_band_t::offline, rt_band_t::pixtype, PT_16BSI, PT_16BUI, PT_1BB, PT_2BUI, PT_32BF, PT_32BSI, PT_32BUI, PT_4BUI, PT_64BF, PT_8BSI, PT_8BUI, PT_END, RASTER_DEBUG, rt_band_clamped_value_is_nodata(), rt_band_corrected_clamped_value(), rt_band_get_data(), rt_util_clamp_to_16BSI(), rt_util_clamp_to_16BUI(), rt_util_clamp_to_1BB(), rt_util_clamp_to_2BUI(), rt_util_clamp_to_32BSI(), rt_util_clamp_to_32BUI(), rt_util_clamp_to_32F(), rt_util_clamp_to_4BUI(), rt_util_clamp_to_8BSI(), rt_util_clamp_to_8BUI(), rt_util_dbl_trunc_warning(), rterror(), rtwarn(), and rt_band_t::width.
Referenced by fillRasterToPolygonize(), RASTER_mapAlgebra2(), RASTER_mapAlgebraExpr(), RASTER_mapAlgebraFct(), RASTER_mapAlgebraFctNgb(), RASTER_setPixelValue(), RASTER_setPixelValuesArray(), RASTER_setPixelValuesGeomval(), rt_band_reclass(), rt_raster_gdal_rasterize(), rt_raster_iterator(), test_band_get_nearest_pixel(), test_band_get_pixel_line(), test_band_get_pixel_of_value(), test_band_pixtype_16BSI(), test_band_pixtype_16BUI(), test_band_pixtype_1BB(), test_band_pixtype_2BUI(), test_band_pixtype_32BF(), test_band_pixtype_32BSI(), test_band_pixtype_32BUI(), test_band_pixtype_4BUI(), test_band_pixtype_64BF(), test_band_pixtype_8BSI(), test_band_pixtype_8BUI(), test_band_reclass(), test_band_stats(), test_band_value_count(), test_gdal_to_raster(), test_gdal_warp(), test_pixel_set_to_array(), test_raster_colormap(), test_raster_fully_within_distance(), test_raster_geos_contains(), test_raster_geos_contains_properly(), test_raster_geos_covered_by(), test_raster_geos_covers(), test_raster_geos_overlaps(), test_raster_geos_touches(), test_raster_intersects(), test_raster_iterator(), test_raster_perimeter(), test_raster_pixel_as_polygon(), test_raster_surface(), test_raster_to_gdal(), and test_raster_within_distance().
848 unsigned char*
data = NULL;
851 int32_t checkvalint = 0;
853 float checkvalfloat = 0;
854 double checkvaldouble = 0;
856 assert(NULL != band);
858 if (converted != NULL)
862 rterror(
"rt_band_set_pixel not implemented yet for OFFDB bands");
869 x < 0 || x >= band->
width ||
870 y < 0 || y >= band->
height 872 rterror(
"rt_band_set_pixel: Coordinates out of range");
884 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0 885 rtwarn(
"Value for pixel %d x %d has been corrected as clamped value becomes NODATA",
x,
y);
889 if (converted != NULL)
895 offset =
x + (
y * band->
width);
900 checkvalint = data[offset];
905 checkvalint = data[offset];
910 checkvalint = data[offset];
915 checkvalint = (int8_t) data[offset];
920 checkvalint = data[offset];
924 int16_t *ptr = (int16_t*) data;
926 checkvalint = (int16_t) ptr[offset];
930 uint16_t *ptr = (uint16_t*) data;
932 checkvalint = ptr[offset];
936 int32_t *ptr = (int32_t*) data;
938 checkvalint = (int32_t) ptr[offset];
944 checkvaluint = ptr[offset];
948 float *ptr = (
float*) data;
950 checkvalfloat = ptr[offset];
954 double *ptr = (
double*) data;
956 checkvaldouble = ptr[offset];
960 rterror(
"rt_band_set_pixel: Unknown pixeltype %d", pixtype);
967 RASTER_DEBUG(3,
"Band has a value that is not NODATA. Setting isnodata to FALSE");
974 checkvalint, checkvaluint,
975 checkvalfloat, checkvaldouble,
977 ) && converted != NULL) {
int32_t rt_util_clamp_to_32BSI(double value)
uint32_t rt_util_clamp_to_32BUI(double value)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
uint16_t rt_util_clamp_to_16BUI(double value)
void rtwarn(const char *fmt,...)
int8_t rt_util_clamp_to_8BSI(double value)
int rt_util_dbl_trunc_warning(double initialvalue, int32_t checkvalint, uint32_t checkvaluint, float checkvalfloat, double checkvaldouble, rt_pixtype pixtype)
uint8_t rt_util_clamp_to_4BUI(double value)
uint8_t rt_util_clamp_to_8BUI(double value)
uint8_t rt_util_clamp_to_1BB(double value)
int rt_band_clamped_value_is_nodata(rt_band band, double val)
Compare clamped value to band's clamped NODATA value.
rt_errorstate rt_band_corrected_clamped_value(rt_band band, double val, double *newval, int *corrected)
Correct value when clamped value is equal to clamped NODATA value.
#define RASTER_DEBUG(level, msg)
uint8_t rt_util_clamp_to_2BUI(double value)
float rt_util_clamp_to_32F(double value)
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
int16_t rt_util_clamp_to_16BSI(double value)