1

I have setup a consol app in C# that uses the GDAL.CORE NuGet, it seems to work fine when converting most of the .shp files I have, however with one .shp file I am getting the error below:

System.ApplicationException: 'EPSG PCS/GCS code 4326 not found in EPSG support files. 
Is this a valid EPSG coordinate system?'

I am using the gcs.csv file below which seems to include this coordinate code = 4326

enter image description here

Also I have setup the path to my gdal-data correctly, so I know its reading my gcs.csv file.

Gdal.SetConfigOption("GDAL_DATA", "C:\\Program Files\\GDAL\\gdal-data");

Do you have any suggestions?

  • What does ogrinfo print about the coordinate reference system of that shapefile? – user30184 Jan 21 at 11:57
  • How can I get ogrinfo in C# code ? this is what I am currently doing string shapefilePath = dataDir + "\\Manchester.shp"; string jsonPath = dataDir + "/output_out_GDALCORE.json"; Gdal.SetConfigOption("GDAL_DATA", "C:\\Program Files\\GDAL\\gdal-data"); OSGeo.OGR.Ogr.RegisterAll(); OSGeo.OGR.Driver shpDriver = Ogr.GetDriverByName("ESRI Shapefile"); DataSource shpDatasource = shpDriver.Open(shapefilePath, 0); – Roberto Luongo Jan 21 at 12:18
  • Use binaries, I just want to see information about the source data and if is looks exceptional. – user30184 Jan 21 at 12:37
  • thanks for prompt reply !!, I just had a look and there is nothing unusual, can't really attach it to this post though, any other suggestions ? – Roberto Luongo Jan 21 at 14:36
  • Make a copy with ogr2ogr ogr2ogr -f "ESRI Shapefile" -a_srs epsg:4326 output.shp input.shp. Does your code show the same exception with the copy? – user30184 Jan 21 at 15:59
1

Issue is sorted after creating a copy of the original shape file and running the conversion against the copied shape file.

C# consol app >> DataSource shpDatasourceCreateCopy = shpDriver.CopyDataSource(shpDatasource, dataDir + "\\CopyTest", new string[0]);

  • Now it might be possible for you to find the real reason for the issue. Something is different in the original than in the copy. – user30184 Jan 22 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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