This project has moved and is read-only. For the latest updates, please go here.

Loading S57 map using sharpmap

Topics: SharpMap Project
Sep 5, 2012 at 11:00 AM

I am developing an application which should read S57 map(.000)

Can any one help me out how to load S57 map to my application using sharpmap.

Sep 5, 2012 at 11:02 AM

I have tried using 

SharpMap.Data.Providers.Ogr(@"D:\Nikhil-GIS\ENC\FL_ENCs\ENC_ROOT\US1GC09M", "AIRARE");

but it is throwing an exception i.e "The type initializer for 'OSGeo.OGR.Ogr' threw an exception" 

Sep 5, 2012 at 3:10 PM

You almost certainly have not set up the FWTools correctly. Please see the HowTo.

Hth FObermaier

Sep 6, 2012 at 11:24 AM

could you let me know how to do it ...... or could you tell me brief procedure 

Sep 6, 2012 at 1:48 PM

Which part of the howto don't you understand?

Sep 7, 2012 at 10:40 AM

after creating config file and adding keys as explained ... 

Still unable to get things sorted..

could you send me patch or application which was earlier build  for loading S57...

I am novice to this..

Sep 7, 2012 at 1:01 PM

did you install FWTools at all?

Sep 8, 2012 at 12:55 PM

May be you need to add


somewhere at OrgProviders.cs (I did it at body "static Ogr()").

By the way, after that WinFormSamples correctly displays MapInfo GeoData.

Feb 25, 2013 at 4:35 PM
Okay I installed FWTools2.4.7 and created the app.conf app.config:
<?xml version="1.0" encoding="utf-8" ?>
<add key="FWToolsBinPath" value="C:\Program Files (x86)\FWTools2.4.7\bin"/>
<add key="FWToolsProjLib" value="C:\Program Files (x86)\FWTools2.4.7\proj_lib"/>
<add key="FWToolsGeoTiffCsv" value="C:\Program Files (x86)\FWTools2.4.7\data"/>
<add key="FWToolsGdalData" value="C:\Program Files (x86)\FWTools2.4.7\data"/>
<add key="FWToolsGdalDriver" value="C:\Program Files (x86)\FWTools2.4.7\plugins"/>

Then in my form:
    private void Form1_Load(object sender, EventArgs e)
        SharpMap.Map mymap = new SharpMap.Map(new Size(1024, 768));
        SharpMap.Layers.VectorLayer vLayer = new SharpMap.Layers.VectorLayer("0");

            vLayer.DataSource = new SharpMap.Data.Providers.Ogr("US1AK90M.000",0); //and Ogr(@"US1AK90M.000", "AIRARE");

        catch (Exception error)
            MessageBox.Show("Damn Failed loading datafile: " + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

        this.pictureBox1.Image = mymap.GetMap();
US1AK90M.000 is in my bin\debug directory

I've added "C:\Program Files (x86)\FWTools2.4.7\bin" to my PATH

Still getting "An attempt was mad to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"

Feb 25, 2013 at 4:39 PM
Tools is 32bit, you need to compile for x86
Feb 25, 2013 at 4:42 PM
Yes debug x86 is how i'm compiling.
Feb 25, 2013 at 6:49 PM
GOT IT! I copied the "gdal\x86" and "gdal\data\s57*.*" to my "bin\Debug" folder and now I get a map! Whew not on to the fun parts ;)
Feb 26, 2013 at 7:50 AM
You are not trying to add FWTools to the current version in Trunk, are you?
If you are using the current version in trunk, you don't need FWTools and all the configuration at all.
Your project needs references to SharpMap, SharpMap.Extensions and you need to add the nuget package GDAL.Native

Hth FObermaier
Apr 5, 2013 at 11:51 AM

I am trying to add S-57 map using the above lines of code.
I am not getting any error as i have added all the required references and also edited the app.config file but the map is not being displayed in MapBox!!

Any suggestion pls!
Apr 5, 2013 at 12:35 PM
There is a sample in the winformsamplesproject, that uses an s-57 dataset. please have a look if that works for you and then find what you do differently