[gdal-dev] default for RelativeToVRT field

Michael Sumner mdsumner at gmail.com
Fri Apr 22 17:49:45 PDT 2022


I would like to control the relativeToVRT field by setting it to 0/false,
it seems the only way to do that is to give a non-local or absolute path to
the *output* file, or give an absolute path for the input. .

intif=autotest/gdrivers/data/gtiff/byte_signed.tif
abtif="$(pwd)"/$intif
gdal_translate $intif -of VRT here.vrt
gdal_translate $intif -of VRT /tmp/there.vrt
gdal_translate $abtif -of VRT here_abs.vrt

grep relative here.vrt
      <SourceFilename relativeToVRT="1">a ...
grep relative /tmp/there.vrt
      <SourceFilename relativeToVRT="0">/p ...
grep relative here_abs.vrt
      <SourceFilename relativeToVRT="0">/p ...

It's the same in C++, if 'pszFilename' is relative the value is 1, if
absolute it is 0.

  GDALDataset *poSrcDS = (GDALDataset *)GDALOpenShared(pszFilename,
GA_ReadOnly);

  GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
  GDALDataset *poVRTDS = poDriver->CreateCopy("", poSrcDS, false, NULL,
NULL, NULL);

  const char *xmlvrt = poVRTDS->GetMetadata("xml:VRT")[0];

Is it possible to force GDAL to make the SourceFilename absolute by setting
options? Or is it just a matter of forcing an input path to be absolute?

I'm concerned about cases of relative paths with prefixes, I want to create
in-memory VRT text that *always* has absolute paths for exactly this
CreateCopy("", ) situation with no actual VRT file.

Thank you, Mike



--
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220423/9ceb22bd/attachment.html>


More information about the gdal-dev mailing list