<div dir="ltr">Argh, I managed to send it while editing :-)<div><br></div><div>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.</div><div><br></div><div>Are there any obvious mistakes I've made here?</div><div><br></div><div>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?</div><div><br></div><div>- Thomas</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 12:07 PM, Thomas Sevaldrud <span dir="ltr"><<a href="mailto:thomas@silentwings.no" target="_blank">thomas@silentwings.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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. </div><div><br></div><div>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.</div><div><br></div><div>This is the part of the code that builds the overview VRT. The input dataset is _ds, an</div><div><br></div><div><div><span style="white-space:pre-wrap">               </span>// Create a VRT of the closest matching overlay</div><div><span style="white-space:pre-wrap">          </span>GDALDriver *vrtDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );</div><div><br></div><div><span style="white-space:pre-wrap">          </span>vrtDS = vrtDriver->Create("", ovrW, ovrH, _numBands, _dataType, NULL);</div><div><span style="white-space:pre-wrap">              </span>GDALSetProjection(vrtDS, _srcProjectionWKT.c_str());</div><div><br></div>   <span style="white-space:pre-wrap">ouble geoTransform[6];
                _ds->GetGeoTransform(geoTransform);
                double basePixelSizeX = geoTransform[XFM_PIXEL_SIZE_EW];
                double basePixelSizeY = geoTransform[XFM_PIXEL_SIZE_NS];</span> </div><div><br><div><span style="white-space:pre-wrap">          </span>geoTransform[XFM_PIXEL_SIZE_EW] = scaleX*basePixelSizeX;</div><div><span style="white-space:pre-wrap">         </span>geoTransform[XFM_PIXEL_SIZE_NS] = scaleY*basePixelSizeY;</div><div><span style="white-space:pre-wrap">         </span>vrtDS->SetGeoTransform(geoTransform);</div><div><br></div><div><span style="white-space:pre-wrap">                </span>for(int i = 1; i <= _numBands; i++)</div><div><span style="white-space:pre-wrap">           </span>{</div><div><span style="white-space:pre-wrap">                        </span>GDALRasterBand* srcRootBand = _ds->GetRasterBand(i);</div><div><span style="white-space:pre-wrap">                  </span>GDALRasterBand* srcBand = srcRootBand->GetOverview(overviewId);</div><div><span style="white-space:pre-wrap">                       </span>VRTSourcedRasterBand* vrtBand = (VRTSourcedRasterBand*)vrtDS->GetRasterBand(i);</div><div><span style="white-space:pre-wrap">                       </span>vrtBand->AddSimpleSource(srcBand);</div><div><span style="white-space:pre-wrap">            </span>}</div></div><div><br></div></div>
</blockquote></div><br></div>