PostGIS  2.5.7dev-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 5607 of file rtpg_mapalgebra.c.

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

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, text_to_cstring(), TRUE, pixval::x, and pixval::y.

Here is the call graph for this function: