Hi List,

I'm trying to read all fields in a CSV file.
Using this command it is working:
ogrinfo -ro -al -so test.csv -oo X_POSSIBLE_NAMES=Lon* -oo
Y_POSSIBLE_NAMES=Lat* -oo KEEP_GEOM_COLUMNS=NO

Now I need to do this in my C# application.
Because I need to send -00 (open options) I cannot use Ogr.Open(), but I
should use Gdal.OpenEx(), right?
OpenEx returns a Dataset, which I somehow need to convert to an
ogr datasource so I can use GetLayerByIndex(), GetFieldCount()
and GetFieldDefn() but I can't get it to work.

Looking at numerous Python example it seems in Python no conversion is
needed.
This is my C# code:
var openOptions = new[]
{
    "X_POSSIBLE_NAMES", "Lon*",
    "Y_POSSIBLE_NAMES", "Lat*",
    "KEEP_GEOM_COLUMNS", "NO"
};
using (var ds = Gdal.OpenEx(input, 4, null, openOptions, null))
{
    if (ds == null)
    {
        throw new Exception("Can't open OGR dataset: " + input);
    }
    // var layer = ds.GetLayerByIndex(0); <----- COMPILE ERROR
}

Any help is much appreciated.

Thanks,

Paul
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to