1

I have previously asked this question on stack overflow, and am now asking this more specialized audience.

I'm wondering why the GDAL C# library (v2.3.3) call to Gdal.wrapper_GDALBuildVRT_names(...) does not produce a physical destination VRT file.

When I issue the equivalent command in the OSGeo4W shell (to combine the 0000a013.gn1 and 0000b013.gn1 files), a VRT file is written to the supplied destination path (C:\Temp\z7_x43_y43.vrt):

gdalbuildvrt C:\Temp\z7_x43_y43.vrt F:\gnc\1\0000a013.gn1 F:\gnc\1\0000b013.gn1

However, when I issue the command in C#, no VRT file is written to the supplied destination path (I've made sure the folder exists and that the file isn't already there):

GdalConfiguration.ConfigureGdal();

var vrtFile = @"C:\Temp\z7_x43_y43.vrt";
var aeroFiles = new List<string>();
aeroFiles.Add(@"F:\gnc\1\0000a013.gn1");
aeroFiles.Add(@"F:\gnc\1\0000b013.gn1");

var vrtOptions = new GDALBuildVRTOptions(new [] { "-overwrite" });
var vrt = Gdal.wrapper_GDALBuildVRT_names(vrtFile, aeroFiles.ToArray(), vrtOptions, null, null);

The *.gn1 files are NITF, WGS84, degree unit files that work fine in other respects (e.g., the OSGeo4W command processes them perfectly).

The resulting vrt instance is correct - I can use it as a Dataset in other parts of my code, and can even cut PNG tiles from it doing something like this (pngFile and translateOptions are defined elsewhere):

Gdal.wrapper_GDALTranslate(pngFile, vrt, new GDALTranslateOptions(translateOptions.ToArray()), null, null);

But why is no VRT file ever written to disk? We have to supply a destination path (vrtFile), so doesn't that imply a destination file will be written?

0

You can try

var vrt = Gdal.wrapper_GDALBuildVRT_names(vrtFile, aeroFiles.ToArray(), vrtOptions, null, null); vrt.FlushCache(); - it might can help you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.