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

GDALRasterLayer Confusion

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Apr 12, 2013 at 9:33 AM
Hi Fellow SharpMappers!

I am trying to display a GEOTIFF file in a map box (using last release source codes v 0.9 as code base).

I have used native GEOTIFF and ESRI TIF/TFW file pairs which load and display fine so long as I am running (debugging) from within VS2010. If I build and compile to MYPROG.EXE and try to run outside of VS2010 (even on my development machine)I get the following exception being thrown (program crashes dialog)...
MYPROG has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.
[Debug] [Close program]
I have the FWTools DLLs in the same folder as the program EXE file. I also have a reference to them in the app.config file thus...
<?xml version="1.0"?>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
        <add key="FWToolsBinPath" value=".\"/>
Note that I am running the EXE from the location/solution folder used by VS2010... I have not moved anything.

I have a distinct feeling it is how the program looks for the FWTools DLLs which may be he problem.

Any ideas?

Thanks in anticipation
Apr 12, 2013 at 10:12 AM
If you do use the latest source code, you must not copy FWTools stuff in your application folder.

We have ditched FWTools for the GDAL nuget package, witch provides access to the GDAL/OGR binaries provided by Tamas Szekeres.
All you need to do is install this gdal package to your application.

Hth FObermaier
Apr 12, 2013 at 11:41 AM


I have done as you said and now get...

Error thrown of "OSGeo.GDAL.GdalPINVOKE"... the code give the user an openFileDialog to select the GEOTIFF (see below)... do I need to add a line or two to get the NuGet package working?
SharpMap.Map myMap = new SharpMap.Map(new Size(400, 300));
/// THIS LINE IS WERE ERROR THROWN    SharpMap.Layers.GdalRasterLayer Tifflayer = new SharpMap.Layers.GdalRasterLayer("GeoTiff", openFileDialog1.FileName);

            mapBox1.Map = myMap;
Apr 12, 2013 at 2:24 PM
Seems I misinterpreted your question, sorry.
But now, that you have done the first step, you might as well take the secondand third too.
  1. For the SharpMap.Extensions project, install the main GDAL package, too.
  2. Update FWToolsHelper, GdalRasterLayer, GeoTransform and Ogr[Provider] from the source (take Branches/1.0/SharpMap.Extensions
Hth FObermaier