0

I'm trying to open a vector file using GDAL's C# bindings. However, running the below code keeps returning null instead of a Dataset for some reason for the dataset variable.

I've installed GDAL (v 3.6.4) and GDAL.Native (v 3.6.4). In the setup, I copied the GdalConfiguration.cs code found in C:\..\GDALTest\obj\Debug\net6.0\NuGet\EDE15D71CD0E9DD7D895094E51A5C8004A7F1505\GDAL\3.6.4 into a new MyGdalConfiguration.cs class.

using GdalTest;
using OSGeo.GDAL;

MyGdalConfiguration.ConfigureGdal();
MyGdalConfiguration.ConfigureOgr();


var vectorPath = "C:\\TEMP\\test";
var vectorPath2 = "C:\\TEMP\\test\\someFile.TAB";

// i've tried a few combinations for the below params, but none worked
// Gdal.OpenEx() params: (string utf8_path, uint nOpenFlags, string[] allowed_drivers, string[] open_options, string[] sibling_files)
var dataset = Gdal.OpenEx(vectorPath, 0, null, null, null);

I've spent hours looking through documentation trying to figure this out, but couldn't come up with an answer. It doesn't help that there is no explicit C# documentation and the bindings don't appear to be 1:1 with the C++ docs

utf8_path should accept either a directory or a .tab file according to this: https://gdal.org/drivers/vector/mitab.html. So either vectorPath variable should be valid.

I'm not quite sure what nOpenFlags or the other args are supposed to look like. I think allowed_drivers could be like new string[] { "MapInfo File" }, but if you leave it blank, it should just look through all of the drivers for a compatible one if set to null.

1 Answer 1

2

It turns out the problem was that the input file that I was trying to use is a NativeX file.

After saving it as just a Native file, I was able to get it to run as expected (so far)

It looks like precisely has a separate driver that extends the functionality that I will need to research later: https://support.precisely.com/product-downloads/item/mapinfo-efal-sdk-download/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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