# Loading Tif file causing our desktop application to crash

**URL:** <https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291>\
**Category:** WPF\
**Created:** [December 13, 2022, 1:02pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291 "2022-12-13T13:02:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anwar\_Sagar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Anwar\_Sagar](https://community.thinkgeo.com/u/Anwar_Sagar)\
**Post date:** [December 13, 2022, 1:02pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/1 "2022-12-13T13:02:20Z")

</div>

Hello,

We have a tif files with size “8,69 MB” and with “161 MB” which when we try to load it to our WPF application it causes a crash.  
[GoehrdeGesamtNeu](http://www.forstdaten.de/download/goldmann/GoehrdeGesamtNeu.tif)  
and here is the trace log from the crash.

##############################  
Application|GlobalExceptionHandler|System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —\> System.ArgumentException: **The parameter you supplied may not be empty.**  
**Parameter name: ExternalProjection.ProjString**  
at ThinkGeo.Core.ValidatorHelper.CheckStringIsNotNullNorEmpty(String value String parameterName)  
at ThinkGeo.Core.ProjectionConverter.OpenCore()  
at ThinkGeo.Core.ProjectionConverter.Open()  
##############################

Any help would be great!

Big thanks,  
Anwar

---

<div class="post-metadata">

**Author:** ![Kyle\_Day](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/kyle_day/32/25613_2.png) [@Kyle\_Day](https://community.thinkgeo.com/u/Kyle_Day)\
**Post date:** [December 14, 2022, 7:24pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/2 "2022-12-14T19:24:51Z")

</div>

Hey @Anwar_Sagar,

I was able to load up your GeoTiff without issues on my side:

 ![image](https://community.thinkgeo.com/uploads/default/original/3X/7/9/79344d0d1a805a6516eb2ac8f3d27d7cfb9ca190.png)

From the stacktrace, it looks like you are trying to do some reprojection on the geotiff. What internal and external projections were you using?

Thanks,  
Kyle

---

<div class="post-metadata">

**Author:** ![Anwar\_Sagar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Anwar\_Sagar](https://community.thinkgeo.com/u/Anwar_Sagar)\
**Post date:** [December 28, 2022, 9:10am UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/3 "2022-12-28T09:10:01Z")

</div>

Hi @Kyle_Day.

Here are our projection strings:  
internalProjString = @"+proj=longlat +ellps=WGS84 +datum=WGS84 +no\_defs";  
externalProjString = @"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no\_defs";

Please provide us with the internal and external projections that you have used.

Br,  
Anwar

---

<div class="post-metadata">

**Author:** ![Kyle\_Day](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/kyle_day/32/25613_2.png) [@Kyle\_Day](https://community.thinkgeo.com/u/Kyle_Day)\
**Post date:** [January 3, 2023, 5:15pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/4 "2023-01-03T17:15:39Z")

</div>

Hey @Anwar_Sagar,

I didn’t use projection when I first tested the image because I was unsure what projection to use. I’ve since updated it. It looks like you have the projection backwards though. The internal projection is what the GeoTiff is in and the external projection is what you would like to transform it to. So, once I set it this way:

```cs
GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer(@"C:\Users\kyleday\Downloads\GoehrdeGesamtNeu.tif");
geoTiffRasterLayer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(@"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", @"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");

```

You’ll need to use the UnmanagedProjectionConverter class as some projections aren’t supported specifically by us. You might also encounter some skewing issues too when converting from that projection to decimal degree. This is the result:

 ![image](https://community.thinkgeo.com/uploads/default/original/3X/1/6/16f2a79c53e8b1b4fe1740584a7c786ba544bdc8.jpeg)

Thanks,  
Kyle

---

<div class="post-metadata">

**Author:** ![Anwar\_Sagar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Anwar\_Sagar](https://community.thinkgeo.com/u/Anwar_Sagar)\
**Post date:** [January 4, 2023, 8:36pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/5 "2023-01-04T20:36:02Z")

</div>

Hey @Kyle_Day,

Thanks you very much for testing this out.  
Yes, we need to use projection with the map layer otherwise the map is shown in wrong place.  
With the example map file with our guessed projection or with out the projection the map is shows in wrong place, this specific map must be in shown in Germany not in France.  
The projection we used was only for testing, but it seems not the correct one. So we would like to get your help in identifying the correct projection strings for such map so it will be shown in the correct place.

Using the ordered unmanged projection string you provided it is shown in the South Atlantic Ocean.

 ![image](https://community.thinkgeo.com/uploads/default/original/3X/2/2/22abc5d82154805d8985583e12eaf696d49a81ad.png)

It should be somewhere near the red dot.

 ![image](https://community.thinkgeo.com/uploads/default/original/3X/b/e/beea7d8999945fe4427baa2d4a0c60e428293e10.png)

Br,  
Anwar

---

<div class="post-metadata">

**Author:** ![Kyle\_Day](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/kyle_day/32/25613_2.png) [@Kyle\_Day](https://community.thinkgeo.com/u/Kyle_Day)\
**Post date:** [January 5, 2023, 4:24pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/6 "2023-01-05T16:24:36Z")

</div>

Hey @Anwar_Sagar,

Sure, I see that both of those GeoTiffs are in different projections. What is the projection of your base map?

Thanks,  
Kyle

---

<div class="post-metadata">

**Author:** ![Anwar\_Sagar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Anwar\_Sagar](https://community.thinkgeo.com/u/Anwar_Sagar)\
**Post date:** [January 27, 2023, 9:45am UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/7 "2023-01-27T09:45:00Z")

</div>

> [@Kyle\_Day](#):
>
> Sure, I see that both of those GeoTiffs are in different projections. What is the projection of your base map?

Hi @Kyle_Day, this is our projection externalSrid = 3857 and sorry for taking this long to replying to you. The actual problem have been fixed at our side against the older ThinkGeo version, we have not been able to take the latest version 13 into use yet.  
Br,  
Anwar

---

<div class="post-metadata">

**Author:** ![Kyle\_Day](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/kyle_day/32/25613_2.png) [@Kyle\_Day](https://community.thinkgeo.com/u/Kyle_Day)\
**Post date:** [January 30, 2023, 4:38pm UTC](https://community.thinkgeo.com/t/loading-tif-file-causing-our-desktop-application-to-crash/10291/8 "2023-01-30T16:38:42Z")

</div>

Hey @Anwar_Sagar,

That makes sense as to why the GeoTiff shows up in the South Atlantic. Then that means that your GeoTiff’s external projection needs to be set to 3857 instead of 4326.

```cs
GeoTiffRasterLayer geoTiffRasterLayer = new GeoTiffRasterLayer(@"C:\Users\kyleday\Downloads\GoehrdeGesamtNeu.tif");
geoTiffRasterLayer.ImageSource.ProjectionConverter = new UnmanagedProjectionConverter(@"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", @"+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs");

```

Thanks,  
Kyle
