SharpMap and tif who are georeferenced

Aug 18, 2011 at 10:53 PM

I have tif images that are georeferenced. There are file .aux and .tfw with the same name as each tif file.
My question is how can i use this georeferenced image in Sharmap with my different shapefile.
thank you

Aug 19, 2011 at 5:38 AM

If you reference, the SharpMap.Extentions project you get some extra layers in sharpmap, among others the GdalRasterLayer..


Then you can do:
layer = new SharpMap.Layers.GdalRasterLayer("GeoTiff", relativePath + "utm.tif");                        


Se the GdalSample in the WinformsSamples project.


Aug 26, 2011 at 10:26 AM

I answer later because I was unavailable.

It works, but I can display only one tiff. When I want to add another tiff I have the exception  'SharpMap.Layers.DuplicateLayerException'.
Also when I add to tiff  a vectors layers , the tiff disappears.

In fact what I wanted, it display multiple tiff files at the same time in addition to many vectors layers

Aug 26, 2011 at 12:35 PM

To display multiple tiff, I solved the problem. In fact I kept the same name for the layer, so it sent me an error.
For the display of my tiff and my other layers, I have the same display with ArcMap. The problem is therefore my data. My coordinated differ too much.
thank you

Oct 10, 2013 at 11:45 AM

i tried the same, loading a tif/tfw by layer = new SharpMap.Layers.GdalRasterLayer(...). In my app i get the error

"typeinitialyzer has caused an exception"

in WinFormSamples trying to load the same tif-file results in

"'<filename>' does not exist in the file system, and is not recognised as a supported dataset Name"

the exception is thrown in

public GdalRasterLayer(string strLayerName, string imageFilename)
_gdalDataset = Gdal.OpenShared(Filename, Access.GA_ReadOnly);
Oct 10, 2013 at 1:28 PM
The exception you are getting is due to an incomplete setup of GDAL.
You need to reference the GDAL.Native package from the NuGet stream.