# Problem with GEOTIFF file

**URL:** <https://community.thinkgeo.com/t/problem-with-geotiff-file/1745>\
**Category:** WinForms\
**Created:** [June 28, 2011, 10:51am UTC](https://community.thinkgeo.com/t/problem-with-geotiff-file/1745 "2011-06-28T10:51:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre-Antoine](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/pierre-antoine/32/24983_2.png) [@Pierre-Antoine](https://community.thinkgeo.com/u/Pierre-Antoine)\
**Post date:** [June 28, 2011, 10:51am UTC](https://community.thinkgeo.com/t/problem-with-geotiff-file/1745/1 "2011-06-28T10:51:31Z")

</div>

Hello&nbsp;everyone,

I've&nbsp;got&nbsp;an&nbsp;issue&nbsp;with&nbsp;the&nbsp;GEOTIFF&nbsp;file&nbsp;extension.&nbsp;When&nbsp;I&nbsp;load&nbsp;a&nbsp;file&nbsp;in&nbsp;the&nbsp;MapSuiteExplorer,&nbsp;it&nbsp;works&nbsp;well.

But&nbsp;when&nbsp;I&nbsp;load&nbsp;it&nbsp;in&nbsp;my&nbsp;application,&nbsp;I've&nbsp;got&nbsp;an&nbsp;exception&nbsp;like&nbsp;that&nbsp;:

`Exception: Parameter is not valid., StackTrace :    at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height)   at ThinkGeo.MapSuite.Core.ManagedGeoTiffRasterSource.x27de45cef66fd62c(Int32 x2434aab1f3e81535, Int32 xd5d735eaa7ef859e, Int32 xf0ca5ed7845b9192, Int32 xf806d545410d90c1, Int32 xdb846c58acdf5e40, Int32 xdf58594ba412eecf)   at ThinkGeo.MapSuite.Core.ManagedGeoTiffRasterSource.x4a80972f7129d9ec(Int32 x2434aab1f3e81535, Int32 xd5d735eaa7ef859e, Int32 xf0ca5ed7845b9192, Int32 xf806d545410d90c1, Int32 xdb846c58acdf5e40, Int32 xdf58594ba412eecf)   at ThinkGeo.MapSuite.Core.ManagedGeoTiffRasterSource.GetImageCore(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.RasterSource.GetImage(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.GeoTiffRasterSource.GetImageCore(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.RasterSource.GetImage(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.GeoTiffRasterSource.GetImageCore(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.RasterSource.GetImage(RectangleShape worldExtent, Int32 canvasWidth, Int32 canvasHeight)   at ThinkGeo.MapSuite.Core.RasterLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)   at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)   at ThinkGeo.MapSuite.Core.GroupLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)   at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)   at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)   at ThinkGeo.MapSuite.DesktopEdition.Overlay.MainDraw(GeoCanvas canvas)   at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1)   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e)   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xe3cee4adb9c72451()   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh(IEnumerable`1 redrawOverlays)   at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()`

That's&nbsp;how&nbsp;I&nbsp;load&nbsp;the&nbsp;file&nbsp;:

`Collection<Layer> layers = new Collection<Layer>();DirectoryInfo di = new DirectoryInfo(GeoTiffFolder);List<FileInfo> files = di.GetFiles().Where(f => f.Extension.ToLower() == EXTENSION_TIF.ToLower()).ToList();foreach (FileInfo file in files){	GeoTiffRasterLayer worldLayer = new GeoTiffRasterLayer(file.FullName);	worldLayer.LibraryType = GeoTiffLibraryType.UnmanagedLibTiff;	worldLayer.UpperThreshold = double.MaxValue;	worldLayer.LowerThreshold = 0;	worldLayer.IsGrayscale = false;	layers.Add(worldLayer);}GroupLayer backgroundLayer = new GroupLayer();foreach (Layer ly in backgroundLayers){	backgroundLayer.Layers.Add(ly);}staticOverlay.Layers.Add(backgroundLayer.Name, backgroundLayer);`

Have&nbsp;you&nbsp;any&nbsp;idea&nbsp;for&nbsp;this&nbsp;exception&nbsp;?

Thanks&nbsp;by&nbsp;advance.

PS&nbsp;:&nbsp;I&nbsp;join&nbsp;you&nbsp;my&nbsp;TIF&nbsp;file&nbsp;:&nbsp;[douchet-pierre-antoine.fr/fi...-tif\_2.zip](http://douchet-pierre-antoine.fr/fichiers/Gers-L2-tif_2.zip)

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 28, 2011, 12:06pm UTC](https://community.thinkgeo.com/t/problem-with-geotiff-file/1745/2 "2011-06-28T12:06:36Z")

</div>

Pierre,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;for&nbsp;the&nbsp;inconvenience,&nbsp;from&nbsp;your&nbsp;code&nbsp;I&nbsp;didn’t&nbsp;find&nbsp;out&nbsp;any&nbsp;problems,&nbsp;however&nbsp;I&nbsp;reviewed&nbsp;the&nbsp;stack&nbsp;track&nbsp;and&nbsp;I&nbsp;found&nbsp;out&nbsp;maybe&nbsp;the&nbsp;problem&nbsp;is&nbsp;from&nbsp;the&nbsp;bounding&nbsp;box&nbsp;of&nbsp;the&nbsp;tif&nbsp;file,&nbsp;did&nbsp;you&nbsp;have&nbsp;a&nbsp;tfw&nbsp;file&nbsp;for&nbsp;your&nbsp;tif&nbsp;file?&nbsp;I’m&nbsp;afraid&nbsp;of&nbsp;the&nbsp;tfw&nbsp;file&nbsp;has&nbsp;invalid&nbsp;bounding&nbsp;box&nbsp;for&nbsp;this&nbsp;tif&nbsp;file.&nbsp;Also&nbsp;I&nbsp;tried&nbsp;to&nbsp;open&nbsp;the&nbsp;link&nbsp;what&nbsp;you&nbsp;posted&nbsp;to&nbsp;download&nbsp;the&nbsp;tif&nbsp;file,&nbsp;but&nbsp;the&nbsp;link&nbsp;cannot&nbsp;be&nbsp;opened&nbsp;properly,&nbsp;if&nbsp;it&nbsp;is&nbsp;possible&nbsp;can&nbsp;you&nbsp;contact&nbsp;ThinkGeo&nbsp;Support&nbsp;to&nbsp;upload&nbsp;your&nbsp;tif&nbsp;file?&nbsp;  
&nbsp;&nbsp;  
&nbsp;In&nbsp;addition,&nbsp;before&nbsp;you&nbsp;upload&nbsp;the&nbsp;file&nbsp;to&nbsp;us,&nbsp;please&nbsp;try&nbsp;to&nbsp;use&nbsp;the&nbsp;GdiPlusRasterLayer&nbsp;to&nbsp;instead&nbsp;of&nbsp;the&nbsp;GeoTiffRasterLayer.&nbsp;However&nbsp;I&nbsp;still&nbsp;want&nbsp;to&nbsp;ask&nbsp;you&nbsp;what’s&nbsp;the&nbsp;version&nbsp;number&nbsp;did&nbsp;you&nbsp;use?&nbsp;The&nbsp;latest&nbsp;version&nbsp;number&nbsp;of&nbsp;development&nbsp;branch&nbsp;is&nbsp;5.0.43.0.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![Pierre-Antoine](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/pierre-antoine/32/24983_2.png) [@Pierre-Antoine](https://community.thinkgeo.com/u/Pierre-Antoine)\
**Post date:** [June 29, 2011, 3:11am UTC](https://community.thinkgeo.com/t/problem-with-geotiff-file/1745/3 "2011-06-29T03:11:48Z")

</div>

Hello&nbsp;Scott,

I&nbsp;use&nbsp;the&nbsp;version&nbsp;4.5.0.0.  
  
I&nbsp;sure&nbsp;that&nbsp;the&nbsp;file&nbsp;is&nbsp;good&nbsp;(and&nbsp;its&nbsp;TWF&nbsp;file)&nbsp;because&nbsp;I&nbsp;can&nbsp;open&nbsp;it&nbsp;in&nbsp;the&nbsp;MapSuiteExplorer.

I&nbsp;found&nbsp;my&nbsp;error.&nbsp;I&nbsp;use&nbsp;several&nbsp;WinformMap&nbsp;in&nbsp;my&nbsp;application&nbsp;and&nbsp;they&nbsp;are&nbsp;trying&nbsp;to&nbsp;load&nbsp;the&nbsp;same&nbsp;TIF&nbsp;files&nbsp;and&nbsp;I&nbsp;think&nbsp;that&nbsp;these&nbsp;files&nbsp;are&nbsp;still&nbsp;in&nbsp;reading&nbsp;mode&nbsp;when&nbsp;I&nbsp;try&nbsp;to&nbsp;load&nbsp;them&nbsp;in&nbsp;a&nbsp;second&nbsp;WinformMap.

Have&nbsp;you&nbsp;any&nbsp;idea&nbsp;how&nbsp;can&nbsp;I&nbsp;avoid&nbsp;this&nbsp;problem&nbsp;?

Thanks.

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [June 29, 2011, 8:38am UTC](https://community.thinkgeo.com/t/problem-with-geotiff-file/1745/4 "2011-06-29T08:38:57Z")

</div>

Pierre,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;see&nbsp;the&nbsp;problem&nbsp;is&nbsp;not&nbsp;from&nbsp;our&nbsp;product,&nbsp;please&nbsp;lock&nbsp;the&nbsp;read&nbsp;process&nbsp;so&nbsp;that&nbsp;when&nbsp;you&nbsp;try&nbsp;to&nbsp;load&nbsp;it&nbsp;on&nbsp;another&nbsp;map,&nbsp;it&nbsp;will&nbsp;not&nbsp;throw&nbsp;this&nbsp;exception&nbsp;and&nbsp;after&nbsp;the&nbsp;read&nbsp;process,&nbsp;then&nbsp;read&nbsp;the&nbsp;it&nbsp;to&nbsp;another&nbsp;map&nbsp;control.&nbsp;Please&nbsp;take&nbsp;a&nbsp;try&nbsp;for&nbsp;this&nbsp;solution.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Scott,
