[gdal-dev] GDALWarp on a specific overview of a dataset

Even Rouault even.rouault at spatialys.com
Mon Jun 15 07:06:56 PDT 2015


Le lundi 15 juin 2015 15:51:37, Thomas Sevaldrud a écrit :
> When using the same image in GeoTIFF with overviews, it works correctly,
> which may indicate something with the ECW drivers. I suppose it must be
> something triggered by something weird I'm doing though, or else I would
> think that other people would have the same problem.

It is sometimes surprising that some bugs remain unreported for long!

> 
> The weird thing is that if I simply add an extra band to the VRT it works
> with ECW as well... This extra band is never used for anything and has no
> source, but with it, I get the correct image.

Interesting. My guess is that you must hit 
https://trac.osgeo.org/gdal/ticket/5954

> 
> I can't switch to GDAL 2.0 yet, but I'll try to isolate the code from the
> GDALOverviewDataset class and use that instead of the VRT approach, and see
> if that makes any difference.

Latest code from 1.11 branch has the fix for the above ticket.

> 
> - Thomas
> 
> 
> On Mon, Jun 15, 2015 at 12:19 PM, Even Rouault <even.rouault at spatialys.com>
> 
> wrote:
> > Thomas,
> > 
> > 2 suggestions to help narrowing down the issue :
> > - try gdalwarp of GDAL 2.0 that can select the most appropriate overview
> > given the target resolution / raster size
> > - try with the ECW translated as a GeoTIFF to check if it isn't an issue
> > with
> > the ECW driver itself.
> > 
> > Even
> > 
> > > Hi,
> > > 
> > > I am having a bit of trouble with warping a dataset (an ECW file) with
> > > multiple overviews. The base file is huge, so I am selecting the
> > > overview that matches closest to my output resolution and makes an
> > > in-memory VRT
> > 
> > of
> > 
> > > this, consisting of the overview bands of the original image.
> > > 
> > > This seems to only work for some overview levels, and not for others. I
> > 
> > get
> > 
> > > results that appear to be made from the correct sets of colors
> > > basically, but way out of scale and postion. Some times it seems to
> > > work nicely though, so I suspect that there is some memory overwriting
> > > issue or something here.
> > > 
> > > This is the part of the code that builds the overview VRT. The input
> > > dataset is _ds, an
> > > 
> > > // Create a VRT of the closest matching overlay
> > > GDALDriver *vrtDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
> > > 
> > > vrtDS = vrtDriver->Create("", ovrW, ovrH, _numBands, _dataType, NULL);
> > > GDALSetProjection(vrtDS, _srcProjectionWKT.c_str());
> > > 
> > >    ouble geoTransform[6]; _ds->GetGeoTransform(geoTransform); double
> > > 
> > > basePixelSizeX = geoTransform[XFM_PIXEL_SIZE_EW]; double basePixelSizeY
> > > = geoTransform[XFM_PIXEL_SIZE_NS];
> > > 
> > > geoTransform[XFM_PIXEL_SIZE_EW] = scaleX*basePixelSizeX;
> > > geoTransform[XFM_PIXEL_SIZE_NS] = scaleY*basePixelSizeY;
> > > vrtDS->SetGeoTransform(geoTransform);
> > > 
> > > for(int i = 1; i <= _numBands; i++)
> > > {
> > > GDALRasterBand* srcRootBand = _ds->GetRasterBand(i);
> > > GDALRasterBand* srcBand = srcRootBand->GetOverview(overviewId);
> > > VRTSourcedRasterBand* vrtBand =
> > > (VRTSourcedRasterBand*)vrtDS->GetRasterBand(i);
> > > vrtBand->AddSimpleSource(srcBand);
> > > }
> > 
> > --
> > Spatialys - Geospatial professional services
> > http://www.spatialys.com

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


More information about the gdal-dev mailing list