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

Thomas Sevaldrud thomas at silentwings.no
Mon Jun 15 03:11:03 PDT 2015


Argh, I managed to send it while editing :-)

Anway, input to this code section is the wanted overview level and the
derived scale factors in X- and Y-direction. Output is the vrtDS dataset
that is used in the GDAL Warp api later.

Are there any obvious mistakes I've made here?

I see that in GDAL 2.0 there will be a new class for handling this, the
GDALOverviewDaset. It's a bit early for me to move to 2.0 yet, but maybe I
should just make a similar dataset type in my own project. Would that be
more efficient than going via a VRT?

- Thomas




On Mon, Jun 15, 2015 at 12:07 PM, Thomas Sevaldrud <thomas at silentwings.no>
wrote:

> 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);
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150615/226232d6/attachment.html>


More information about the gdal-dev mailing list