PostGIS  2.5.7dev-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 1540 of file rt_raster.c.

1540  {
1541  rt_raster rtn = NULL;
1542  double gt[6] = {0};
1543 
1544  assert(NULL != raster);
1545 
1546  if (deep) {
1547  int numband = rt_raster_get_num_bands(raster);
1548  uint32_t *nband = NULL;
1549  int i = 0;
1550 
1551  nband = rtalloc(sizeof(uint32_t) * numband);
1552  if (nband == NULL) {
1553  rterror("rt_raster_clone: Could not allocate memory for deep clone");
1554  return NULL;
1555  }
1556  for (i = 0; i < numband; i++)
1557  nband[i] = i;
1558 
1559  rtn = rt_raster_from_band(raster, nband, numband);
1560  rtdealloc(nband);
1561 
1562  return rtn;
1563  }
1564 
1565  rtn = rt_raster_new(
1568  );
1569  if (rtn == NULL) {
1570  rterror("rt_raster_clone: Could not create cloned raster");
1571  return NULL;
1572  }
1573 
1577 
1578  return rtn;
1579 }
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:52
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:77
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:1435
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
unsigned int uint32_t
Definition: uthash.h:78

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: