[gdal-dev] Using OpenEx() in C# with CSV file
Asger Sigurd Skovbo Petersen
asgerpetersen at gmail.com
Fri Oct 27 05:01:42 PDT 2017
Hi Paul,
As it happens I am having the same issue right now.
I am no swig expert at all, but it looks like the vector (OGR) part of the
Dataset is specifically NOT defined for C# see
https://github.com/OSGeo/gdal/blob/75b443c768b9757085c7c0642e575e1417ccf9dd/gdal/swig/include/Dataset.i#L798-L912
It would be nice to know why this is so, and how much work it is to fix it.
Best regards
Asger
On 23 October 2017 at 12:16, Paul Meems <bontepaarden at gmail.com> wrote:
> 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 at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171027/4b3361a6/attachment.html>
More information about the gdal-dev
mailing list