PostGIS  3.4.0dev-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 5502 of file rtpg_mapalgebra.c.

5503 {
5504  rt_pgraster *pgraster = NULL;
5505  rt_pgraster *pgrtn = NULL;
5506  rt_raster raster = NULL;
5507  rt_raster newrast = NULL;
5508  rt_band band = NULL;
5509  rt_band newband = NULL;
5510  int x, y, nband, width, height, ngbwidth, ngbheight, winwidth, winheight, u, v, nIndex, nNullItems;
5511  double r, rpix;
5512  double newnodatavalue = 0.0;
5513  double newinitialvalue = 0.0;
5514  double newval = 0.0;
5515  rt_pixtype newpixeltype;
5516  int ret = -1;
5517  Oid oid;
5518  FmgrInfo cbinfo;
5519  LOCAL_FCINFO(cbdata, FUNC_MAX_ARGS); /* Could be optimized */
5520  Datum tmpnewval;
5521  ArrayType * neighborDatum;
5522  char * strFromText = NULL;
5523  text * txtNodataMode = NULL;
5524  text * txtCallbackParam = NULL;
5525  int intReplace = 0;
5526  float fltReplace = 0;
5527  bool valuereplace = false, pixelreplace, nNodataOnly = true, nNullSkip = false;
5528  Datum * neighborData = NULL;
5529  bool * neighborNulls = NULL;
5530  int neighborDims[2];
5531  int neighborLbs[2];
5532  int16 typlen;
5533  bool typbyval;
5534  char typalign;
5535 
5536  POSTGIS_RT_DEBUG(2, "RASTER_mapAlgebraFctNgb: STARTING...");
5537 
5538  /* Check raster */
5539  if (PG_ARGISNULL(0)) {
5540  elog(WARNING, "Raster is NULL. Returning NULL");
5541  PG_RETURN_NULL();
5542  }
5543 
5544 
5545  /* Deserialize raster */
5546  pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
5547  raster = rt_raster_deserialize(pgraster, FALSE);
5548  if (NULL == raster)
5549  {
5550  PG_FREE_IF_COPY(pgraster, 0);
5551  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not deserialize raster");
5552  PG_RETURN_NULL();
5553  }
5554 
5555  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting arguments...");
5556 
5557  /* Get the rest of the arguments */
5558 
5559  if (PG_ARGISNULL(1))
5560  nband = 1;
5561  else
5562  nband = PG_GETARG_INT32(1);
5563 
5564  if (nband < 1)
5565  nband = 1;
5566 
5567  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Creating new empty raster...");
5568 
5573  width = rt_raster_get_width(raster);
5574  height = rt_raster_get_height(raster);
5575 
5576  newrast = rt_raster_new(width, height);
5577 
5578  if ( NULL == newrast ) {
5580  PG_FREE_IF_COPY(pgraster, 0);
5581  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not create a new raster");
5582  PG_RETURN_NULL();
5583  }
5584 
5585  rt_raster_set_scale(newrast,
5588 
5589  rt_raster_set_offsets(newrast,
5592 
5593  rt_raster_set_skews(newrast,
5596 
5598 
5599 
5604  if (rt_raster_is_empty(newrast))
5605  {
5606  elog(NOTICE, "Raster is empty. Returning an empty raster");
5608  PG_FREE_IF_COPY(pgraster, 0);
5609 
5610  pgrtn = rt_raster_serialize(newrast);
5611  rt_raster_destroy(newrast);
5612  if (NULL == pgrtn) {
5613  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5614  PG_RETURN_NULL();
5615  }
5616 
5617  SET_VARSIZE(pgrtn, pgrtn->size);
5618  PG_RETURN_POINTER(pgrtn);
5619  }
5620 
5621  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Getting raster band %d...", nband);
5622 
5627  if (!rt_raster_has_band(raster, nband - 1)) {
5628  elog(NOTICE, "Raster does not have the required band. Returning a raster "
5629  "without a band");
5631  PG_FREE_IF_COPY(pgraster, 0);
5632 
5633  pgrtn = rt_raster_serialize(newrast);
5634  rt_raster_destroy(newrast);
5635  if (NULL == pgrtn) {
5636  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5637  PG_RETURN_NULL();
5638  }
5639 
5640  SET_VARSIZE(pgrtn, pgrtn->size);
5641  PG_RETURN_POINTER(pgrtn);
5642  }
5643 
5644  /* Get the raster band */
5646  if ( NULL == band ) {
5647  elog(NOTICE, "Could not get the required band. Returning a raster "
5648  "without a band");
5650  PG_FREE_IF_COPY(pgraster, 0);
5651 
5652  pgrtn = rt_raster_serialize(newrast);
5653  rt_raster_destroy(newrast);
5654  if (NULL == pgrtn) {
5655  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5656  PG_RETURN_NULL();
5657  }
5658 
5659  SET_VARSIZE(pgrtn, pgrtn->size);
5660  PG_RETURN_POINTER(pgrtn);
5661  }
5662 
5663  /*
5664  * Get NODATA value
5665  */
5666  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Getting NODATA value for band...");
5667 
5669  rt_band_get_nodata(band, &newnodatavalue);
5670  }
5671 
5672  else {
5673  newnodatavalue = rt_band_get_min_value(band);
5674  }
5675 
5676  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: NODATA value for band: %f",
5677  newnodatavalue);
5683  newinitialvalue = newnodatavalue;
5684 
5688  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Setting pixeltype...");
5689 
5690  if (PG_ARGISNULL(2)) {
5691  newpixeltype = rt_band_get_pixtype(band);
5692  }
5693 
5694  else {
5695  strFromText = text_to_cstring(PG_GETARG_TEXT_P(2));
5696  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype parameter: %s", strFromText);
5697  newpixeltype = rt_pixtype_index_from_name(strFromText);
5698  pfree(strFromText);
5699  if (newpixeltype == PT_END)
5700  newpixeltype = rt_band_get_pixtype(band);
5701  }
5702 
5703  if (newpixeltype == PT_END) {
5704 
5706  PG_FREE_IF_COPY(pgraster, 0);
5707  rt_raster_destroy(newrast);
5708 
5709  elog(ERROR, "RASTER_mapAlgebraFctNgb: Invalid pixeltype");
5710  PG_RETURN_NULL();
5711  }
5712 
5713  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Pixeltype set to %s (%d)",
5714  rt_pixtype_name(newpixeltype), newpixeltype);
5715 
5716  /* Get the name of the callback userfunction */
5717  if (PG_ARGISNULL(5)) {
5718 
5720  PG_FREE_IF_COPY(pgraster, 0);
5721  rt_raster_destroy(newrast);
5722 
5723  elog(ERROR, "RASTER_mapAlgebraFctNgb: Required function is missing");
5724  PG_RETURN_NULL();
5725  }
5726 
5727  oid = PG_GETARG_OID(5);
5728  if (oid == InvalidOid) {
5729 
5731  PG_FREE_IF_COPY(pgraster, 0);
5732  rt_raster_destroy(newrast);
5733 
5734  elog(ERROR, "RASTER_mapAlgebraFctNgb: Got invalid function object id");
5735  PG_RETURN_NULL();
5736  }
5737 
5738  fmgr_info(oid, &cbinfo);
5739 
5740  /* function cannot return set */
5741  if (cbinfo.fn_retset) {
5742 
5744  PG_FREE_IF_COPY(pgraster, 0);
5745  rt_raster_destroy(newrast);
5746 
5747  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function provided must return double precision not resultset");
5748  PG_RETURN_NULL();
5749  }
5750  /* function should have correct # of args */
5751  else if (cbinfo.fn_nargs != 3) {
5752 
5754  PG_FREE_IF_COPY(pgraster, 0);
5755  rt_raster_destroy(newrast);
5756 
5757  elog(ERROR, "RASTER_mapAlgebraFctNgb: Function does not have three input parameters");
5758  PG_RETURN_NULL();
5759  }
5760 
5761  if (func_volatile(oid) == 'v') {
5762  elog(NOTICE, "Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
5763  }
5764 
5765  /* prep function call data */
5766  InitFunctionCallInfoData(*cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
5767  cbdata->args[0].isnull = FALSE;
5768  cbdata->args[1].isnull = FALSE;
5769  cbdata->args[2].isnull = FALSE;
5770 
5771  /* check that the function isn't strict if the args are null. */
5772  if (PG_ARGISNULL(7)) {
5773  if (cbinfo.fn_strict) {
5774 
5776  PG_FREE_IF_COPY(pgraster, 0);
5777  rt_raster_destroy(newrast);
5778 
5779  elog(ERROR, "RASTER_mapAlgebraFctNgb: Strict callback functions cannot have NULL parameters");
5780  PG_RETURN_NULL();
5781  }
5782 
5783  cbdata->args[2].value = (Datum)NULL;
5784  cbdata->args[2].isnull = TRUE;
5785  }
5786  else {
5787  cbdata->args[2].value = PG_GETARG_DATUM(7);
5788  }
5789 
5796 
5797  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: Band is a nodata band, returning "
5798  "a raster filled with nodata");
5799 
5800  rt_raster_generate_new_band(newrast, newpixeltype,
5801  newinitialvalue, TRUE, newnodatavalue, 0);
5802 
5804  PG_FREE_IF_COPY(pgraster, 0);
5805 
5806  /* Serialize created raster */
5807  pgrtn = rt_raster_serialize(newrast);
5808  rt_raster_destroy(newrast);
5809  if (NULL == pgrtn) {
5810  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5811  PG_RETURN_NULL();
5812  }
5813 
5814  SET_VARSIZE(pgrtn, pgrtn->size);
5815  PG_RETURN_POINTER(pgrtn);
5816  }
5817 
5818 
5823  rt_raster_generate_new_band(newrast, newpixeltype,
5824  newinitialvalue, TRUE, newnodatavalue, 0);
5825 
5826  /* Get the new raster band */
5827  newband = rt_raster_get_band(newrast, 0);
5828  if ( NULL == newband ) {
5829  elog(NOTICE, "Could not modify band for new raster. Returning new "
5830  "raster with the original band");
5831 
5833  PG_FREE_IF_COPY(pgraster, 0);
5834 
5835  /* Serialize created raster */
5836  pgrtn = rt_raster_serialize(newrast);
5837  rt_raster_destroy(newrast);
5838  if (NULL == pgrtn) {
5839  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5840  PG_RETURN_NULL();
5841  }
5842 
5843  SET_VARSIZE(pgrtn, pgrtn->size);
5844  PG_RETURN_POINTER(pgrtn);
5845  }
5846 
5847  /* Get the width of the neighborhood */
5848  if (PG_ARGISNULL(3) || PG_GETARG_INT32(3) <= 0) {
5849  elog(NOTICE, "Neighborhood width is NULL or <= 0. Returning new "
5850  "raster with the original band");
5851 
5853  PG_FREE_IF_COPY(pgraster, 0);
5854 
5855  /* Serialize created raster */
5856  pgrtn = rt_raster_serialize(newrast);
5857  rt_raster_destroy(newrast);
5858  if (NULL == pgrtn) {
5859  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5860  PG_RETURN_NULL();
5861  }
5862 
5863  SET_VARSIZE(pgrtn, pgrtn->size);
5864  PG_RETURN_POINTER(pgrtn);
5865  }
5866 
5867  ngbwidth = PG_GETARG_INT32(3);
5868  winwidth = ngbwidth * 2 + 1;
5869 
5870  /* Get the height of the neighborhood */
5871  if (PG_ARGISNULL(4) || PG_GETARG_INT32(4) <= 0) {
5872  elog(NOTICE, "Neighborhood height is NULL or <= 0. Returning new "
5873  "raster with the original band");
5874 
5876  PG_FREE_IF_COPY(pgraster, 0);
5877 
5878  /* Serialize created raster */
5879  pgrtn = rt_raster_serialize(newrast);
5880  rt_raster_destroy(newrast);
5881  if (NULL == pgrtn) {
5882  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5883  PG_RETURN_NULL();
5884  }
5885 
5886  SET_VARSIZE(pgrtn, pgrtn->size);
5887  PG_RETURN_POINTER(pgrtn);
5888  }
5889 
5890  ngbheight = PG_GETARG_INT32(4);
5891  winheight = ngbheight * 2 + 1;
5892 
5893  /* Get the type of NODATA behavior for the neighborhoods. */
5894  if (PG_ARGISNULL(6)) {
5895  elog(NOTICE, "Neighborhood NODATA behavior defaulting to 'ignore'");
5896  txtNodataMode = cstring_to_text("ignore");
5897  }
5898  else {
5899  txtNodataMode = PG_GETARG_TEXT_P(6);
5900  }
5901 
5902  txtCallbackParam = (text*)palloc(VARSIZE(txtNodataMode));
5903  SET_VARSIZE(txtCallbackParam, VARSIZE(txtNodataMode));
5904  memcpy((void *)VARDATA(txtCallbackParam), (void *)VARDATA(txtNodataMode), VARSIZE(txtNodataMode) - VARHDRSZ);
5905 
5906  /* pass the nodata mode into the user function */
5907  cbdata->args[1].value = PointerGetDatum(txtCallbackParam);
5908 
5909  strFromText = text_to_cstring(txtNodataMode);
5910  strFromText = rtpg_strtoupper(strFromText);
5911 
5912  if (strcmp(strFromText, "VALUE") == 0)
5913  valuereplace = true;
5914  else if (strcmp(strFromText, "IGNORE") != 0 && strcmp(strFromText, "NULL") != 0) {
5915  /* if the text is not "IGNORE" or "NULL", it may be a numerical value */
5916  if (sscanf(strFromText, "%d", &intReplace) <= 0 && sscanf(strFromText, "%f", &fltReplace) <= 0) {
5917  /* the value is NOT an integer NOR a floating point */
5918  elog(NOTICE, "Neighborhood NODATA mode is not recognized. Must be one of 'value', 'ignore', "
5919  "'NULL', or a numeric value. Returning new raster with the original band");
5920 
5921  /* clean up the nodatamode string */
5922  pfree(txtCallbackParam);
5923  pfree(strFromText);
5924 
5926  PG_FREE_IF_COPY(pgraster, 0);
5927 
5928  /* Serialize created raster */
5929  pgrtn = rt_raster_serialize(newrast);
5930  rt_raster_destroy(newrast);
5931  if (NULL == pgrtn) {
5932  elog(ERROR, "RASTER_mapAlgebraFctNgb: Could not serialize raster");
5933  PG_RETURN_NULL();
5934  }
5935 
5936  SET_VARSIZE(pgrtn, pgrtn->size);
5937  PG_RETURN_POINTER(pgrtn);
5938  }
5939  }
5940  else if (strcmp(strFromText, "NULL") == 0) {
5941  /* this setting means that the neighborhood should be skipped if any of the values are null */
5942  nNullSkip = true;
5943  }
5944 
5945  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: Main computing loop (%d x %d)",
5946  width, height);
5947 
5948  /* Allocate room for the neighborhood. */
5949  neighborData = (Datum *)palloc(winwidth * winheight * sizeof(Datum));
5950  neighborNulls = (bool *)palloc(winwidth * winheight * sizeof(bool));
5951 
5952  /* The dimensions of the neighborhood array, for creating a multi-dimensional array. */
5953  neighborDims[0] = winwidth;
5954  neighborDims[1] = winheight;
5955 
5956  /* The lower bounds for the new multi-dimensional array. */
5957  neighborLbs[0] = 1;
5958  neighborLbs[1] = 1;
5959 
5960  /* Get information about the type of item in the multi-dimensional array (float8). */
5961  get_typlenbyvalalign(FLOAT8OID, &typlen, &typbyval, &typalign);
5962 
5963  for (x = 0 + ngbwidth; x < width - ngbwidth; x++) {
5964  for(y = 0 + ngbheight; y < height - ngbheight; y++) {
5965  /* populate an array with the pixel values in the neighborhood */
5966  nIndex = 0;
5967  nNullItems = 0;
5968  nNodataOnly = true;
5969  pixelreplace = false;
5970  if (valuereplace) {
5971  ret = rt_band_get_pixel(band, x, y, &rpix, NULL);
5972  if (ret == ES_NONE && FLT_NEQ(rpix, newnodatavalue)) {
5973  pixelreplace = true;
5974  }
5975  }
5976  for (u = x - ngbwidth; u <= x + ngbwidth; u++) {
5977  for (v = y - ngbheight; v <= y + ngbheight; v++) {
5978  ret = rt_band_get_pixel(band, u, v, &r, NULL);
5979  if (ret == ES_NONE) {
5980  if (FLT_NEQ(r, newnodatavalue)) {
5981  /* If the pixel value for this neighbor cell is not NODATA */
5982  neighborData[nIndex] = Float8GetDatum((double)r);
5983  neighborNulls[nIndex] = false;
5984  nNodataOnly = false;
5985  }
5986  else {
5987  /* If the pixel value for this neighbor cell is NODATA */
5988  if (valuereplace && pixelreplace) {
5989  /* Replace the NODATA value with the currently processing pixel. */
5990  neighborData[nIndex] = Float8GetDatum((double)rpix);
5991  neighborNulls[nIndex] = false;
5992  /* do not increment nNullItems, since the user requested that the */
5993  /* neighborhood replace NODATA values with the central pixel value */
5994  }
5995  else {
5996  neighborData[nIndex] = PointerGetDatum(NULL);
5997  neighborNulls[nIndex] = true;
5998  nNullItems++;
5999  }
6000  }
6001  }
6002  else {
6003  /* Fill this will NULL if we can't read the raster pixel. */
6004  neighborData[nIndex] = PointerGetDatum(NULL);
6005  neighborNulls[nIndex] = true;
6006  nNullItems++;
6007  }
6008  /* Next neighbor position */
6009  nIndex++;
6010  }
6011  }
6012 
6017  if (!(nNodataOnly || /* neighborhood only contains NODATA -- OR -- */
6018  (nNullSkip && nNullItems > 0) || /* neighborhood should skip any NODATA cells, and a NODATA cell was detected -- OR -- */
6019  (valuereplace && nNullItems > 0))) { /* neighborhood should replace NODATA cells with the central pixel value, and a NODATA cell was detected */
6020  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: (%dx%d), %dx%d neighborhood",
6021  x, y, winwidth, winheight);
6022 
6023  neighborDatum = construct_md_array((void *)neighborData, neighborNulls, 2, neighborDims, neighborLbs,
6024  FLOAT8OID, typlen, typbyval, typalign);
6025 
6026  /* Assign the neighbor matrix as the first argument to the user function */
6027  cbdata->args[0].value = PointerGetDatum(neighborDatum);
6028 
6029  /* Invoke the user function */
6030  tmpnewval = FunctionCallInvoke(cbdata);
6031 
6032  /* Get the return value of the user function */
6033  if (cbdata->isnull)
6034  {
6035  newval = newnodatavalue;
6036  }
6037  else {
6038  newval = DatumGetFloat8(tmpnewval);
6039  }
6040 
6041  POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFctNgb: new value = %f",
6042  newval);
6043 
6044  rt_band_set_pixel(newband, x, y, newval, NULL);
6045  }
6046 
6047  /* reset the number of null items in the neighborhood */
6048  nNullItems = 0;
6049  }
6050  }
6051 
6052 
6053  /* clean up */
6054  pfree(neighborNulls);
6055  pfree(neighborData);
6056  pfree(strFromText);
6057  pfree(txtCallbackParam);
6058 
6060  PG_FREE_IF_COPY(pgraster, 0);
6061 
6062  /* The newrast band has been modified */
6063 
6064  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster modified, serializing it.");
6065  /* Serialize created raster */
6066 
6067  pgrtn = rt_raster_serialize(newrast);
6068  rt_raster_destroy(newrast);
6069  if (NULL == pgrtn)
6070  PG_RETURN_NULL();
6071 
6072  POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFctNgb: raster serialized");
6073  POSTGIS_RT_DEBUG(4, "RASTER_mapAlgebraFctNgb: returning raster");
6074 
6075  SET_VARSIZE(pgrtn, pgrtn->size);
6076  PG_RETURN_POINTER(pgrtn);
6077 }
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:2386
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:65
#define POSTGIS_RT_DEBUGF(level, msg,...)
Definition: rtpostgis.h:69
Struct definitions.
Definition: librtcore.h:2403

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: