PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rt_raster_iterator()

rt_errorstate rt_raster_iterator ( rt_iterator  itrset,
uint16_t  itrcount,
rt_extenttype  extenttype,
rt_raster  customextent,
rt_pixtype  pixtype,
uint8_t  hasnodata,
double  nodataval,
uint16_t  distancex,
uint16_t  distancey,
rt_mask  mask,
void *  userarg,
int(*)(rt_iterator_arg arg, void *userarg, double *value, int *nodata)  callback,
rt_raster rtnraster 
)

n-raster iterator.

Returns a raster with one band. The raster returned should be freed by the caller

Parameters
itrset: set of rt_iterator objects.
itrcount: number of objects in itrset.
extenttype: type of extent for the output raster.
customextent: raster specifying custom extent. is only used if extenttype is ET_CUSTOM.
pixtype: the desired pixel type of the output raster's band.
hasnodata: indicates if the band has nodata value
nodataval: the nodata value, will be appropriately truncated to fit the pixtype size.
distancex: the number of pixels around the specified pixel along the X axis
distancey: the number of pixels around the specified pixel along the Y axis
*userarg: pointer to any argument that is passed as-is to callback.
*callback: callback function for actual processing of pixel values.
*rtnraster: return one band raster from iterator process

The callback function must have the following signature.

int FNAME(rt_iterator_arg arg, void *userarg, double *value, int *nodata)

The callback function must return zero (error) or non-zero (success) indicating whether the function ran successfully. The parameters passed to the callback function are as follows.

  • rt_iterator_arg arg : struct containing pixel values, NODATA flags and metadata
  • void *userarg : NULL or calling function provides to rt_raster_iterator() for use by callback function
  • double *value : value of pixel to be burned by rt_raster_iterator()
  • int *nodata : flag (0 or 1) indicating that pixel to be burned is NODATA
Returns
ES_NONE on success, ES_ERROR on error

The raster returned should be freed by the caller

Parameters
itrset: set of rt_iterator objects.
itrcount: number of objects in itrset.
extenttype: type of extent for the output raster.
customextent: raster specifying custom extent. is only used if extenttype is ET_CUSTOM.
pixtype: the desired pixel type of the output raster's band.
hasnodata: indicates if the band has nodata value
nodataval: the nodata value, will be appropriately truncated to fit the pixtype size.
distancex: the number of pixels around the specified pixel along the X axis
distancey: the number of pixels around the specified pixel along the Y axis
mask: the object of mask
userarg: pointer to any argument that is passed as-is to callback.
callback: callback function for actual processing of pixel values.
*rtnraster: return one band raster from iterator process

The callback function must have the following signature.

int FNAME(rt_iterator_arg arg, void *userarg, double *value, int *nodata)

The callback function must return zero (error) or non-zero (success) indicating whether the function ran successfully. The parameters passed to the callback function are as follows.

  • rt_iterator_arg arg: struct containing pixel values, NODATA flags and metadata
  • void *userarg: NULL or calling function provides to rt_raster_iterator() for use by callback function
  • double *value: value of pixel to be burned by rt_raster_iterator()
  • int *nodata: flag (0 or 1) indicating that pixel to be burned is NODATA
Returns
ES_NONE on success, ES_ERROR on error

Definition at line 812 of file rt_mapalgebra.c.

827  {
828  /* output raster */
829  rt_raster rtnrast = NULL;
830  /* output raster's band */
831  rt_band rtnband = NULL;
832 
833  /* working raster */
834  rt_raster rast = NULL;
835 
836  _rti_iterator_arg _param = NULL;
837  int allnull = 0;
838  int allempty = 0;
839  int aligned = 0;
840  double offset[4] = {0.};
841  rt_pixel npixels;
842 
843  int i = 0;
844  int status = 0;
845  int inextent = 0;
846  int x = 0;
847  int y = 0;
848  int _x = 0;
849  int _y = 0;
850 
851  int _width = 0;
852  int _height = 0;
853 
854  double minval;
855  double value;
856  int isnodata;
857  int nodata;
858 
859  RASTER_DEBUG(3, "Starting...");
860 
861  assert(itrset != NULL && itrcount > 0);
862  assert(rtnraster != NULL);
863 
864  /* init rtnraster to NULL */
865  *rtnraster = NULL;
866 
867  /* check that callback function is not NULL */
868  if (callback == NULL) {
869  rterror("rt_raster_iterator: Callback function not provided");
870  return ES_ERROR;
871  }
872 
873  /* check that custom extent is provided if extenttype = ET_CUSTOM */
874  if (extenttype == ET_CUSTOM && rt_raster_is_empty(customextent)) {
875  rterror("rt_raster_iterator: Custom extent cannot be empty if extent type is ET_CUSTOM");
876  return ES_ERROR;
877  }
878 
879  /* check that pixtype != PT_END */
880  if (pixtype == PT_END) {
881  rterror("rt_raster_iterator: Pixel type cannot be PT_END");
882  return ES_ERROR;
883  }
884 
885  /* initialize _param */
886  if ((_param = _rti_iterator_arg_init()) == NULL) {
887  rterror("rt_raster_iterator: Could not initialize internal variables");
888  return ES_ERROR;
889  }
890 
891  /* fill _param */
892  if (!_rti_iterator_arg_populate(_param, itrset, itrcount, distancex, distancey, &allnull, &allempty)) {
893  rterror("rt_raster_iterator: Could not populate for internal variables");
895  return ES_ERROR;
896  }
897 
898  /* shortcut if all null, return NULL */
899  if (allnull == itrcount) {
900  RASTER_DEBUG(3, "all rasters are NULL, returning NULL");
901 
903 
904  return ES_NONE;
905  }
906  /* shortcut if all empty, return empty raster */
907  else if (allempty == itrcount) {
908  RASTER_DEBUG(3, "all rasters are empty, returning empty raster");
909 
911 
912  rtnrast = rt_raster_new(0, 0);
913  if (rtnrast == NULL) {
914  rterror("rt_raster_iterator: Could not create empty raster");
915  return ES_ERROR;
916  }
917  rt_raster_set_scale(rtnrast, 0, 0);
918 
919  *rtnraster = rtnrast;
920  return ES_NONE;
921  }
922 
923  /* check that all rasters are aligned */
924  RASTER_DEBUG(3, "checking alignment of all rasters");
925  rast = NULL;
926 
927  /* find raster to use as reference */
928  /* use custom if provided */
929  if (extenttype == ET_CUSTOM) {
930  RASTER_DEBUG(4, "using custom extent as reference raster");
931  rast = customextent;
932  }
933  /* use first valid one in _param->raster */
934  else {
935  for (i = 0; i < itrcount; i++) {
936  if (!_param->isempty[i]) {
937  RASTER_DEBUGF(4, "using raster at index %d as reference raster", i);
938  rast = _param->raster[i];
939  break;
940  }
941  }
942  }
943 
944  /* no rasters found, SHOULD NEVER BE HERE! */
945  if (rast == NULL) {
946  rterror("rt_raster_iterator: Could not find reference raster to use for alignment tests");
947 
949 
950  return ES_ERROR;
951  }
952 
953  do {
954  aligned = 1;
955 
956  /* check custom first if set. also skip if rasters are the same */
957  if (extenttype == ET_CUSTOM && rast != customextent) {
958  if (rt_raster_same_alignment(rast, customextent, &aligned, NULL) != ES_NONE) {
959  rterror("rt_raster_iterator: Could not test for alignment between reference raster and custom extent");
960 
962 
963  return ES_ERROR;
964  }
965 
966  RASTER_DEBUGF(5, "custom extent alignment: %d", aligned);
967  if (!aligned)
968  break;
969  }
970 
971  for (i = 0; i < itrcount; i++) {
972  /* skip NULL rasters and if rasters are the same */
973  if (_param->isempty[i] || rast == _param->raster[i])
974  continue;
975 
976  if (rt_raster_same_alignment(rast, _param->raster[i], &aligned, NULL) != ES_NONE) {
977  rterror("rt_raster_iterator: Could not test for alignment between reference raster and raster %d", i);
978 
980 
981  return ES_ERROR;
982  }
983  RASTER_DEBUGF(5, "raster at index %d alignment: %d", i, aligned);
984 
985  /* abort checking since a raster isn't aligned */
986  if (!aligned)
987  break;
988  }
989  }
990  while (0);
991 
992  /* not aligned, error */
993  if (!aligned) {
994  rterror("rt_raster_iterator: The set of rasters provided (custom extent included, if appropriate) do not have the same alignment");
995 
997 
998  return ES_ERROR;
999  }
1000 
1001  /* use extenttype to build output raster (no bands though) */
1002  i = -1;
1003  switch (extenttype) {
1004  case ET_INTERSECTION:
1005  case ET_UNION:
1006  /* make copy of first "real" raster */
1007  rtnrast = rtalloc(sizeof(struct rt_raster_t));
1008  if (rtnrast == NULL) {
1009  rterror("rt_raster_iterator: Could not allocate memory for output raster");
1010 
1011  _rti_iterator_arg_destroy(_param);
1012 
1013  return ES_ERROR;
1014  }
1015 
1016  for (i = 0; i < itrcount; i++) {
1017  if (!_param->isempty[i]) {
1018  memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_t));
1019  break;
1020  }
1021  }
1022  rtnrast->numBands = 0;
1023  rtnrast->bands = NULL;
1024 
1025  /* get extent of output raster */
1026  rast = NULL;
1027  for (i = i + 1; i < itrcount; i++) {
1028  if (_param->isempty[i])
1029  continue;
1030 
1031  status = rt_raster_from_two_rasters(rtnrast, _param->raster[i], extenttype, &rast, NULL);
1032  rtdealloc(rtnrast);
1033 
1034  if (rast == NULL || status != ES_NONE) {
1035  rterror("rt_raster_iterator: Could not compute %s extent of rasters",
1036  extenttype == ET_UNION ? "union" : "intersection"
1037  );
1038 
1039  _rti_iterator_arg_destroy(_param);
1040 
1041  return ES_ERROR;
1042  }
1043  else if (rt_raster_is_empty(rast)) {
1044  rtinfo("rt_raster_iterator: Computed raster for %s extent is empty",
1045  extenttype == ET_UNION ? "union" : "intersection"
1046  );
1047 
1048  _rti_iterator_arg_destroy(_param);
1049 
1050  *rtnraster = rast;
1051  return ES_NONE;
1052  }
1053 
1054  rtnrast = rast;
1055  rast = NULL;
1056  }
1057 
1058  break;
1059  /*
1060  first, second and last have similar checks
1061  and continue into custom
1062  */
1063  case ET_FIRST:
1064  i = 0;
1065  /* FALLTHROUGH */
1066  case ET_SECOND:
1067  if (i < 0) {
1068  if (itrcount < 2)
1069  i = 0;
1070  else
1071  i = 1;
1072  }
1073  /* FALLTHROUGH */
1074  case ET_LAST:
1075  if (i < 0) i = itrcount - 1;
1076 
1077  /* input raster is null, return NULL */
1078  if (_param->raster[i] == NULL) {
1079  RASTER_DEBUGF(3, "returning NULL as %s raster is NULL and extent type is ET_%s",
1080  (i == 0 ? "first" : (i == 1 ? "second" : "last")),
1081  (i == 0 ? "FIRST" : (i == 1 ? "SECOND" : "LAST"))
1082  );
1083 
1084  _rti_iterator_arg_destroy(_param);
1085 
1086  return ES_NONE;
1087  }
1088  /* input raster is empty, return empty raster */
1089  else if (_param->isempty[i]) {
1090  RASTER_DEBUGF(3, "returning empty raster as %s raster is empty and extent type is ET_%s",
1091  (i == 0 ? "first" : (i == 1 ? "second" : "last")),
1092  (i == 0 ? "FIRST" : (i == 1 ? "SECOND" : "LAST"))
1093  );
1094 
1095  _rti_iterator_arg_destroy(_param);
1096 
1097  rtnrast = rt_raster_new(0, 0);
1098  if (rtnrast == NULL) {
1099  rterror("rt_raster_iterator: Could not create empty raster");
1100  return ES_ERROR;
1101  }
1102  rt_raster_set_scale(rtnrast, 0, 0);
1103 
1104  *rtnraster = rtnrast;
1105  return ES_NONE;
1106  }
1107  /* FALLTHROUGH */
1108  /* copy the custom extent raster */
1109  case ET_CUSTOM:
1110  rtnrast = rtalloc(sizeof(struct rt_raster_t));
1111  if (rtnrast == NULL) {
1112  rterror("rt_raster_iterator: Could not allocate memory for output raster");
1113 
1114  _rti_iterator_arg_destroy(_param);
1115 
1116  return ES_ERROR;
1117  }
1118 
1119  switch (extenttype) {
1120  case ET_CUSTOM:
1121  memcpy(rtnrast, customextent, sizeof(struct rt_raster_t));
1122  break;
1123  /* first, second, last */
1124  default:
1125  memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_t));
1126  break;
1127  }
1128  rtnrast->numBands = 0;
1129  rtnrast->bands = NULL;
1130  break;
1131  }
1132 
1133  _width = rt_raster_get_width(rtnrast);
1134  _height = rt_raster_get_height(rtnrast);
1135 
1136  RASTER_DEBUGF(4, "rtnrast (width, height, ulx, uly, scalex, scaley, skewx, skewy, srid) = (%d, %d, %f, %f, %f, %f, %f, %f, %d)",
1137  _width,
1138  _height,
1139  rt_raster_get_x_offset(rtnrast),
1140  rt_raster_get_y_offset(rtnrast),
1141  rt_raster_get_x_scale(rtnrast),
1142  rt_raster_get_y_scale(rtnrast),
1143  rt_raster_get_x_skew(rtnrast),
1144  rt_raster_get_y_skew(rtnrast),
1145  rt_raster_get_srid(rtnrast)
1146  );
1147 
1148  /* init values and NODATA for use with empty rasters */
1149  if (!_rti_iterator_arg_empty_init(_param)) {
1150  rterror("rt_raster_iterator: Could not initialize empty values and NODATA");
1151 
1152  _rti_iterator_arg_destroy(_param);
1153  rt_raster_destroy(rtnrast);
1154 
1155  return ES_ERROR;
1156  }
1157 
1158  /* create output band */
1160  rtnrast,
1161  pixtype,
1162  nodataval,
1163  hasnodata, nodataval,
1164  0
1165  ) < 0) {
1166  rterror("rt_raster_iterator: Could not add new band to output raster");
1167 
1168  _rti_iterator_arg_destroy(_param);
1169  rt_raster_destroy(rtnrast);
1170 
1171  return ES_ERROR;
1172  }
1173 
1174  /* get output band */
1175  rtnband = rt_raster_get_band(rtnrast, 0);
1176  if (rtnband == NULL) {
1177  rterror("rt_raster_iterator: Could not get new band from output raster");
1178 
1179  _rti_iterator_arg_destroy(_param);
1180  rt_raster_destroy(rtnrast);
1181 
1182  return ES_ERROR;
1183  }
1184 
1185  /* output band's minimum value */
1186  minval = rt_band_get_min_value(rtnband);
1187 
1188  /* initialize argument for callback function */
1189  if (!_rti_iterator_arg_callback_init(_param)) {
1190  rterror("rt_raster_iterator: Could not initialize callback function argument");
1191 
1192  _rti_iterator_arg_destroy(_param);
1193  rt_band_destroy(rtnband);
1194  rt_raster_destroy(rtnrast);
1195 
1196  return ES_ERROR;
1197  }
1198 
1199  /* fill _param->offset */
1200  for (i = 0; i < itrcount; i++) {
1201  if (_param->isempty[i])
1202  continue;
1203 
1204  status = rt_raster_from_two_rasters(rtnrast, _param->raster[i], ET_FIRST, &rast, offset);
1205  rtdealloc(rast);
1206  if (status != ES_NONE) {
1207  rterror("rt_raster_iterator: Could not compute raster offsets");
1208 
1209  _rti_iterator_arg_destroy(_param);
1210  rt_band_destroy(rtnband);
1211  rt_raster_destroy(rtnrast);
1212 
1213  return ES_ERROR;
1214  }
1215 
1216  _param->offset[i][0] = offset[2];
1217  _param->offset[i][1] = offset[3];
1218  RASTER_DEBUGF(4, "rast %d offset: %f %f", i, offset[2], offset[3]);
1219  }
1220 
1221  /* loop over each pixel (POI) of output raster */
1222  /* _x,_y are for output raster */
1223  /* x,y are for input raster */
1224  for (_y = 0; _y < _height; _y++) {
1225  for (_x = 0; _x < _width; _x++) {
1226  RASTER_DEBUGF(4, "iterating output pixel (x, y) = (%d, %d)", _x, _y);
1227  _param->arg->dst_pixel[0] = _x;
1228  _param->arg->dst_pixel[1] = _y;
1229 
1230  /* loop through each input raster */
1231  for (i = 0; i < itrcount; i++) {
1232  RASTER_DEBUGF(4, "raster %d", i);
1233 
1234  /*
1235  empty raster
1236  OR band does not exist and flag set to use NODATA
1237  OR band is NODATA
1238  */
1239  if (
1240  _param->isempty[i] ||
1241  (_param->band.rtband[i] == NULL && itrset[i].nbnodata) ||
1242  _param->band.isnodata[i]
1243  ) {
1244  RASTER_DEBUG(4, "empty raster, band does not exist or band is NODATA. using empty values and NODATA");
1245 
1246  x = _x;
1247  y = _y;
1248 
1249  _param->arg->values[i] = _param->empty.values;
1250  _param->arg->nodata[i] = _param->empty.nodata;
1251 
1252  continue;
1253  }
1254 
1255  /* input raster's X,Y */
1256  x = _x - (int) _param->offset[i][0];
1257  y = _y - (int) _param->offset[i][1];
1258  RASTER_DEBUGF(4, "source pixel (x, y) = (%d, %d)", x, y);
1259 
1260  _param->arg->src_pixel[i][0] = x;
1261  _param->arg->src_pixel[i][1] = y;
1262 
1263  /* neighborhood */
1264  npixels = NULL;
1265  status = 0;
1266  if (distancex > 0 && distancey > 0) {
1267  RASTER_DEBUG(4, "getting neighborhood");
1268 
1269  status = rt_band_get_nearest_pixel(
1270  _param->band.rtband[i],
1271  x, y,
1272  distancex, distancey,
1273  1,
1274  &npixels
1275  );
1276  if (status < 0) {
1277  rterror("rt_raster_iterator: Could not get pixel neighborhood");
1278 
1279  _rti_iterator_arg_destroy(_param);
1280  rt_band_destroy(rtnband);
1281  rt_raster_destroy(rtnrast);
1282 
1283  return ES_ERROR;
1284  }
1285  }
1286 
1287  /* get value of POI */
1288  /* get pixel's value */
1289  if (
1290  (x >= 0 && x < _param->width[i]) &&
1291  (y >= 0 && y < _param->height[i])
1292  ) {
1293  RASTER_DEBUG(4, "getting value of POI");
1294  if (rt_band_get_pixel(
1295  _param->band.rtband[i],
1296  x, y,
1297  &value,
1298  &isnodata
1299  ) != ES_NONE) {
1300  rterror("rt_raster_iterator: Could not get the pixel value of band");
1301 
1302  _rti_iterator_arg_destroy(_param);
1303  rt_band_destroy(rtnband);
1304  rt_raster_destroy(rtnrast);
1305 
1306  return ES_ERROR;
1307  }
1308  inextent = 1;
1309  }
1310  /* outside band extent, set to NODATA */
1311  else {
1312  RASTER_DEBUG(4, "Outside band extent, setting value to NODATA");
1313  /* has NODATA, use NODATA */
1314  if (_param->band.hasnodata[i])
1315  value = _param->band.nodataval[i];
1316  /* no NODATA, use min possible value */
1317  else
1318  value = _param->band.minval[i];
1319 
1320  inextent = 0;
1321  isnodata = 1;
1322  }
1323 
1324  /* add pixel to neighborhood */
1325  status++;
1326  if (status > 1)
1327  npixels = (rt_pixel) rtrealloc(npixels, sizeof(struct rt_pixel_t) * status);
1328  else
1329  npixels = (rt_pixel) rtalloc(sizeof(struct rt_pixel_t));
1330 
1331  if (npixels == NULL) {
1332  rterror("rt_raster_iterator: Could not reallocate memory for neighborhood");
1333 
1334  _rti_iterator_arg_destroy(_param);
1335  rt_band_destroy(rtnband);
1336  rt_raster_destroy(rtnrast);
1337 
1338  return ES_ERROR;
1339  }
1340 
1341  npixels[status - 1].x = x;
1342  npixels[status - 1].y = y;
1343  npixels[status - 1].nodata = 1;
1344  npixels[status - 1].value = value;
1345 
1346  /* set nodata flag */
1347  if ((!_param->band.hasnodata[i] && inextent) || !isnodata) {
1348  npixels[status - 1].nodata = 0;
1349  }
1350  RASTER_DEBUGF(4, "value, nodata: %f, %d", value, npixels[status - 1].nodata);
1351 
1352  /* convert set of rt_pixel to 2D array */
1353  status = rt_pixel_set_to_array(
1354  npixels, status, mask,
1355  x, y,
1356  distancex, distancey,
1357  &(_param->arg->values[i]),
1358  &(_param->arg->nodata[i]),
1359  NULL, NULL
1360  );
1361  rtdealloc(npixels);
1362  if (status != ES_NONE) {
1363  rterror("rt_raster_iterator: Could not create 2D array of neighborhood");
1364 
1365  _rti_iterator_arg_destroy(_param);
1366  rt_band_destroy(rtnband);
1367  rt_raster_destroy(rtnrast);
1368 
1369  return ES_ERROR;
1370  }
1371  }
1372 
1373  /* callback */
1374  RASTER_DEBUG(4, "calling callback function");
1375  value = 0;
1376  nodata = 0;
1377  status = callback(_param->arg, userarg, &value, &nodata);
1378 
1379  /* free memory from callback */
1381 
1382  /* handle callback status */
1383  if (status == 0) {
1384  rterror("rt_raster_iterator: Callback function returned an error");
1385 
1386  _rti_iterator_arg_destroy(_param);
1387  rt_band_destroy(rtnband);
1388  rt_raster_destroy(rtnrast);
1389 
1390  return ES_ERROR;
1391  }
1392 
1393  /* burn value to pixel */
1394  status = 0;
1395  if (!nodata) {
1396  status = rt_band_set_pixel(rtnband, _x, _y, value, NULL);
1397  RASTER_DEBUGF(4, "burning pixel (%d, %d) with value: %f", _x, _y, value);
1398  }
1399  else if (!hasnodata) {
1400  status = rt_band_set_pixel(rtnband, _x, _y, minval, NULL);
1401  RASTER_DEBUGF(4, "burning pixel (%d, %d) with minval: %f", _x, _y, minval);
1402  }
1403  else {
1404  RASTER_DEBUGF(4, "NOT burning pixel (%d, %d)", _x, _y);
1405  }
1406  if (status != ES_NONE) {
1407  rterror("rt_raster_iterator: Could not set pixel value");
1408 
1409  _rti_iterator_arg_destroy(_param);
1410  rt_band_destroy(rtnband);
1411  rt_raster_destroy(rtnrast);
1412 
1413  return ES_ERROR;
1414  }
1415  }
1416  }
1417 
1418  /* lots of cleanup */
1419  _rti_iterator_arg_destroy(_param);
1420 
1421  *rtnraster = rtnrast;
1422  return ES_NONE;
1423 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
#define RASTER_DEBUG(level, msg)
Definition: librtcore.h:295
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
#define RASTER_DEBUGF(level, msg,...)
Definition: librtcore.h:299
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
Definition: rt_raster.c:181
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:213
int rt_raster_generate_new_band(rt_raster raster, rt_pixtype pixtype, double initialvalue, uint32_t hasnodata, double nodatavalue, int index)
Generate a new inline band and add it to a raster.
Definition: rt_raster.c:485
void rtinfo(const char *fmt,...)
Definition: rt_context.c:211
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:137
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1221
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
@ PT_END
Definition: librtcore.h:197
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
struct rt_pixel_t * rt_pixel
Definition: librtcore.h:147
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:150
double rt_band_get_min_value(rt_band band)
Returns the minimal possible value for the band according to the pixel type.
Definition: rt_band.c:1745
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
Definition: rt_band.c:974
@ ES_NONE
Definition: librtcore.h:180
@ ES_ERROR
Definition: librtcore.h:181
void rt_band_destroy(rt_band band)
Destroy a raster band.
Definition: rt_band.c:340
void * rtrealloc(void *mem, size_t size)
Definition: rt_context.c:179
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
@ ET_CUSTOM
Definition: librtcore.h:206
@ ET_LAST
Definition: librtcore.h:205
@ ET_INTERSECTION
Definition: librtcore.h:201
@ ET_UNION
Definition: librtcore.h:202
@ ET_SECOND
Definition: librtcore.h:204
@ ET_FIRST
Definition: librtcore.h:203
rt_errorstate rt_pixel_set_to_array(rt_pixel npixel, uint32_t count, rt_mask mask, int x, int y, uint16_t distancex, uint16_t distancey, double ***value, int ***nodata, int *dimx, int *dimy)
Definition: rt_pixel.c:286
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
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.
Definition: rt_band.c:1374
void rtdealloc(void *mem)
Definition: rt_context.c:186
rt_errorstate rt_raster_from_two_rasters(rt_raster rast1, rt_raster rast2, rt_extenttype extenttype, rt_raster *rtnraster, double *offset)
Definition: rt_raster.c:3361
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_raster.c:159
rt_errorstate rt_raster_same_alignment(rt_raster rast1, rt_raster rast2, int *aligned, char **reason)
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:190
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:222
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_raster.c:1334
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
int value
Definition: genraster.py:61
static int _rti_iterator_arg_callback_init(_rti_iterator_arg _param)
static int _rti_iterator_arg_empty_init(_rti_iterator_arg _param)
static _rti_iterator_arg _rti_iterator_arg_init()
static int _rti_iterator_arg_populate(_rti_iterator_arg _param, rt_iterator itrset, uint16_t itrcount, uint16_t distancex, uint16_t distancey, int *allnull, int *allempty)
static void _rti_iterator_arg_callback_clean(_rti_iterator_arg _param)
static void _rti_iterator_arg_destroy(_rti_iterator_arg _param)
struct _rti_iterator_arg_t::@10 band
struct _rti_iterator_arg_t::@13 empty
rt_iterator_arg arg
double *** values
Definition: librtcore.h:2459
double value
Definition: librtcore.h:2338
uint8_t nodata
Definition: librtcore.h:2337
rt_band * bands
Definition: librtcore.h:2303
uint16_t numBands
Definition: librtcore.h:2290

References _rti_iterator_arg_callback_clean(), _rti_iterator_arg_callback_init(), _rti_iterator_arg_destroy(), _rti_iterator_arg_empty_init(), _rti_iterator_arg_init(), _rti_iterator_arg_populate(), _rti_iterator_arg_t::arg, _rti_iterator_arg_t::band, rt_raster_t::bands, rt_iterator_arg_t::dst_pixel, _rti_iterator_arg_t::empty, ES_ERROR, ES_NONE, ET_CUSTOM, ET_FIRST, ET_INTERSECTION, ET_LAST, ET_SECOND, ET_UNION, _rti_iterator_arg_t::hasnodata, _rti_iterator_arg_t::isempty, _rti_iterator_arg_t::isnodata, _rti_iterator_arg_t::minval, rt_iterator_t::nbnodata, rt_pixel_t::nodata, rt_iterator_arg_t::nodata, _rti_iterator_arg_t::nodata, _rti_iterator_arg_t::nodataval, rt_raster_t::numBands, _rti_iterator_arg_t::offset, PT_END, rtpixdump::rast, _rti_iterator_arg_t::raster, RASTER_DEBUG, RASTER_DEBUGF, rt_band_destroy(), rt_band_get_min_value(), rt_band_get_nearest_pixel(), rt_band_get_pixel(), rt_band_set_pixel(), rt_pixel_set_to_array(), rt_raster_destroy(), rt_raster_from_two_rasters(), rt_raster_generate_new_band(), rt_raster_get_band(), rt_raster_get_height(), rt_raster_get_srid(), rt_raster_get_width(), rt_raster_get_x_offset(), rt_raster_get_x_scale(), rt_raster_get_x_skew(), rt_raster_get_y_offset(), rt_raster_get_y_scale(), rt_raster_get_y_skew(), rt_raster_is_empty(), rt_raster_new(), rt_raster_same_alignment(), rt_raster_set_scale(), rtalloc(), _rti_iterator_arg_t::rtband, rtdealloc(), rterror(), rtinfo(), rtrealloc(), rt_iterator_arg_t::src_pixel, rt_pixel_t::value, genraster::value, rt_iterator_arg_t::values, _rti_iterator_arg_t::values, rt_pixel_t::x, pixval::x, rt_pixel_t::y, and pixval::y.

Referenced by RASTER_clip(), RASTER_nMapAlgebra(), RASTER_nMapAlgebraExpr(), RASTER_setPixelValuesGeomval(), RASTER_union_finalfn(), RASTER_union_transfn(), and test_raster_iterator().

Here is the call graph for this function:
Here is the caller graph for this function: