Configuring Gdal

Topics: Español, General Topics, SharpMap Project, SharpMap v0.9 / v1.x
Mar 17, 2011 at 8:26 AM


I want to configure Gdal in a SharpMap Project. I followed the steps explained in: but does not work.

Someone has any idea more?


Mar 17, 2011 at 9:51 AM

Here my simple piece of code:

public partial class Form1 : Form
        //--> Define the SharpMap object
        SharpMap.Map _sharpMap;  
        //--> Set the zoom factor percentage
        const float ZOOM_FACTOR = 0.3f;
        //--> Define the data name and source
        const string DATA_NAME = "Catalu�a";
        const string DATA_PATH = @"E:\SLUPH\Mapas\250000\a.SID";

        public Form1()

            //--> Initialize the map
            _sharpMap = new SharpMap.Map(new Size(700, 450));
            _sharpMap.BackColor = Color.White;

            SharpMap.Layers.GdalRasterLayer MapLayer = new SharpMap.Layers.GdalRasterLayer(DATA_NAME, DATA_PATH);

            //--> Zoom the map to the entire extent


        private void RefreshMap()
            //--> Use SharpMap to generate the map image
            picMap.Image = _sharpMap.GetMap();

Error: An exception occurred in the type initializer 'SharpMap.Layers.GdalRasterLayer'

I am using FwTools 2.4.7 and SharpMap-0.9-Trunk-2010.10.21

Mar 20, 2011 at 8:02 PM

Hello javiermorata, please download the source and compile sharpmap yourself.

In order to get gdal working, you need to follow these steps.

Hth FObermaier

Mar 22, 2011 at 10:33 AM

Thanks again FObermaier, now works fine.