1

According to GDAL's official site, GDAL 2.1 OGRDataSource class is deprecated and GDALDataset should be used. Methods like OGR_DS_GetLayerByName should be replaced by GDALDatasetGetLayerByName().

Now in GDAL for C#, latest 2.1.0 version, I cannot find this new methods in the Gdal.Dataset class.

Where did they go?

1 Answer 1

3

You've referenced the C++ API, but the functions you've listed are in the C API.

The C# API does mirror the C++ API, so instead of looking for the GDALDatasetGetLayerByName function, you need to be using the GDALDataset::GetLayerByName function on the GDALDataset class.

An example of this is given in the the GDAL C# bindings examples, such as OGRLayerAlg (starting at line 76):

DataSource ds1 = Ogr.Open(args[1], 0);
/* ... */
Layer layer1 = ds1.GetLayerByName(args[2]);
2
  • (damned Enter Key!) I know there is not a direct name mapping. What I am trying to say is that in C++, in class Dataset, you have classes like GetLayerByName and GetLayerCount, but there is no call for this methods in C#. On the other hand Ogr.DataSource class is deprecated and we should start using Gdal.DataSet classes, so I am stuck! Thank you!
    – hugomau
    Commented Oct 25, 2016 at 8:01
  • Putting things clearer. the method you are calling in the example (GetLayerByName) is deprecated for version 2.1.1. As an alternative the documentation states that one should use 'Gdal.Dataset.GetLayerByName'. Now in C# this methods are not implemented. This is my problem. Thank you
    – hugomau
    Commented Oct 26, 2016 at 8:05

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.