PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ rt_raster_clone()

rt_raster rt_raster_clone ( rt_raster  raster,
uint8_t  deep 
)

Clone an existing raster.

Parameters
raster: raster to clone
deep: flag indicating if bands should be cloned
Returns
a new rt_raster or NULL on error

Definition at line 1535 of file rt_raster.c.

1535  {
1536  rt_raster rtn = NULL;
1537  double gt[6] = {0};
1538 
1539  assert(NULL != raster);
1540 
1541  if (deep) {
1542  int numband = rt_raster_get_num_bands(raster);
1543  uint32_t *nband = NULL;
1544  int i = 0;
1545 
1546  nband = rtalloc(sizeof(uint32_t) * numband);
1547  if (nband == NULL) {
1548  rterror("rt_raster_clone: Could not allocate memory for deep clone");
1549  return NULL;
1550  }
1551  for (i = 0; i < numband; i++)
1552  nband[i] = i;
1553 
1554  rtn = rt_raster_from_band(raster, nband, numband);
1555  rtdealloc(nband);
1556 
1557  return rtn;
1558  }
1559 
1560  rtn = rt_raster_new(
1563  );
1564  if (rtn == NULL) {
1565  rterror("rt_raster_clone: Could not create cloned raster");
1566  return NULL;
1567  }
1568 
1572 
1573  return rtn;
1574 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
void rtdealloc(void *mem)
Definition: rt_context.c:186
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
gt
Definition: window.py:78
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_raster.c:356
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
Definition: rt_raster.c:727
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:48
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:372
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_raster rt_raster_from_band(rt_raster raster, uint32_t *bandNums, int count)
Construct a new rt_raster from an existing rt_raster and an array of band numbers.
Definition: rt_raster.c:1430
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:121
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_raster.c:706

References window::gt, pixval::nband, rtrowdump::raster, rt_raster_from_band(), rt_raster_get_geotransform_matrix(), rt_raster_get_height(), rt_raster_get_num_bands(), rt_raster_get_srid(), rt_raster_get_width(), rt_raster_new(), rt_raster_set_geotransform_matrix(), rt_raster_set_srid(), rtalloc(), rtdealloc(), and rterror().

Referenced by _rti_colormap_arg_init(), RASTER_colorMap(), RASTER_union_transfn(), rtpg_union_noarg(), and test_raster_clone().

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