PostGIS  3.1.6dev-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 5612 of file rtpg_mapalgebra.c.

5613 {
5614  rt_pgraster *pgraster = NULL;
5615  rt_pgraster *pgrtn = NULL;
5616  rt_raster raster = NULL;
5617  rt_raster newrast = NULL;
5618  rt_band band = NULL;
5619  rt_band newband = NULL;
5620  int x, y, nband, width, height, ngbwidth, ngbheight, winwidth, winheight, u, v, nIndex, nNullItems;
5621  double r, rpix;
5622  double newnodatavalue = 0.0;
5623  double newinitialvalue = 0.0;
5624  double newval = 0.0;
5625  rt_pixtype newpixeltype;
5626  int ret = -1;
5627  Oid oid;
5628  FmgrInfo cbinfo;
5629 #if POSTGIS_PGSQL_VERSION < 120
5630  FunctionCallInfoData cbdata;
5631 #else
5632  LOCAL_FCINFO(cbdata, FUNC_MAX_ARGS); /* Could be optimized */
5633 #endif
5634  Datum tmpnewval;
5635  ArrayType * neighborDatum;
5636  char * strFromText = NULL;
5637  text * txtNodataMode = NULL;
5638  text * txtCallbackParam = NULL;
5639  int intReplace = 0;
5640  float fltReplace = 0;
5641  bool valuereplace = false, pixelreplace, nNodataOnly = true, nNullSkip = false;
5642  Datum * neighborData = NULL;
5643  bool * neighborNulls = NULL;
5644  int neighborDims[2];
5645  int neighborLbs[2];
5646  int16 typlen;
5647  bool typbyval;
5648  char typalign;
5649 
5650  POSTGIS_RT_DEBUG(2, "RASTER_mapAlgebraFctNgb: STARTING...");
5651 
5652  /* Check raster */
5653  if (PG_ARGISNULL(0)) {
5654  elog(WARNING, "Raster is NULL. Returning NULL");
5655  PG_RETURN_NULL();
5656  }
5657 
5658 
5659  /* Deserialize raster */
5660  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
5661  raster = rt_raster_deserialize(pgraster, FALSE);
5662  if (NULL == raster)
5663  {
5664  PG_FREE_IF_COPY(pgraster, 0);
5665  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not deserialize raster");
5666  PG_RETURN_NULL();
5667  }
5668 
5669  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting arguments...");
5670 
5671  /* Get the rest of the arguments */
5672 
5673  if (PG_ARGISNULL(1))
5674  nband = 1;
5675  else
5676  nband = PG_GETARG_INT32(1);
5677 
5678  if (nband < 1)
5679  nband = 1;
5680 
5681  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Creating new empty raster...");
5682 
5687  width = rt_raster_get_width(raster);
5688  height = rt_raster_get_height(raster);
5689 
5690  newrast = rt_raster_new(width, height);
5691 
5692  if ( NULL == newrast ) {
5694  PG_FREE_IF_COPY(pgraster, 0);
5695  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not create a new raster");
5696  PG_RETURN_NULL();
5697  }
5698 
5699  rt_raster_set_scale(newrast,
5702 
5703  rt_raster_set_offsets(newrast,
5706 
5707  rt_raster_set_skews(newrast,
5710 
5712 
5713 
5718  if (rt_raster_is_empty(newrast))
5719  {
5720  elog(NOTICE, "Raster is empty. Returning an empty raster");
5722  PG_FREE_IF_COPY(pgraster, 0);
5723 
5724  pgrtn = rt_raster_serialize(newrast);
5725  rt_raster_destroy(newrast);
5726  if (NULL == pgrtn) {
5727  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5728  PG_RETURN_NULL();
5729  }
5730 
5731  SET_VARSIZE(pgrtn, pgrtn->size);
5732  PG_RETURN_POINTER(pgrtn);
5733  }
5734 
5735  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Getting raster band %d...", nband);
5736 
5741  if (!rt_raster_has_band(raster, nband - 1)) {
5742  elog(NOTICE, "Raster does not have the required band. Returning a raster "
5743  "without a band");
5745  PG_FREE_IF_COPY(pgraster, 0);
5746 
5747  pgrtn = rt_raster_serialize(newrast);
5748  rt_raster_destroy(newrast);
5749  if (NULL == pgrtn) {
5750  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5751  PG_RETURN_NULL();
5752  }
5753 
5754  SET_VARSIZE(pgrtn, pgrtn->size);
5755  PG_RETURN_POINTER(pgrtn);
5756  }
5757 
5758  /* Get the raster band */
5760  if ( NULL == band ) {
5761  elog(NOTICE, "Could not get the required band. Returning a raster "
5762  "without a band");
5764  PG_FREE_IF_COPY(pgraster, 0);
5765 
5766  pgrtn = rt_raster_serialize(newrast);
5767  rt_raster_destroy(newrast);
5768  if (NULL == pgrtn) {
5769  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5770  PG_RETURN_NULL();
5771  }
5772 
5773  SET_VARSIZE(pgrtn, pgrtn->size);
5774  PG_RETURN_POINTER(pgrtn);
5775  }
5776 
5777  /*
5778  * Get NODATA value
5779  */
5780  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting NODATA value for band...");
5781 
5783  rt_band_get_nodata(band, &newnodatavalue);
5784  }
5785 
5786  else {
5787  newnodatavalue = rt_band_get_min_value(band);
5788  }
5789 
5790  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: NODATA value for band: %f",
5791  newnodatavalue);
5797  newinitialvalue = newnodatavalue;
5798 
5802  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Setting pixeltype...");
5803 
5804  if (PG_ARGISNULL(2)) {
5805  newpixeltype = rt_band_get_pixtype(band);
5806  }
5807 
5808  else {
5809  strFromText = text_to_cstring(PG_GETARG_TEXT_P(2));
5810  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype parameter: %s", strFromText);
5811  newpixeltype = rt_pixtype_index_from_name(strFromText);
5812  pfree(strFromText);
5813  if (newpixeltype == PT_END)
5814  newpixeltype = rt_band_get_pixtype(band);
5815  }
5816 
5817  if (newpixeltype == PT_END) {
5818 
5820  PG_FREE_IF_COPY(pgraster, 0);
5821  rt_raster_destroy(newrast);
5822 
5823  elog(ERROR, "RASTER_mapAlgebraFctNgb: Invalid pixeltype");
5824  PG_RETURN_NULL();
5825  }
5826 
5827  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype set to %s (%d)",
5828  rt_pixtype_name(newpixeltype), newpixeltype);
5829 
5830  /* Get the name of the callback userfunction */
5831  if (PG_ARGISNULL(5)) {
5832 
5834  PG_FREE_IF_COPY(pgraster, 0);
5835  rt_raster_destroy(newrast);
5836 
5837  elog(ERROR, "RASTER_mapAlgebraFctNgb: Required function is missing");
5838  PG_RETURN_NULL();
5839  }
5840 
5841  oid = PG_GETARG_OID(5);
5842  if (oid == InvalidOid) {
5843 
5845  PG_FREE_IF_COPY(pgraster, 0);
5846  rt_raster_destroy(newrast);
5847 
5848  elog(ERROR, "RASTER_mapAlgebraFctNgb: Got invalid function object id");
5849  PG_RETURN_NULL();
5850  }
5851 
5852  fmgr_info(oid, &cbinfo);
5853 
5854  /* function cannot return set */
5855  if (cbinfo.fn_retset) {
5856 
5858  PG_FREE_IF_COPY(pgraster, 0);
5859  rt_raster_destroy(newrast);
5860 
5861  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function provided must return double precision not resultset");
5862  PG_RETURN_NULL();
5863  }
5864  /* function should have correct # of args */
5865  else if (cbinfo.fn_nargs != 3) {
5866 
5868  PG_FREE_IF_COPY(pgraster, 0);
5869  rt_raster_destroy(newrast);
5870 
5871  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function does not have three input parameters");
5872  PG_RETURN_NULL();
5873  }
5874 
5875  if (func_volatile(oid) == 'v') {
5876  elog(NOTICE, "Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
5877  }
5878 
5879  /* prep function call data */
5880 #if POSTGIS_PGSQL_VERSION < 120
5881  InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
5882  memset(cbdata.argnull, FALSE, sizeof(bool) * 3);
5883 #else
5884  InitFunctionCallInfoData(*cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
5885  cbdata->args[0].isnull = FALSE;
5886  cbdata->args[1].isnull = FALSE;
5887  cbdata->args[2].isnull = FALSE;
5888 #endif
5889 
5890  /* check that the function isn't strict if the args are null. */
5891  if (PG_ARGISNULL(7)) {
5892  if (cbinfo.fn_strict) {
5893 
5895  PG_FREE_IF_COPY(pgraster, 0);
5896  rt_raster_destroy(newrast);
5897 
5898  elog(ERROR, "RASTER_mapAlgebraFctNgb: Strict callback functions cannot have NULL parameters");
5899  PG_RETURN_NULL();
5900  }
5901 
5902 #if POSTGIS_PGSQL_VERSION < 120
5903  cbdata.arg[2] = (Datum)NULL;
5904  cbdata.argnull[2] = TRUE;
5905 #else
5906  cbdata->args[2].value = (Datum)NULL;
5907  cbdata->args[2].isnull = TRUE;
5908 #endif
5909  }
5910  else {
5911 #if POSTGIS_PGSQL_VERSION < 120
5912  cbdata.arg[2] = PG_GETARG_DATUM(7);
5913 #else
5914  cbdata->args[2].value = PG_GETARG_DATUM(7);
5915 #endif
5916  }
5917 
5924 
5925  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Band is a nodata band, returning "
5926  "a raster filled with nodata");
5927 
5928  rt_raster_generate_new_band(newrast, newpixeltype,
5929  newinitialvalue, TRUE, newnodatavalue, 0);
5930 
5932  PG_FREE_IF_COPY(pgraster, 0);
5933 
5934  /* Serialize created raster */
5935  pgrtn = rt_raster_serialize(newrast);
5936  rt_raster_destroy(newrast);
5937  if (NULL == pgrtn) {
5938  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5939  PG_RETURN_NULL();
5940  }
5941 
5942  SET_VARSIZE(pgrtn, pgrtn->size);
5943  PG_RETURN_POINTER(pgrtn);
5944  }
5945 
5946 
5951  rt_raster_generate_new_band(newrast, newpixeltype,
5952  newinitialvalue, TRUE, newnodatavalue, 0);
5953 
5954  /* Get the new raster band */
5955  newband = rt_raster_get_band(newrast, 0);
5956  if ( NULL == newband ) {
5957  elog(NOTICE, "Could not modify band for new raster. Returning new "
5958  "raster with the original band");
5959 
5961  PG_FREE_IF_COPY(pgraster, 0);
5962 
5963  /* Serialize created raster */
5964  pgrtn = rt_raster_serialize(newrast);
5965  rt_raster_destroy(newrast);
5966  if (NULL == pgrtn) {
5967  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5968  PG_RETURN_NULL();
5969  }
5970 
5971  SET_VARSIZE(pgrtn, pgrtn->size);
5972  PG_RETURN_POINTER(pgrtn);
5973  }
5974 
5975  /* Get the width of the neighborhood */
5976  if (PG_ARGISNULL(3) || PG_GETARG_INT32(3) <= 0) {
5977  elog(NOTICE, "Neighborhood width is NULL or <= 0. Returning new "
5978  "raster with the original band");
5979 
5981  PG_FREE_IF_COPY(pgraster, 0);
5982 
5983  /* Serialize created raster */
5984  pgrtn = rt_raster_serialize(newrast);
5985  rt_raster_destroy(newrast);
5986  if (NULL == pgrtn) {
5987  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5988  PG_RETURN_NULL();
5989  }
5990 
5991  SET_VARSIZE(pgrtn, pgrtn->size);
5992  PG_RETURN_POINTER(pgrtn);
5993  }
5994 
5995  ngbwidth = PG_GETARG_INT32(3);
5996  winwidth = ngbwidth * 2 + 1;
5997 
5998  /* Get the height of the neighborhood */
5999  if (PG_ARGISNULL(4) || PG_GETARG_INT32(4) <= 0) {
6000  elog(NOTICE, "Neighborhood height is NULL or <= 0. Returning new "
6001  "raster with the original band");
6002 
6004  PG_FREE_IF_COPY(pgraster, 0);
6005 
6006  /* Serialize created raster */
6007  pgrtn = rt_raster_serialize(newrast);
6008  rt_raster_destroy(newrast);
6009  if (NULL == pgrtn) {
6010  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
6011  PG_RETURN_NULL();
6012  }
6013 
6014  SET_VARSIZE(pgrtn, pgrtn->size);
6015  PG_RETURN_POINTER(pgrtn);
6016  }
6017 
6018  ngbheight = PG_GETARG_INT32(4);
6019  winheight = ngbheight * 2 + 1;
6020 
6021  /* Get the type of NODATA behavior for the neighborhoods. */
6022  if (PG_ARGISNULL(6)) {
6023  elog(NOTICE, "Neighborhood NODATA behavior defaulting to 'ignore'");
6024  txtNodataMode = cstring_to_text("ignore");
6025  }
6026  else {
6027  txtNodataMode = PG_GETARG_TEXT_P(6);
6028  }
6029 
6030  txtCallbackParam = (text*)palloc(VARSIZE(txtNodataMode));
6031  SET_VARSIZE(txtCallbackParam, VARSIZE(txtNodataMode));
6032  memcpy((void *)VARDATA(txtCallbackParam), (void *)VARDATA(txtNodataMode), VARSIZE(txtNodataMode) - VARHDRSZ);
6033 
6034  /* pass the nodata mode into the user function */
6035 #if POSTGIS_PGSQL_VERSION < 120
6036  cbdata.arg[1] = CStringGetDatum(txtCallbackParam);
6037 #else
6038  cbdata->args[1].value = CStringGetDatum(txtCallbackParam);
6039 #endif
6040 
6041  strFromText = text_to_cstring(txtNodataMode);
6042  strFromText = rtpg_strtoupper(strFromText);
6043 
6044  if (strcmp(strFromText, "VALUE") == 0)
6045  valuereplace = true;
6046  else if (strcmp(strFromText, "IGNORE") != 0 && strcmp(strFromText, "NULL") != 0) {
6047  /* if the text is not "IGNORE" or "NULL", it may be a numerical value */
6048  if (sscanf(strFromText, "%d", &intReplace) <= 0 && sscanf(strFromText, "%f", &fltReplace) <= 0) {
6049  /* the value is NOT an integer NOR a floating point */
6050  elog(NOTICE, "Neighborhood NODATA mode is not recognized. Must be one of 'value', 'ignore', "
6051  "'NULL', or a numeric value. Returning new raster with the original band");
6052 
6053  /* clean up the nodatamode string */
6054  pfree(txtCallbackParam);
6055  pfree(strFromText);
6056 
6058  PG_FREE_IF_COPY(pgraster, 0);
6059 
6060  /* Serialize created raster */
6061  pgrtn = rt_raster_serialize(newrast);
6062  rt_raster_destroy(newrast);
6063  if (NULL == pgrtn) {
6064  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
6065  PG_RETURN_NULL();
6066  }
6067 
6068  SET_VARSIZE(pgrtn, pgrtn->size);
6069  PG_RETURN_POINTER(pgrtn);
6070  }
6071  }
6072  else if (strcmp(strFromText, "NULL") == 0) {
6073  /* this setting means that the neighborhood should be skipped if any of the values are null */
6074  nNullSkip = true;
6075  }
6076 
6077  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Main computing loop (%d x %d)",
6078  width, height);
6079 
6080  /* Allocate room for the neighborhood. */
6081  neighborData = (Datum *)palloc(winwidth * winheight * sizeof(Datum));
6082  neighborNulls = (bool *)palloc(winwidth * winheight * sizeof(bool));
6083 
6084  /* The dimensions of the neighborhood array, for creating a multi-dimensional array. */
6085  neighborDims[0] = winwidth;
6086  neighborDims[1] = winheight;
6087 
6088  /* The lower bounds for the new multi-dimensional array. */
6089  neighborLbs[0] = 1;
6090  neighborLbs[1] = 1;
6091 
6092  /* Get information about the type of item in the multi-dimensional array (float8). */
6093  get_typlenbyvalalign(FLOAT8OID, &typlen, &typbyval, &typalign);
6094 
6095  for (x = 0 + ngbwidth; x < width - ngbwidth; x++) {
6096  for(y = 0 + ngbheight; y < height - ngbheight; y++) {
6097  /* populate an array with the pixel values in the neighborhood */
6098  nIndex = 0;
6099  nNullItems = 0;
6100  nNodataOnly = true;
6101  pixelreplace = false;
6102  if (valuereplace) {
6103  ret = rt_band_get_pixel(band, x, y, &rpix, NULL);
6104  if (ret == ES_NONE && FLT_NEQ(rpix, newnodatavalue)) {
6105  pixelreplace = true;
6106  }
6107  }
6108  for (u = x - ngbwidth; u <= x + ngbwidth; u++) {
6109  for (v = y - ngbheight; v <= y + ngbheight; v++) {
6110  ret = rt_band_get_pixel(band, u, v, &r, NULL);
6111  if (ret == ES_NONE) {
6112  if (FLT_NEQ(r, newnodatavalue)) {
6113  /* If the pixel value for this neighbor cell is not NODATA */
6114  neighborData[nIndex] = Float8GetDatum((double)r);
6115  neighborNulls[nIndex] = false;
6116  nNodataOnly = false;
6117  }
6118  else {
6119  /* If the pixel value for this neighbor cell is NODATA */
6120  if (valuereplace && pixelreplace) {
6121  /* Replace the NODATA value with the currently processing pixel. */
6122  neighborData[nIndex] = Float8GetDatum((double)rpix);
6123  neighborNulls[nIndex] = false;
6124  /* do not increment nNullItems, since the user requested that the */
6125  /* neighborhood replace NODATA values with the central pixel value */
6126  }
6127  else {
6128  neighborData[nIndex] = PointerGetDatum(NULL);
6129  neighborNulls[nIndex] = true;
6130  nNullItems++;
6131  }
6132  }
6133  }
6134  else {
6135  /* Fill this will NULL if we can't read the raster pixel. */
6136  neighborData[nIndex] = PointerGetDatum(NULL);
6137  neighborNulls[nIndex] = true;
6138  nNullItems++;
6139  }
6140  /* Next neighbor position */
6141  nIndex++;
6142  }
6143  }
6144 
6149  if (!(nNodataOnly || /* neighborhood only contains NODATA -- OR -- */
6150  (nNullSkip && nNullItems > 0) || /* neighborhood should skip any NODATA cells, and a NODATA cell was detected -- OR -- */
6151  (valuereplace && nNullItems > 0))) { /* neighborhood should replace NODATA cells with the central pixel value, and a NODATA cell was detected */
6152  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: (%dx%d), %dx%d neighborhood",
6153  x, y, winwidth, winheight);
6154 
6155  neighborDatum = construct_md_array((void *)neighborData, neighborNulls, 2, neighborDims, neighborLbs,
6156  FLOAT8OID, typlen, typbyval, typalign);
6157 
6158 #if POSTGIS_PGSQL_VERSION < 120
6159  /* Assign the neighbor matrix as the first argument to the user function */
6160  cbdata.arg[0] = PointerGetDatum(neighborDatum);
6161 
6162  /* Invoke the user function */
6163  tmpnewval = FunctionCallInvoke(&cbdata);
6164 
6165  /* Get the return value of the user function */
6166  if (cbdata.isnull) {
6167  newval = newnodatavalue;
6168  }
6169 #else
6170  /* Assign the neighbor matrix as the first argument to the user function */
6171  cbdata->args[0].value = PointerGetDatum(neighborDatum);
6172 
6173  /* Invoke the user function */
6174  tmpnewval = FunctionCallInvoke(cbdata);
6175 
6176  /* Get the return value of the user function */
6177  if (cbdata->isnull)
6178  {
6179  newval = newnodatavalue;
6180  }
6181 #endif
6182  else {
6183  newval = DatumGetFloat8(tmpnewval);
6184  }
6185 
6186  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: new value = %f",
6187  newval);
6188 
6189  rt_band_set_pixel(newband, x, y, newval, NULL);
6190  }
6191 
6192  /* reset the number of null items in the neighborhood */
6193  nNullItems = 0;
6194  }
6195  }
6196 
6197 
6198  /* clean up */
6199  pfree(neighborNulls);
6200  pfree(neighborData);
6201  pfree(strFromText);
6202  pfree(txtCallbackParam);
6203 
6205  PG_FREE_IF_COPY(pgraster, 0);
6206 
6207  /* The newrast band has been modified */
6208 
6209  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster modified, serializing it.");
6210  /* Serialize created raster */
6211 
6212  pgrtn = rt_raster_serialize(newrast);
6213  rt_raster_destroy(newrast);
6214  if (NULL == pgrtn)
6215  PG_RETURN_NULL();
6216 
6217  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster serialized");
6218  POSTGIS_RT_DEBUG(4, "RASTER_mapAlgebraFctNgb: returning raster");
6219 
6220  SET_VARSIZE(pgrtn, pgrtn->size);
6221  PG_RETURN_POINTER(pgrtn);
6222 }
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:2234
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
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 rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition: rt_raster.c:137
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:1221
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
Definition: rt_raster.c:82
rt_pixtype
Definition: librtcore.h:185
@ PT_END
Definition: librtcore.h:197
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
Definition: rt_raster.c:168
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:48
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:1342
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: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
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_raster.c:129
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_raster.c:363
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition: rt_band.c:1730
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:121
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.
Definition: rt_raster.c:159
double rt_raster_get_y_skew(rt_raster raster)
Get skew about the Y axis.
Definition: rt_raster.c:190
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition: rt_raster.c:199
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:222
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
Definition: rt_raster.c:1329
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
Definition: rt_raster.c:381
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:61
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:65
Struct definitions.
Definition: librtcore.h:2251

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: