PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ RASTER_mapAlgebraFctNgb()

Datum RASTER_mapAlgebraFctNgb ( PG_FUNCTION_ARGS  )

Create a new empty raster with having the same georeference as the provided raster

If this new raster is empty (width = 0 OR height = 0) then there is nothing to compute and we return it right now

Check if the raster has the required band. Otherwise, return a raster without band

We set the initial value of the future band to nodata value. If nodata value is null, then the raster will be initialized to rt_band_get_min_value but all the values should be recomputed anyway

Set the new pixeltype

Optimization: If the raster is only filled with nodata values return right now a raster filled with the nodatavalueexpr TODO: Call rt_band_check_isnodata instead?

Create the raster receiving all the computed values. Initialize it to the new initial value

We compute a value only for the withdata value neighborhood since the nodata value has already been set by the first optimization

Definition at line 5591 of file rtpg_mapalgebra.c.

5592 {
5593  rt_pgraster *pgraster = NULL;
5594  rt_pgraster *pgrtn = NULL;
5595  rt_raster raster = NULL;
5596  rt_raster newrast = NULL;
5597  rt_band band = NULL;
5598  rt_band newband = NULL;
5599  int x, y, nband, width, height, ngbwidth, ngbheight, winwidth, winheight, u, v, nIndex, nNullItems;
5600  double r, rpix;
5601  double newnodatavalue = 0.0;
5602  double newinitialvalue = 0.0;
5603  double newval = 0.0;
5604  rt_pixtype newpixeltype;
5605  int ret = -1;
5606  Oid oid;
5607  FmgrInfo cbinfo;
5608 #if POSTGIS_PGSQL_VERSION < 120
5609  FunctionCallInfoData cbdata;
5610 #else
5611  LOCAL_FCINFO(cbdata, FUNC_MAX_ARGS); /* Could be optimized */
5612 #endif
5613  Datum tmpnewval;
5614  ArrayType * neighborDatum;
5615  char * strFromText = NULL;
5616  text * txtNodataMode = NULL;
5617  text * txtCallbackParam = NULL;
5618  int intReplace = 0;
5619  float fltReplace = 0;
5620  bool valuereplace = false, pixelreplace, nNodataOnly = true, nNullSkip = false;
5621  Datum * neighborData = NULL;
5622  bool * neighborNulls = NULL;
5623  int neighborDims[2];
5624  int neighborLbs[2];
5625  int16 typlen;
5626  bool typbyval;
5627  char typalign;
5628 
5629  POSTGIS_RT_DEBUG(2, "RASTER_mapAlgebraFctNgb: STARTING...");
5630 
5631  /* Check raster */
5632  if (PG_ARGISNULL(0)) {
5633  elog(WARNING, "Raster is NULL. Returning NULL");
5634  PG_RETURN_NULL();
5635  }
5636 
5637 
5638  /* Deserialize raster */
5639  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
5640  raster = rt_raster_deserialize(pgraster, FALSE);
5641  if (NULL == raster)
5642  {
5643  PG_FREE_IF_COPY(pgraster, 0);
5644  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not deserialize raster");
5645  PG_RETURN_NULL();
5646  }
5647 
5648  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting arguments...");
5649 
5650  /* Get the rest of the arguments */
5651 
5652  if (PG_ARGISNULL(1))
5653  nband = 1;
5654  else
5655  nband = PG_GETARG_INT32(1);
5656 
5657  if (nband < 1)
5658  nband = 1;
5659 
5660  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Creating new empty raster...");
5661 
5666  width = rt_raster_get_width(raster);
5667  height = rt_raster_get_height(raster);
5668 
5669  newrast = rt_raster_new(width, height);
5670 
5671  if ( NULL == newrast ) {
5673  PG_FREE_IF_COPY(pgraster, 0);
5674  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not create a new raster");
5675  PG_RETURN_NULL();
5676  }
5677 
5678  rt_raster_set_scale(newrast,
5681 
5682  rt_raster_set_offsets(newrast,
5685 
5686  rt_raster_set_skews(newrast,
5689 
5691 
5692 
5697  if (rt_raster_is_empty(newrast))
5698  {
5699  elog(NOTICE, "Raster is empty. Returning an empty raster");
5701  PG_FREE_IF_COPY(pgraster, 0);
5702 
5703  pgrtn = rt_raster_serialize(newrast);
5704  rt_raster_destroy(newrast);
5705  if (NULL == pgrtn) {
5706  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5707  PG_RETURN_NULL();
5708  }
5709 
5710  SET_VARSIZE(pgrtn, pgrtn->size);
5711  PG_RETURN_POINTER(pgrtn);
5712  }
5713 
5714  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Getting raster band %d...", nband);
5715 
5720  if (!rt_raster_has_band(raster, nband - 1)) {
5721  elog(NOTICE, "Raster does not have the required band. Returning a raster "
5722  "without a band");
5724  PG_FREE_IF_COPY(pgraster, 0);
5725 
5726  pgrtn = rt_raster_serialize(newrast);
5727  rt_raster_destroy(newrast);
5728  if (NULL == pgrtn) {
5729  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5730  PG_RETURN_NULL();
5731  }
5732 
5733  SET_VARSIZE(pgrtn, pgrtn->size);
5734  PG_RETURN_POINTER(pgrtn);
5735  }
5736 
5737  /* Get the raster band */
5739  if ( NULL == band ) {
5740  elog(NOTICE, "Could not get the required band. Returning a raster "
5741  "without a band");
5743  PG_FREE_IF_COPY(pgraster, 0);
5744 
5745  pgrtn = rt_raster_serialize(newrast);
5746  rt_raster_destroy(newrast);
5747  if (NULL == pgrtn) {
5748  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5749  PG_RETURN_NULL();
5750  }
5751 
5752  SET_VARSIZE(pgrtn, pgrtn->size);
5753  PG_RETURN_POINTER(pgrtn);
5754  }
5755 
5756  /*
5757  * Get NODATA value
5758  */
5759  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting NODATA value for band...");
5760 
5762  rt_band_get_nodata(band, &newnodatavalue);
5763  }
5764 
5765  else {
5766  newnodatavalue = rt_band_get_min_value(band);
5767  }
5768 
5769  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: NODATA value for band: %f",
5770  newnodatavalue);
5776  newinitialvalue = newnodatavalue;
5777 
5781  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Setting pixeltype...");
5782 
5783  if (PG_ARGISNULL(2)) {
5784  newpixeltype = rt_band_get_pixtype(band);
5785  }
5786 
5787  else {
5788  strFromText = text_to_cstring(PG_GETARG_TEXT_P(2));
5789  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype parameter: %s", strFromText);
5790  newpixeltype = rt_pixtype_index_from_name(strFromText);
5791  pfree(strFromText);
5792  if (newpixeltype == PT_END)
5793  newpixeltype = rt_band_get_pixtype(band);
5794  }
5795 
5796  if (newpixeltype == PT_END) {
5797 
5799  PG_FREE_IF_COPY(pgraster, 0);
5800  rt_raster_destroy(newrast);
5801 
5802  elog(ERROR, "RASTER_mapAlgebraFctNgb: Invalid pixeltype");
5803  PG_RETURN_NULL();
5804  }
5805 
5806  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype set to %s (%d)",
5807  rt_pixtype_name(newpixeltype), newpixeltype);
5808 
5809  /* Get the name of the callback userfunction */
5810  if (PG_ARGISNULL(5)) {
5811 
5813  PG_FREE_IF_COPY(pgraster, 0);
5814  rt_raster_destroy(newrast);
5815 
5816  elog(ERROR, "RASTER_mapAlgebraFctNgb: Required function is missing");
5817  PG_RETURN_NULL();
5818  }
5819 
5820  oid = PG_GETARG_OID(5);
5821  if (oid == InvalidOid) {
5822 
5824  PG_FREE_IF_COPY(pgraster, 0);
5825  rt_raster_destroy(newrast);
5826 
5827  elog(ERROR, "RASTER_mapAlgebraFctNgb: Got invalid function object id");
5828  PG_RETURN_NULL();
5829  }
5830 
5831  fmgr_info(oid, &cbinfo);
5832 
5833  /* function cannot return set */
5834  if (cbinfo.fn_retset) {
5835 
5837  PG_FREE_IF_COPY(pgraster, 0);
5838  rt_raster_destroy(newrast);
5839 
5840  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function provided must return double precision not resultset");
5841  PG_RETURN_NULL();
5842  }
5843  /* function should have correct # of args */
5844  else if (cbinfo.fn_nargs != 3) {
5845 
5847  PG_FREE_IF_COPY(pgraster, 0);
5848  rt_raster_destroy(newrast);
5849 
5850  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function does not have three input parameters");
5851  PG_RETURN_NULL();
5852  }
5853 
5854  if (func_volatile(oid) == 'v') {
5855  elog(NOTICE, "Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
5856  }
5857 
5858  /* prep function call data */
5859 #if POSTGIS_PGSQL_VERSION < 120
5860  InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
5861  memset(cbdata.argnull, FALSE, sizeof(bool) * 3);
5862 #else
5863  InitFunctionCallInfoData(*cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
5864  cbdata->args[0].isnull = FALSE;
5865  cbdata->args[1].isnull = FALSE;
5866  cbdata->args[2].isnull = FALSE;
5867 #endif
5868 
5869  /* check that the function isn't strict if the args are null. */
5870  if (PG_ARGISNULL(7)) {
5871  if (cbinfo.fn_strict) {
5872 
5874  PG_FREE_IF_COPY(pgraster, 0);
5875  rt_raster_destroy(newrast);
5876 
5877  elog(ERROR, "RASTER_mapAlgebraFctNgb: Strict callback functions cannot have NULL parameters");
5878  PG_RETURN_NULL();
5879  }
5880 
5881 #if POSTGIS_PGSQL_VERSION < 120
5882  cbdata.arg[2] = (Datum)NULL;
5883  cbdata.argnull[2] = TRUE;
5884 #else
5885  cbdata->args[2].value = (Datum)NULL;
5886  cbdata->args[2].isnull = TRUE;
5887 #endif
5888  }
5889  else {
5890 #if POSTGIS_PGSQL_VERSION < 120
5891  cbdata.arg[2] = PG_GETARG_DATUM(7);
5892 #else
5893  cbdata->args[2].value = PG_GETARG_DATUM(7);
5894 #endif
5895  }
5896 
5903 
5904  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Band is a nodata band, returning "
5905  "a raster filled with nodata");
5906 
5907  rt_raster_generate_new_band(newrast, newpixeltype,
5908  newinitialvalue, TRUE, newnodatavalue, 0);
5909 
5911  PG_FREE_IF_COPY(pgraster, 0);
5912 
5913  /* Serialize created raster */
5914  pgrtn = rt_raster_serialize(newrast);
5915  rt_raster_destroy(newrast);
5916  if (NULL == pgrtn) {
5917  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5918  PG_RETURN_NULL();
5919  }
5920 
5921  SET_VARSIZE(pgrtn, pgrtn->size);
5922  PG_RETURN_POINTER(pgrtn);
5923  }
5924 
5925 
5930  rt_raster_generate_new_band(newrast, newpixeltype,
5931  newinitialvalue, TRUE, newnodatavalue, 0);
5932 
5933  /* Get the new raster band */
5934  newband = rt_raster_get_band(newrast, 0);
5935  if ( NULL == newband ) {
5936  elog(NOTICE, "Could not modify band for new raster. Returning new "
5937  "raster with the original band");
5938 
5940  PG_FREE_IF_COPY(pgraster, 0);
5941 
5942  /* Serialize created raster */
5943  pgrtn = rt_raster_serialize(newrast);
5944  rt_raster_destroy(newrast);
5945  if (NULL == pgrtn) {
5946  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5947  PG_RETURN_NULL();
5948  }
5949 
5950  SET_VARSIZE(pgrtn, pgrtn->size);
5951  PG_RETURN_POINTER(pgrtn);
5952  }
5953 
5954  /* Get the width of the neighborhood */
5955  if (PG_ARGISNULL(3) || PG_GETARG_INT32(3) <= 0) {
5956  elog(NOTICE, "Neighborhood width is NULL or <= 0. Returning new "
5957  "raster with the original band");
5958 
5960  PG_FREE_IF_COPY(pgraster, 0);
5961 
5962  /* Serialize created raster */
5963  pgrtn = rt_raster_serialize(newrast);
5964  rt_raster_destroy(newrast);
5965  if (NULL == pgrtn) {
5966  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5967  PG_RETURN_NULL();
5968  }
5969 
5970  SET_VARSIZE(pgrtn, pgrtn->size);
5971  PG_RETURN_POINTER(pgrtn);
5972  }
5973 
5974  ngbwidth = PG_GETARG_INT32(3);
5975  winwidth = ngbwidth * 2 + 1;
5976 
5977  /* Get the height of the neighborhood */
5978  if (PG_ARGISNULL(4) || PG_GETARG_INT32(4) <= 0) {
5979  elog(NOTICE, "Neighborhood height is NULL or <= 0. Returning new "
5980  "raster with the original band");
5981 
5983  PG_FREE_IF_COPY(pgraster, 0);
5984 
5985  /* Serialize created raster */
5986  pgrtn = rt_raster_serialize(newrast);
5987  rt_raster_destroy(newrast);
5988  if (NULL == pgrtn) {
5989  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5990  PG_RETURN_NULL();
5991  }
5992 
5993  SET_VARSIZE(pgrtn, pgrtn->size);
5994  PG_RETURN_POINTER(pgrtn);
5995  }
5996 
5997  ngbheight = PG_GETARG_INT32(4);
5998  winheight = ngbheight * 2 + 1;
5999 
6000  /* Get the type of NODATA behavior for the neighborhoods. */
6001  if (PG_ARGISNULL(6)) {
6002  elog(NOTICE, "Neighborhood NODATA behavior defaulting to 'ignore'");
6003  txtNodataMode = cstring_to_text("ignore");
6004  }
6005  else {
6006  txtNodataMode = PG_GETARG_TEXT_P(6);
6007  }
6008 
6009  txtCallbackParam = (text*)palloc(VARSIZE(txtNodataMode));
6010  SET_VARSIZE(txtCallbackParam, VARSIZE(txtNodataMode));
6011  memcpy((void *)VARDATA(txtCallbackParam), (void *)VARDATA(txtNodataMode), VARSIZE(txtNodataMode) - VARHDRSZ);
6012 
6013  /* pass the nodata mode into the user function */
6014 #if POSTGIS_PGSQL_VERSION < 120
6015  cbdata.arg[1] = PointerGetDatum(txtCallbackParam);
6016 #else
6017  cbdata->args[1].value = PointerGetDatum(txtCallbackParam);
6018 #endif
6019 
6020  strFromText = text_to_cstring(txtNodataMode);
6021  strFromText = rtpg_strtoupper(strFromText);
6022 
6023  if (strcmp(strFromText, "VALUE") == 0)
6024  valuereplace = true;
6025  else if (strcmp(strFromText, "IGNORE") != 0 && strcmp(strFromText, "NULL") != 0) {
6026  /* if the text is not "IGNORE" or "NULL", it may be a numerical value */
6027  if (sscanf(strFromText, "%d", &intReplace) <= 0 && sscanf(strFromText, "%f", &fltReplace) <= 0) {
6028  /* the value is NOT an integer NOR a floating point */
6029  elog(NOTICE, "Neighborhood NODATA mode is not recognized. Must be one of 'value', 'ignore', "
6030  "'NULL', or a numeric value. Returning new raster with the original band");
6031 
6032  /* clean up the nodatamode string */
6033  pfree(txtCallbackParam);
6034  pfree(strFromText);
6035 
6037  PG_FREE_IF_COPY(pgraster, 0);
6038 
6039  /* Serialize created raster */
6040  pgrtn = rt_raster_serialize(newrast);
6041  rt_raster_destroy(newrast);
6042  if (NULL == pgrtn) {
6043  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
6044  PG_RETURN_NULL();
6045  }
6046 
6047  SET_VARSIZE(pgrtn, pgrtn->size);
6048  PG_RETURN_POINTER(pgrtn);
6049  }
6050  }
6051  else if (strcmp(strFromText, "NULL") == 0) {
6052  /* this setting means that the neighborhood should be skipped if any of the values are null */
6053  nNullSkip = true;
6054  }
6055 
6056  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Main computing loop (%d x %d)",
6057  width, height);
6058 
6059  /* Allocate room for the neighborhood. */
6060  neighborData = (Datum *)palloc(winwidth * winheight * sizeof(Datum));
6061  neighborNulls = (bool *)palloc(winwidth * winheight * sizeof(bool));
6062 
6063  /* The dimensions of the neighborhood array, for creating a multi-dimensional array. */
6064  neighborDims[0] = winwidth;
6065  neighborDims[1] = winheight;
6066 
6067  /* The lower bounds for the new multi-dimensional array. */
6068  neighborLbs[0] = 1;
6069  neighborLbs[1] = 1;
6070 
6071  /* Get information about the type of item in the multi-dimensional array (float8). */
6072  get_typlenbyvalalign(FLOAT8OID, &typlen, &typbyval, &typalign);
6073 
6074  for (x = 0 + ngbwidth; x < width - ngbwidth; x++) {
6075  for(y = 0 + ngbheight; y < height - ngbheight; y++) {
6076  /* populate an array with the pixel values in the neighborhood */
6077  nIndex = 0;
6078  nNullItems = 0;
6079  nNodataOnly = true;
6080  pixelreplace = false;
6081  if (valuereplace) {
6082  ret = rt_band_get_pixel(band, x, y, &rpix, NULL);
6083  if (ret == ES_NONE && FLT_NEQ(rpix, newnodatavalue)) {
6084  pixelreplace = true;
6085  }
6086  }
6087  for (u = x - ngbwidth; u <= x + ngbwidth; u++) {
6088  for (v = y - ngbheight; v <= y + ngbheight; v++) {
6089  ret = rt_band_get_pixel(band, u, v, &r, NULL);
6090  if (ret == ES_NONE) {
6091  if (FLT_NEQ(r, newnodatavalue)) {
6092  /* If the pixel value for this neighbor cell is not NODATA */
6093  neighborData[nIndex] = Float8GetDatum((double)r);
6094  neighborNulls[nIndex] = false;
6095  nNodataOnly = false;
6096  }
6097  else {
6098  /* If the pixel value for this neighbor cell is NODATA */
6099  if (valuereplace && pixelreplace) {
6100  /* Replace the NODATA value with the currently processing pixel. */
6101  neighborData[nIndex] = Float8GetDatum((double)rpix);
6102  neighborNulls[nIndex] = false;
6103  /* do not increment nNullItems, since the user requested that the */
6104  /* neighborhood replace NODATA values with the central pixel value */
6105  }
6106  else {
6107  neighborData[nIndex] = PointerGetDatum(NULL);
6108  neighborNulls[nIndex] = true;
6109  nNullItems++;
6110  }
6111  }
6112  }
6113  else {
6114  /* Fill this will NULL if we can't read the raster pixel. */
6115  neighborData[nIndex] = PointerGetDatum(NULL);
6116  neighborNulls[nIndex] = true;
6117  nNullItems++;
6118  }
6119  /* Next neighbor position */
6120  nIndex++;
6121  }
6122  }
6123 
6128  if (!(nNodataOnly || /* neighborhood only contains NODATA -- OR -- */
6129  (nNullSkip && nNullItems > 0) || /* neighborhood should skip any NODATA cells, and a NODATA cell was detected -- OR -- */
6130  (valuereplace && nNullItems > 0))) { /* neighborhood should replace NODATA cells with the central pixel value, and a NODATA cell was detected */
6131  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: (%dx%d), %dx%d neighborhood",
6132  x, y, winwidth, winheight);
6133 
6134  neighborDatum = construct_md_array((void *)neighborData, neighborNulls, 2, neighborDims, neighborLbs,
6135  FLOAT8OID, typlen, typbyval, typalign);
6136 
6137 #if POSTGIS_PGSQL_VERSION < 120
6138  /* Assign the neighbor matrix as the first argument to the user function */
6139  cbdata.arg[0] = PointerGetDatum(neighborDatum);
6140 
6141  /* Invoke the user function */
6142  tmpnewval = FunctionCallInvoke(&cbdata);
6143 
6144  /* Get the return value of the user function */
6145  if (cbdata.isnull) {
6146  newval = newnodatavalue;
6147  }
6148 #else
6149  /* Assign the neighbor matrix as the first argument to the user function */
6150  cbdata->args[0].value = PointerGetDatum(neighborDatum);
6151 
6152  /* Invoke the user function */
6153  tmpnewval = FunctionCallInvoke(cbdata);
6154 
6155  /* Get the return value of the user function */
6156  if (cbdata->isnull)
6157  {
6158  newval = newnodatavalue;
6159  }
6160 #endif
6161  else {
6162  newval = DatumGetFloat8(tmpnewval);
6163  }
6164 
6165  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: new value = %f",
6166  newval);
6167 
6168  rt_band_set_pixel(newband, x, y, newval, NULL);
6169  }
6170 
6171  /* reset the number of null items in the neighborhood */
6172  nNullItems = 0;
6173  }
6174  }
6175 
6176 
6177  /* clean up */
6178  pfree(neighborNulls);
6179  pfree(neighborData);
6180  pfree(strFromText);
6181  pfree(txtCallbackParam);
6182 
6184  PG_FREE_IF_COPY(pgraster, 0);
6185 
6186  /* The newrast band has been modified */
6187 
6188  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster modified, serializing it.");
6189  /* Serialize created raster */
6190 
6191  pgrtn = rt_raster_serialize(newrast);
6192  rt_raster_destroy(newrast);
6193  if (NULL == pgrtn)
6194  PG_RETURN_NULL();
6195 
6196  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster serialized");
6197  POSTGIS_RT_DEBUG(4, "RASTER_mapAlgebraFctNgb: returning raster");
6198 
6199  SET_VARSIZE(pgrtn, pgrtn->size);
6200  PG_RETURN_POINTER(pgrtn);
6201 }
char * r
Definition: cu_in_wkt.c:24
#define TRUE
Definition: dbfopen.c:73
#define FALSE
Definition: dbfopen.c:72
#define FLT_NEQ(x, y)
Definition: librtcore.h:2379
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:360
double rt_raster_get_x_skew(rt_raster raster)
Get skew about the X axis.
Definition: rt_raster.c:185
double rt_raster_get_x_offset(rt_raster raster)
Get raster x offset, in projection units.
Definition: rt_raster.c:217
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:489
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:141
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
Definition: rt_band.c:674
rt_pixtype rt_pixtype_index_from_name(const char *pixname)
Definition: rt_pixel.c:80
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
Definition: rt_band.c:1376
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:86
rt_pixtype
Definition: librtcore.h:187
@ PT_END
Definition: librtcore.h:199
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
Definition: rt_raster.c:172
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
Definition: rt_band.c:714
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:52
int rt_raster_has_band(rt_raster raster, int nband)
Return TRUE if the raster has a band of this number.
Definition: rt_raster.c:1375
void * rt_raster_serialize(rt_raster raster)
Return this raster in serialized form.
Definition: rt_serialize.c:521
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
Definition: rt_raster.c:154
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:1902
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:182
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:133
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_raster.c:367
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1887
rt_pixtype rt_band_get_pixtype(rt_band band)
Return pixeltype of this band.
Definition: rt_band.c:631
const char * rt_pixtype_name(rt_pixtype pixtype)
Definition: rt_pixel.c:110
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:125
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_raster.c:163
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:194
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:203
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
Definition: rt_serialize.c:725
double rt_raster_get_y_offset(rt_raster raster)
Get raster y offset, in projection units.
Definition: rt_raster.c:226
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_raster.c:1362
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:385
band
Definition: ovdump.py:58
nband
Definition: pixval.py:53
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
Definition: rtrowdump.py:121
char * rtpg_strtoupper(char *str)
#define POSTGIS_RT_DEBUG(level, msg)
Definition: rtpostgis.h:69
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:73
Struct definitions.
Definition: librtcore.h:2396

References ovdump::band, ES_NONE, FALSE, FLT_NEQ, pixval::nband, POSTGIS_RT_DEBUG, POSTGIS_RT_DEBUGF, PT_END, r, rtrowdump::raster, rt_band_get_hasnodata_flag(), rt_band_get_isnodata_flag(), rt_band_get_min_value(), rt_band_get_nodata(), rt_band_get_pixel(), rt_band_get_pixtype(), rt_band_set_pixel(), rt_pixtype_index_from_name(), rt_pixtype_name(), rt_raster_deserialize(), rt_raster_destroy(), 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_has_band(), rt_raster_is_empty(), rt_raster_new(), rt_raster_serialize(), rt_raster_set_offsets(), rt_raster_set_scale(), rt_raster_set_skews(), rt_raster_set_srid(), rtpg_strtoupper(), rt_raster_serialized_t::size, TRUE, pixval::x, and pixval::y.

Here is the call graph for this function: