Return formatted GDAL raster from raster.
1605 GDALDriverH src_drv = NULL;
1606 int destroy_src_drv = 0;
1607 GDALDatasetH
src_ds = NULL;
1609 vsi_l_offset rtn_lenvsi;
1610 uint64_t rtn_len = 0;
1612 GDALDriverH rtn_drv = NULL;
1613 GDALDatasetH rtn_ds = NULL;
1617 assert(NULL != gdalsize);
1624 if (format == NULL || !strlen(format))
1631 rterror(
"rt_raster_to_gdal: Could not convert raster to GDAL MEM format");
1636 rtn_drv = GDALGetDriverByName(format);
1637 if (NULL == rtn_drv) {
1638 rterror(
"rt_raster_to_gdal: Could not load the output GDAL driver");
1640 if (destroy_src_drv) GDALDestroyDriver(src_drv);
1646 cc = GDALGetMetadataItem(rtn_drv, GDAL_DCAP_CREATECOPY, NULL);
1648 vio = GDALGetMetadataItem(rtn_drv, GDAL_DCAP_VIRTUALIO, NULL);
1650 if (cc == NULL || vio == NULL) {
1651 rterror(
"rt_raster_to_gdal: Output GDAL driver does not support CreateCopy and/or VirtualIO");
1653 if (destroy_src_drv) GDALDestroyDriver(src_drv);
1658 RASTER_DEBUG(3,
"Copying GDAL MEM raster to memory file in output format");
1659 rtn_ds = GDALCreateCopy(
1671 if (destroy_src_drv) GDALDestroyDriver(src_drv);
1674 if (NULL == rtn_ds) {
1675 rterror(
"rt_raster_to_gdal: Could not create the output GDAL dataset");
1679 RASTER_DEBUGF(4,
"dataset SRS: %s", GDALGetProjectionRef(rtn_ds));
1685 RASTER_DEBUG(3,
"Done copying GDAL MEM raster to memory file in output format");
1689 rtn = VSIGetMemFileBuffer(
"/vsimem/out.dat", &rtn_lenvsi,
TRUE);
1690 RASTER_DEBUG(3,
"Done copying GDAL memory file to buffer");
1692 rterror(
"rt_raster_to_gdal: Could not create the output GDAL raster");
1696 rtn_len = (uint64_t) rtn_lenvsi;
1697 *gdalsize = rtn_len;
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
#define RASTER_DEBUG(level, msg)
int rt_util_gdal_register_all(int force_register_all)
#define RASTER_DEBUGF(level, msg,...)
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
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.