Return formatted GDAL raster from raster.
1606 GDALDriverH src_drv = NULL;
1607 int destroy_src_drv = 0;
1608 GDALDatasetH
src_ds = NULL;
1610 vsi_l_offset rtn_lenvsi;
1611 uint64_t rtn_len = 0;
1613 GDALDriverH rtn_drv = NULL;
1614 GDALDatasetH rtn_ds = NULL;
1617 assert(NULL != raster);
1618 assert(NULL != gdalsize);
1625 if (format == NULL || !strlen(format))
1631 if (NULL == src_ds) {
1632 rterror(
"rt_raster_to_gdal: Could not convert raster to GDAL MEM format");
1637 rtn_drv = GDALGetDriverByName(format);
1638 if (NULL == rtn_drv) {
1639 rterror(
"rt_raster_to_gdal: Could not load the output GDAL driver");
1641 if (destroy_src_drv) GDALDestroyDriver(src_drv);
1647 RASTER_DEBUG(3,
"Copying GDAL MEM raster to memory file in output format");
1648 rtn_ds = GDALCreateCopy(
1660 if (destroy_src_drv) GDALDestroyDriver(src_drv);
1663 if (NULL == rtn_ds) {
1664 rterror(
"rt_raster_to_gdal: Could not create the output GDAL dataset");
1668 RASTER_DEBUGF(4,
"dataset SRS: %s", GDALGetProjectionRef(rtn_ds));
1674 RASTER_DEBUG(3,
"Done copying GDAL MEM raster to memory file in output format");
1678 rtn = VSIGetMemFileBuffer(
"/vsimem/out.dat", &rtn_lenvsi,
TRUE);
1679 RASTER_DEBUG(3,
"Done copying GDAL memory file to buffer");
1681 rterror(
"rt_raster_to_gdal: Could not create the output GDAL raster");
1685 rtn_len = (uint64_t) rtn_lenvsi;
1686 *gdalsize = rtn_len;
int rt_util_gdal_register_all(int force_register_all)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
GDALDatasetH rt_raster_to_gdal_mem(rt_raster raster, const char *srs, uint32_t *bandNums, int *excludeNodataValues, int count, GDALDriverH *rtn_drv, int *destroy_rtn_drv)
Return GDAL dataset using GDAL MEM driver from raster.
#define RASTER_DEBUGF(level, msg,...)
#define RASTER_DEBUG(level, msg)