32 #define _LARGEFILE64_SOURCE 1
64 uint16_t width, uint16_t height,
66 uint32_t hasnodata,
double nodataval,
75 rterror(
"rt_band_new_inline: Out of memory allocating rt_band");
81 band->pixtype = pixtype;
84 band->height = height;
85 band->hasnodata = hasnodata ? 1 : 0;
96 rterror(
"rt_band_new_inline: Could not set NODATA value");
125 uint16_t width, uint16_t height,
127 uint32_t hasnodata,
double nodataval,
128 uint8_t bandNum,
const char* path
133 assert(NULL != path);
137 rterror(
"rt_band_new_offline: Out of memory allocating rt_band");
145 band->pixtype = pixtype;
148 band->height = height;
149 band->hasnodata = hasnodata ? 1 : 0;
157 rterror(
"rt_band_new_offline: Could not set NODATA value");
162 band->data.offline.bandNum = bandNum;
165 pathlen = strlen(path);
166 band->data.offline.path =
rtalloc(
sizeof(
char) * (pathlen + 1));
167 if (
band->data.offline.path == NULL) {
168 rterror(
"rt_band_new_offline: Out of memory allocating offline path");
172 memcpy(
band->data.offline.path, path, pathlen);
173 band->data.offline.path[pathlen] =
'\0';
175 band->data.offline.mem = NULL;
208 GDALDatasetH hdsSrc = NULL;
210 GDALRasterBandH hbandSrc = NULL;
212 GDALDataType gdpixtype;
218 if (hdsSrc == NULL && !force) {
219 rterror(
"rt_band_new_offline_from_path: Cannot open offline raster: %s", path);
223 nband = GDALGetRasterCount(hdsSrc);
224 if (!
nband && !force) {
225 rterror(
"rt_band_new_offline_from_path: No bands found in offline raster: %s", path);
230 else if (bandNum >
nband && !force) {
232 "rt_band_new_offline_from_path: Specified band %d not found in offline raster: %s",
240 hbandSrc = GDALGetRasterBand(hdsSrc, bandNum);
241 if (hbandSrc == NULL && !force) {
243 "rt_band_new_offline_from_path: Cannot get band %d from GDAL dataset",
250 gdpixtype = GDALGetRasterDataType(hbandSrc);
252 if (pt ==
PT_END && !force) {
254 "rt_band_new_offline_from_path: Unsupported pixel type %s of band %d from GDAL dataset",
255 GDALGetDataTypeName(gdpixtype),
264 nodataval = GDALGetRasterNoDataValue(hbandSrc, &hasnodata);
271 hasnodata, nodataval,
290 assert(
band != NULL);
298 band->data.offline.bandNum, (
const char *)
band->data.offline.path
303 uint8_t *
data = NULL;
306 rterror(
"rt_band_duplicate: Out of memory allocating online band data");
321 rterror(
"rt_band_duplicate: Could not copy band");
330 assert(NULL !=
band);
331 return band->offline ? 1 : 0;
349 if (
band->data.offline.mem != NULL)
352 if (
band->data.offline.path != NULL)
356 else if (
band->data.mem != NULL &&
band->ownsdata)
365 assert(NULL !=
band);
368 if (!
band->offline) {
369 RASTER_DEBUG(3,
"rt_band_get_ext_path: Band is not offline");
372 return band->data.offline.path;
377 assert(NULL !=
band);
378 assert(NULL != bandnum);
382 if (!
band->offline) {
383 RASTER_DEBUG(3,
"rt_band_get_ext_band_num: Band is not offline");
387 *bandnum =
band->data.offline.bandNum;
401 assert(NULL !=
band);
404 if (
band->data.offline.mem != NULL)
405 return band->data.offline.mem;
410 return band->data.offline.mem;
413 return band->data.mem;
430 GDALDatasetH hdsSrc = NULL;
432 VRTDatasetH hdsDst = NULL;
433 VRTSourcedRasterBandH hbandDst = NULL;
435 double offset[2] = {0};
442 assert(
band != NULL);
443 assert(
band->raster != NULL);
445 if (!
band->offline) {
446 rterror(
"rt_band_load_offline_data: Band is not offline");
449 else if (!strlen(
band->data.offline.path)) {
450 rterror(
"rt_band_load_offline_data: Offline band does not a have a specified file");
456 rterror(
"rt_band_load_offline_data: Access to offline bands disabled");
462 if (hdsSrc == NULL) {
463 rterror(
"rt_band_load_offline_data: Cannot open offline raster: %s",
band->data.offline.path);
468 nband = GDALGetRasterCount(hdsSrc);
470 rterror(
"rt_band_load_offline_data: No bands found in offline raster: %s",
band->data.offline.path);
475 else if (
band->data.offline.bandNum + 1 >
nband) {
476 rterror(
"rt_band_load_offline_data: Specified band %d not found in offline raster: %s",
band->data.offline.bandNum,
band->data.offline.path);
482 if (GDALGetGeoTransform(hdsSrc, ogt) != CE_None) {
483 RASTER_DEBUG(4,
"Using default geotransform matrix (0, 1, 0, 0, 0, -1)");
491 RASTER_DEBUGF(3,
"Offline geotransform (%f, %f, %f, %f, %f, %f)",
492 ogt[0], ogt[1], ogt[2], ogt[3], ogt[4], ogt[5]);
502 rterror(
"rt_band_load_offline_data: Could not test alignment of in-db representation of out-db raster");
507 rtwarn(
"The in-db representation of the out-db raster is not aligned. Band data may be incorrect");
514 &(offset[0]), &(offset[1]),
521 hdsDst = VRTCreate(
band->width,
band->height);
522 GDALSetGeoTransform(hdsDst, ogt);
529 hbandDst = (VRTSourcedRasterBandH) GDALGetRasterBand(hdsDst, 1);
532 GDALSetRasterNoDataValue(hbandDst,
band->nodataval);
535 hbandDst, GDALGetRasterBand(hdsSrc,
band->data.offline.bandNum + 1),
536 fabs(offset[0]), fabs(offset[1]),
540 "near", VRT_NODATA_UNSET
544 VRTFlushCache(hdsDst);
561 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s",
band->data.offline.path);
567 rterror(
"rt_band_load_offline_data: Cannot load data from offline raster: %s",
band->data.offline.path);
573 if (
band->data.offline.mem != NULL) {
575 band->data.offline.mem = NULL;
589 assert(NULL !=
band);
590 if (!
band->offline) {
591 rterror(
"rt_band_get_file_size: Band is not offline");
596 rterror(
"rt_band_get_file_size: Access to offline bands disabled");
600 if( VSIStatL(
band->data.offline.path, &sStat) != 0 ) {
601 rterror(
"rt_band_get_file_size: Cannot access file");
605 return sStat.st_size;
611 assert(NULL !=
band);
612 if (!
band->offline) {
613 rterror(
"rt_band_get_file_timestamp: Band is not offline");
618 rterror(
"rt_band_get_file_timestamp: Access to offline bands disabled");
622 if( VSIStatL(
band->data.offline.path, &sStat) != 0 ) {
623 rterror(
"rt_band_get_file_timestamp: Cannot access file");
627 return sStat.st_mtime;
633 assert(NULL !=
band);
636 return band->pixtype;
642 assert(NULL !=
band);
651 assert(NULL !=
band);
660 assert(NULL !=
band);
662 return band->ownsdata ? 1 : 0;
668 assert(NULL !=
band);
670 band->ownsdata = flag ? 1 : 0;
675 assert(NULL !=
band);
677 return band->hasnodata ? 1 : 0;
683 assert(NULL !=
band);
685 band->hasnodata = (flag) ? 1 : 0;
688 if (!
band->hasnodata &&
band->isnodata) {
689 RASTER_DEBUG(3,
"Setting isnodata to FALSE as band no longer has NODATA");
696 assert(NULL !=
band);
698 if (!
band->hasnodata) {
703 rterror(
"rt_band_set_isnodata_flag: Cannot set isnodata flag as band has no NODATA");
708 band->isnodata = (flag) ? 1 : 0;
715 assert(NULL !=
band);
718 return band->isnodata ? 1 : 0;
735 int32_t checkvalint = 0;
736 uint32_t checkvaluint = 0;
737 float checkvalfloat = 0;
738 double checkvaldouble = 0;
740 assert(NULL !=
band);
742 if (converted != NULL)
745 pixtype =
band->pixtype;
753 checkvalint =
band->nodataval;
758 checkvalint =
band->nodataval;
763 checkvalint =
band->nodataval;
768 checkvalint =
band->nodataval;
773 checkvalint =
band->nodataval;
778 checkvalint =
band->nodataval;
783 checkvalint =
band->nodataval;
788 checkvalint =
band->nodataval;
793 checkvaluint =
band->nodataval;
798 checkvalfloat =
band->nodataval;
802 band->nodataval = val;
803 checkvaldouble =
band->nodataval;
807 rterror(
"rt_band_set_nodata: Unknown pixeltype %d", pixtype);
823 checkvalint, checkvaluint,
824 checkvalfloat, checkvaldouble,
826 ) && converted != NULL) {
856 void *vals, uint32_t len
860 uint8_t *
data = NULL;
863 assert(NULL !=
band);
864 assert(vals != NULL && len > 0);
869 rterror(
"rt_band_set_pixel_line not implemented yet for OFFDB bands");
873 pixtype =
band->pixtype;
877 x < 0 || x >=
band->width ||
878 y < 0 || y >=
band->height
880 rterror(
"rt_band_set_pixel_line: Coordinates out of range (%d, %d) vs (%d, %d)",
x,
y,
band->width,
band->height);
885 offset =
x + (
y *
band->width);
889 if (len > (
band->width *
band->height) - offset) {
890 rterror(
"rt_band_set_pixel_line: Could not apply pixels as values length exceeds end of data");
902 memcpy(ptr, vals, size * len);
906 uint16_t *ptr = (uint16_t *)
data;
908 memcpy(ptr, vals, size * len);
912 int16_t *ptr = (int16_t *)
data;
914 memcpy(ptr, vals, size * len);
918 uint32_t *ptr = (uint32_t *)
data;
920 memcpy(ptr, vals, size * len);
924 int32_t *ptr = (int32_t *)
data;
926 memcpy(ptr, vals, size * len);
930 float *ptr = (
float *)
data;
932 memcpy(ptr, vals, size * len);
936 double *ptr = (
double *)
data;
938 memcpy(ptr, vals, size * len);
942 rterror(
"rt_band_set_pixel_line: Unknown pixeltype %d", pixtype);
947 #if POSTGIS_DEBUG_LEVEL > 0
981 uint8_t *
data = NULL;
984 int32_t checkvalint = 0;
985 uint32_t checkvaluint = 0;
986 float checkvalfloat = 0;
987 double checkvaldouble = 0;
989 assert(NULL !=
band);
991 if (converted != NULL)
995 rterror(
"rt_band_set_pixel not implemented yet for OFFDB bands");
999 pixtype =
band->pixtype;
1002 x < 0 || x >=
band->width ||
1003 y < 0 || y >=
band->height
1005 rterror(
"rt_band_set_pixel: Coordinates out of range");
1017 #if POSTGIS_RASTER_WARN_ON_TRUNCATION > 0
1018 rtwarn(
"Value for pixel %d x %d has been corrected as clamped value becomes NODATA",
x,
y);
1022 if (converted != NULL)
1028 offset =
x + (
y *
band->width);
1033 checkvalint =
data[offset];
1038 checkvalint =
data[offset];
1043 checkvalint =
data[offset];
1048 checkvalint = (int8_t)
data[offset];
1053 checkvalint =
data[offset];
1057 int16_t *ptr = (int16_t*)
data;
1059 checkvalint = (int16_t) ptr[offset];
1063 uint16_t *ptr = (uint16_t*)
data;
1065 checkvalint = ptr[offset];
1069 int32_t *ptr = (int32_t*)
data;
1071 checkvalint = (int32_t) ptr[offset];
1075 uint32_t *ptr = (uint32_t*)
data;
1077 checkvaluint = ptr[offset];
1081 float *ptr = (
float*)
data;
1083 checkvalfloat = ptr[offset];
1087 double *ptr = (
double*)
data;
1089 checkvaldouble = ptr[offset];
1093 rterror(
"rt_band_set_pixel: Unknown pixeltype %d", pixtype);
1100 RASTER_DEBUG(3,
"Band has a value that is not NODATA. Setting isnodata to FALSE");
1107 checkvalint, checkvaluint,
1108 checkvalfloat, checkvaldouble,
1110 ) && converted != NULL) {
1141 void **vals, uint16_t *nvals
1143 uint8_t *_vals = NULL;
1145 uint8_t *
data = NULL;
1146 uint32_t offset = 0;
1147 uint16_t _nvals = 0;
1149 uint8_t *ptr = NULL;
1151 assert(NULL !=
band);
1152 assert(vals != NULL && nvals != NULL);
1158 x < 0 || x >=
band->width ||
1159 y < 0 || y >=
band->height
1161 rtwarn(
"Attempting to get pixel values with out of range raster coordinates: (%d, %d)",
x,
y);
1170 rterror(
"rt_band_get_pixel_line: Cannot get band data");
1175 offset =
x + (
y *
band->width);
1183 maxlen =
band->width *
band->height;
1185 if (((
int) (offset + _nvals)) > maxlen) {
1186 _nvals = maxlen - offset;
1187 rtwarn(
"Limiting returning number values to %d", _nvals);
1191 ptr =
data + (offset * pixsize);
1193 _vals =
rtalloc(_nvals * pixsize);
1194 if (_vals == NULL) {
1195 rterror(
"rt_band_get_pixel_line: Could not allocate memory for pixel values");
1200 memcpy(_vals, ptr, _nvals * pixsize);
1228 uint8_t*
data = NULL;
1229 uint32_t offset = 0;
1231 assert(NULL !=
band);
1232 assert(NULL !=
value);
1239 x < 0 || x >=
band->width ||
1240 y < 0 || y >=
band->height
1242 rtwarn(
"Attempting to get pixel value with out of range raster coordinates: (%d, %d)",
x,
y);
1247 if (
band->isnodata) {
1248 RASTER_DEBUG(3,
"Band's isnodata flag is TRUE. Returning NODATA value");
1250 if (nodata != NULL) *nodata = 1;
1256 rterror(
"rt_band_get_pixel: Cannot get band data");
1261 offset =
x + (
y *
band->width);
1263 pixtype =
band->pixtype;
1267 #ifdef OPTIMIZE_SPACE
1269 int byteOffset = offset / 8;
1270 int bitOffset = offset % 8;
1274 *
value = getBits(
data, val, 1, bitOffset);
1279 #ifdef OPTIMIZE_SPACE
1281 int byteOffset = offset / 4;
1282 int bitOffset = offset % 4;
1286 *
value = getBits(
data, val, 2, bitOffset);
1291 #ifdef OPTIMIZE_SPACE
1293 int byteOffset = offset / 2;
1294 int bitOffset = offset % 2;
1298 *
value = getBits(
data, val, 2, bitOffset);
1303 int8_t val = (int8_t)
data[offset];
1308 uint8_t val =
data[offset];
1313 int16_t *ptr = (int16_t*)
data;
1314 *
value = ptr[offset];
1318 uint16_t *ptr = (uint16_t*)
data;
1319 *
value = ptr[offset];
1323 int32_t *ptr = (int32_t*)
data;
1324 *
value = ptr[offset];
1328 uint32_t *ptr = (uint32_t*)
data;
1329 *
value = ptr[offset];
1333 float *ptr = (
float*)
data;
1334 *
value = ptr[offset];
1338 double *ptr = (
double*)
data;
1339 *
value = ptr[offset];
1343 rterror(
"rt_band_get_pixel: Unknown pixeltype %d", pixtype);
1349 if (
band->hasnodata && nodata != NULL) {
1377 uint16_t distancex, uint16_t distancey,
1378 int exclude_nodata_value,
1382 int extent[4] = {0};
1383 int max_extent[4] = {0};
1386 uint32_t _d[2] = {0};
1401 assert(NULL !=
band);
1402 assert(NULL != npixels);
1419 exclude_nodata_value && (
1420 (x < 0 || x >
band->width) ||
1421 (y < 0 || y >
band->height)
1428 else if (
x >
band->width)
1433 else if (
y >
band->height)
1446 RASTER_DEBUG(4,
"No nearest pixels possible for provided pixel and distances");
1452 if (!
band->hasnodata)
1453 exclude_nodata_value =
FALSE;
1455 else if (exclude_nodata_value &&
band->isnodata) {
1456 RASTER_DEBUG(4,
"No nearest pixels possible as band is NODATA and excluding NODATA values");
1466 b = abs(
x -
band->width);
1475 b = abs(
y -
band->height);
1499 max_extent[0], max_extent[1], max_extent[2], max_extent[3]);
1507 extent[0] =
x - (int)_d[0];
1508 extent[1] =
y - (int)_d[1];
1509 extent[2] =
x + (int)_d[0];
1510 extent[3] =
y + (int)_d[1];
1512 RASTER_DEBUGF(4,
"Processing distances: %d x %d", _d[0], _d[1]);
1514 extent[0], extent[1], extent[2], extent[3]);
1516 for (i = 0; i < 2; i++) {
1520 _max = extent[2] - extent[0] + 1;
1523 _max = extent[3] - extent[1] + 1;
1526 for (j = 0; j < 2; j++) {
1555 for (k = 0; k < (uint32_t) _max; k++) {
1558 _x < max_extent[0] || _x > max_extent[2] ||
1559 _y < max_extent[1] || _y > max_extent[3]
1567 (_x < 0 || _x >=
band->width) ||
1568 (_y < 0 || _y >=
band->height)
1571 if (!
band->hasnodata)
1576 RASTER_DEBUGF(4,
"NODATA pixel outside band extent: (x, y, val) = (%d, %d, %f)", _x, _y,
pixval);
1587 rterror(
"rt_band_get_nearest_pixel: Could not get pixel value");
1596 if (!exclude_nodata_value || (exclude_nodata_value && !isnodata)) {
1598 RASTER_DEBUGF(4,
"Adding pixel to set of nearest pixels: (x, y, val) = (%d, %d, %f)", _x, _y,
pixval);
1601 if (*npixels == NULL)
1605 if (*npixels == NULL) {
1606 rterror(
"rt_band_get_nearest_pixel: Could not allocate memory for nearest pixel(s)");
1610 npixel = &((*npixels)[
count - 1]);
1616 if (!inextent && !
band->hasnodata)
1630 else if (d0 &&
count)
1654 double *searchset,
int searchcount,
1668 assert(NULL !=
band);
1669 assert(NULL != pixels);
1670 assert(NULL != searchset && searchcount > 0);
1672 if (!
band->hasnodata)
1673 exclude_nodata_value =
FALSE;
1675 else if (exclude_nodata_value &&
band->isnodata) {
1676 RASTER_DEBUG(4,
"Pixels cannot be searched as band is NODATA and excluding NODATA values");
1680 for (
x = 0;
x <
band->width;
x++) {
1681 for (
y = 0;
y <
band->height;
y++) {
1684 rterror(
"rt_band_get_pixel_of_value: Cannot get band pixel");
1687 else if (exclude_nodata_value && isnodata)
1690 for (i = 0; i < searchcount; i++) {
1700 if (*pixels == NULL)
1704 if (*pixels == NULL) {
1705 rterror(
"rt_band_get_pixel_of_value: Could not allocate memory for pixel(s)");
1731 assert(NULL !=
band);
1732 assert(NULL != nodata);
1734 *nodata =
band->nodataval;
1736 if (!
band->hasnodata) {
1737 rterror(
"rt_band_get_nodata: Band has no NODATA value");
1746 assert(NULL !=
band);
1757 assert(NULL !=
band);
1761 if (!
band->hasnodata) {
1766 pxValue =
band->nodataval;
1769 for (i = 0; i <
band->width; i++) {
1770 for (j = 0; j <
band->height; j++) {
1773 rterror(
"rt_band_check_is_nodata: Cannot get band pixel");
1776 else if (!isnodata) {
1801 assert(NULL !=
band);
1804 if (!
band->hasnodata)
1814 val,
band->nodataval,
1818 return isequal ? 1 : 0;
1837 double *newval,
int *corrected
1841 assert(NULL !=
band);
1842 assert(NULL != newval);
1844 if (corrected != NULL)
1856 switch (
band->pixtype) {
1858 *newval = !
band->nodataval;
1910 *newval += FLT_EPSILON;
1912 *newval -= FLT_EPSILON;
1917 rterror(
"rt_band_corrected_clamped_value: Unknown pixeltype %d",
band->pixtype);
1921 if (corrected != NULL)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
rt_pixtype rt_util_gdal_datatype_to_pixtype(GDALDataType gdt)
Convert GDALDataType to rt_pixtype.
#define RASTER_DEBUG(level, msg)
int rt_util_gdal_register_all(int force_register_all)
#define RASTER_DEBUGF(level, msg,...)
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
int8_t rt_util_clamp_to_8BSI(double value)
uint8_t rt_util_clamp_to_1BB(double value)
int32_t rt_util_clamp_to_32BSI(double value)
rt_errorstate rt_raster_geopoint_to_cell(rt_raster raster, double xw, double yw, double *xr, double *yr, double *igt)
Convert an xw, yw map point to a xr, yr raster point.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
int rt_util_dbl_trunc_warning(double initialvalue, int32_t checkvalint, uint32_t checkvaluint, float checkvalfloat, double checkvaldouble, rt_pixtype pixtype)
GDALDataType rt_util_pixtype_to_gdal_datatype(rt_pixtype pt)
Convert rt_pixtype to GDALDataType.
double rt_pixtype_get_min_value(rt_pixtype pixtype)
Return minimum value possible for pixel type.
struct rt_pixel_t * rt_pixel
rt_raster rt_raster_from_gdal_dataset(GDALDatasetH ds)
Return a raster from a GDAL dataset.
uint8_t rt_util_clamp_to_2BUI(double value)
void rtwarn(const char *fmt,...)
rt_errorstate rt_pixtype_compare_clamped_values(rt_pixtype pixtype, double val, double refval, int *isequal)
Test to see if two values are equal when clamped.
uint8_t rt_util_clamp_to_8BUI(double value)
GDALDatasetH rt_util_gdal_open(const char *fn, GDALAccess fn_access, int shared)
rt_errorstate
Enum definitions.
int16_t rt_util_clamp_to_16BSI(double value)
void * rtrealloc(void *mem, size_t size)
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
uint8_t rt_util_clamp_to_4BUI(double value)
const char * rt_pixtype_name(rt_pixtype pixtype)
void rtdealloc(void *mem)
uint16_t rt_util_clamp_to_16BUI(double value)
uint32_t rt_util_clamp_to_32BUI(double value)
float rt_util_clamp_to_32F(double value)
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
This library is the generic raster handling section of PostGIS.
static double distance(double x1, double y1, double x2, double y2)
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
void rt_band_set_ownsdata_flag(rt_band band, int flag)
int rt_band_get_pixel_of_value(rt_band band, int exclude_nodata_value, double *searchset, int searchcount, rt_pixel *pixels)
Search band for pixel(s) with search values.
rt_band rt_band_duplicate(rt_band band)
Create a new band duplicated from source band.
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
void rt_band_set_hasnodata_flag(rt_band band, int flag)
Set hasnodata flag value.
rt_errorstate rt_band_set_isnodata_flag(rt_band band, int flag)
Set isnodata flag value.
const char * rt_band_get_ext_path(rt_band band)
Return band's external path (only valid when rt_band_is_offline returns non-zero).
rt_errorstate rt_band_load_offline_data(rt_band band)
Load offline band's data.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
double rt_band_get_min_value(rt_band band)
Returns the minimal possible value for the band according to the pixel type.
uint64_t rt_band_get_file_size(rt_band band)
Return file size in bytes.
int rt_band_check_is_nodata(rt_band band)
Returns TRUE if the band is only nodata values.
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
rt_errorstate rt_band_set_pixel_line(rt_band band, int x, int y, void *vals, uint32_t len)
Set values of multiple pixels.
void rt_band_destroy(rt_band band)
Destroy a raster band.
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.
rt_band rt_band_new_offline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t bandNum, const char *path)
Create an out-db rt_band.
rt_errorstate rt_band_get_ext_band_num(rt_band band, uint8_t *bandnum)
Return bands' external band number (only valid when rt_band_is_offline returns non-zero).
uint64_t rt_band_get_file_timestamp(rt_band band)
Return file timestamp.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
rt_band rt_band_new_offline_from_path(uint16_t width, uint16_t height, int hasnodata, double nodataval, uint8_t bandNum, const char *path, int force)
Create an out-db rt_band from path.
uint32_t rt_band_get_nearest_pixel(rt_band band, int x, int y, uint16_t distancex, uint16_t distancey, int exclude_nodata_value, rt_pixel *npixels)
Get nearest pixel(s) with value (not NODATA) to specified pixel.
void * rt_band_get_data(rt_band band)
Get pointer to raster band data.
int rt_band_clamped_value_is_nodata(rt_band band, double val)
Compare clamped value to band's clamped NODATA value.
char enable_outdb_rasters
int rt_band_get_ownsdata_flag(rt_band band)
Return 0 (FALSE) or non-zero (TRUE) indicating if rt_band is responsible for managing the memory for ...
int rt_band_is_offline(rt_band band)
Return non-zero if the given band data is on the filesystem.
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
rt_errorstate rt_band_get_pixel_line(rt_band band, int x, int y, uint16_t len, void **vals, uint16_t *nvals)
Get values of multiple pixels.