PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 8740 of file rt_api.c.

References window::gt, pixval::nband, 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().

8740  {
8741  rt_raster rtn = NULL;
8742  double gt[6] = {0};
8743 
8744  assert(NULL != raster);
8745 
8746  if (deep) {
8747  int numband = rt_raster_get_num_bands(raster);
8748  uint32_t *nband = NULL;
8749  int i = 0;
8750 
8751  nband = rtalloc(sizeof(uint32_t) * numband);
8752  if (nband == NULL) {
8753  rterror("rt_raster_clone: Could not allocate memory for deep clone");
8754  return NULL;
8755  }
8756  for (i = 0; i < numband; i++)
8757  nband[i] = i;
8758 
8759  rtn = rt_raster_from_band(raster, nband, numband);
8760  rtdealloc(nband);
8761 
8762  return rtn;
8763  }
8764 
8765  rtn = rt_raster_new(
8766  rt_raster_get_width(raster),
8767  rt_raster_get_height(raster)
8768  );
8769  if (rtn == NULL) {
8770  rterror("rt_raster_clone: Could not create cloned raster");
8771  return NULL;
8772  }
8773 
8776  rt_raster_set_srid(rtn, rt_raster_get_srid(raster));
8777 
8778  return rtn;
8779 }
int rt_raster_get_num_bands(rt_raster raster)
Definition: rt_api.c:5677
void rtdealloc(void *mem)
Definition: rt_api.c:882
tuple gt
Definition: window.py:79
void rt_raster_set_srid(rt_raster raster, int32_t srid)
Set raster's SRID.
Definition: rt_api.c:5668
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
Definition: rt_api.c:5661
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
Definition: rt_api.c:6005
tuple nband
Definition: pixval.py:52
void rt_raster_set_geotransform_matrix(rt_raster raster, double *gt)
Set raster's geotransform using 6-element array.
Definition: rt_api.c:6026
uint16_t rt_raster_get_height(rt_raster raster)
Definition: rt_api.c:5434
void * rtalloc(size_t size)
Raster core memory management functions.
Definition: rt_api.c:867
void rterror(const char *fmt,...)
Raster core error and info handlers.
Definition: rt_api.c:895
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_api.c:8643
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition: rt_api.c:5353
uint16_t rt_raster_get_width(rt_raster raster)
Definition: rt_api.c:5426

Here is the call graph for this function:

Here is the caller graph for this function: