[gdal-dev] VRTWarpedDataset with ChunkandWarpImage

Even Rouault even.rouault at spatialys.com
Mon Oct 27 16:33:08 PDT 2014


Le mardi 28 octobre 2014 00:16:25, David Olson a écrit :
> Here shortened version of the code...
> 
>   VSIFCloseL(VSIFileFromMemBuffer((*vsifile1).c_str(),
>                                   buf1, FALSE));  // buf1 = RGB JPEG
>   GDALDatasetH hsrc1_ds = GDALOpenInternal((*vsifile1).c_str(),
> GA_ReadOnly, kGdalAllowedDrivers);
>  VSIFCloseL(VSIFileFromMemBuffer((*vsifile2).c_str(),
>                                   buf2, FALSE));  // buf2 = RGB JPEG
>  GDALDatasetH hsrc2_ds = GDALOpenInternal((*vsifile2).c_str(), GA_ReadOnly,
>                            kGdalAllowedDrivers);
> ....  // initialize geo_transform, gdal_warp
> gdal_warp->hSrcDS = hsrc1_ds;
> VRTWarpedDataset *hdst_ds =  (VRTWarpedDataset*)(GDALCreateWarpedVRT(
>       hsrc1_ds, XSize, YSize, &dst_geo_transform[0], gdal_warp));
> gdal_warp->hDstDS = hdst_ds;
> gdal_warp->hSrcDS = hsrc2_ds;
> CPLErr eErr = warp_operation.ChunkAndWarpImage(0, 0,
> GDALGetRasterXSize(hdst_ds),
>                                             GDALGetRasterYSize(hdst_ds));
> GDALClose((GDALDatasetH)hdst_ds);   // "ERROR 6: WriteBlock() not supported
> for this dataset." /band
> ... // Close Source Datasets etc..

Hum, what you attempt to do is really weird and explains the error. You cannot 
use a warped VRT as the *output* of a warping operation. You can only read in 
a warped VRT.

> 
> On Mon, Oct 27, 2014 at 3:41 PM, David Olson <olsond at google.com> wrote:
> > Evan,
> > 
> >   The source and destination data are 3-band RGB so I don't believe that
> > 
> > is the problem...
> > 
> >   However I did define GdalWarp->nDstAlphaBand = 0 with the same result.
> > 
> > Basically getting three
> > 
> >   erorrs - one for each band:
> > ERROR 6: WriteBlock() not supported for this dataset.
> > ERROR 6: WriteBlock() not supported for this dataset.
> > ERROR 6: WriteBlock() not supported for this dataset.
> > 
> > Thanks, David
> > 
> > On Mon, Oct 27, 2014 at 3:21 PM, Even Rouault
> > <even.rouault at spatialys.com>
> > 
> > wrote:
> >> Le lundi 27 octobre 2014 22:42:11, David Olson a écrit :
> >> > Hi,
> >> > 
> >> >   I've set up a c++ code which creates a VRTWarpedDataset from a
> >> >   source
> >> > 
> >> > image then uses ChunkAndWarpImage to warp additional source images and
> >> > create a mosaic with the VRTWarpedDataset destination (hdst_ds).
> >> > 
> >> >  The code is tested and runs fine without memory leak.
> >> >  
> >> >  However I do get an error upon calling GDALClose(hdst_ds) :
> >> >       *ERROR 6: WriteBlock() not supported for this dataset*.
> >> >  
> >> >  GDALClose calls FlushCache which calls WriteBlock.
> >> >  Just wanting to get some insight on this error. And possibly how to
> >> 
> >> avoid
> >> 
> >> > it.
> >> 
> >> David,
> >> 
> >> Difficult to tell without a reproducable snippet. But my guess is that
> >> you have
> >> an issue with setting up alpha band. Perhaps you have not defined
> >> nDstAlphaBand
> >> in the warping options ?
> >> 
> >> Even
> >> 
> >> --
> >> Spatialys - Geospatial professional services
> >> http://www.spatialys.com

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list