PostGIS  3.4.0dev-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 1568 of file rt_raster.c.

1568  {
1569  rt_raster rtn = NULL;
1570  double gt[6] = {0};
1571 
1572  assert(NULL != raster);
1573 
1574  if (deep) {
1575  int numband = rt_raster_get_num_bands(raster);
1576  uint32_t *nband = NULL;
1577  int i = 0;
1578 
1579  nband = rtalloc(sizeof(uint32_t) * numband);
1580  if (nband == NULL) {
1581  rterror("rt_raster_clone: Could not allocate memory for deep clone");
1582  return NULL;
1583  }
1584  for (i = 0; i < numband; i++)
1585  nband[i] = i;
1586 
1587  rtn = rt_raster_from_band(raster, nband, numband);
1588  rtdealloc(nband);
1589 
1590  return rtn;
1591  }
1592 
1593  rtn = rt_raster_new(
1596  );
1597  if (rtn == NULL) {
1598  rterror("rt_raster_clone: Could not create cloned raster");
1599  return NULL;
1600  }
1601 
1605 
1606  return rtn;
1607 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:219
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:191
void rtdealloc(void *mem)
Definition: rt_context.c:206
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:360
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
Definition: rt_raster.c:731
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_raster.c:52
uint16_t rt_raster_get_num_bands(rt_raster raster)
Definition: rt_raster.c:376
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_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:1463
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_raster.c:125
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_raster.c:710

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: