[GIS] How to convert ESRI personal geodatabase (.mdb) to shapefile using OGR in C#

cogr2ogrpersonal-geodatabaseshapefile

I have to create a class in C# in which I would like to insert a function that converts an ESRI personal geodatabase, extracting that features it contains in shp using OGR. I looked at library documentation and I saw that ogr2ogr can do the job. It looks to me that this utility is based on the command line. How can I embed its functions in a C# script?

Best Answer

Does the ogr2ogr command work? An easy one would be to run it from C#. Otherwise you can use the C# SWIG bindings, if you can get these for your programming environment with PGeo support.

If you are using GDAL 1.x use OGR_DS_CopyLayer/OGRDataSource::CopyLayer (or whatever it is called in the C# bindings). Or if you are using GDAL 2.x, use GDALDatasetCopyLayer.

The idea is you open a PGeo dataset/layer, create/open a shapefile dataset, then copy the layer(s) (i.e. shapefile) between the two.