1
Vote

Unable to add layers which are very large TIFF files

description

I have been looking at moving our app from using the MapWinGIS OCX over to using DotSpatial. I am using a very large TIFF file for my base map layer and although it works fine in the OCX, it seems to choke DotSpatial.
 
I pulled down the DotSpatial source and the problem seems to be that in DotSpatial.Data, InRamImageData.cs, a Bitmap is used to store the image for the layer. In my case, the size of the image is 28203 x 45794 and something that size can't be stored in a Bitmap.
 
In the Open() method, I modified the line:
 using (Image temp = Image.FromStream(stream)
 
to be:
 using (Image temp = Image.FromStream(stream, true, false)) 
 
to avoid an Overflow exception from the validation of the Image.FromStream, but then it simply dies with a "Parameter is not valid" exception when it reaches:
_myImage = new Bitmap(temp.Width, temp.Height, PixelFormat.Format32bppArgb);
 
So I am left with the thought that perhaps the inability to create the _myImage bitmap means that perhaps the whole approach is not going to work for a file of this size.
 
Anyway, for now I am going to have to drop back to using the MapWinGIS OCX but I do hope that perhaps this can be corrected in the future... especially if this is going to be considered as a replacement for the OCX. If y'all would like to test attempts to get around this I would be happy to test it for you. I'd also be interested in hearing from y'all if you have any ideas about work arounds I can try. Thanks!

comments

fairbanj wrote Jul 18, 2012 at 7:20 PM

I've played a fair amount more with the MapWinGIS OCX and the way it is handling images in memory. After reviewing it I've come to the conclusion that it is hanlding this type of image layer beautifully -- it must be memory mapping the file or something since the memory footprint of the app remains very small throughout even though the TIF file in question is 4GB in size. Performance while panning and zooming around the map was very high with a max memory footprint of about 120 Meg. ESRI's products also handle this file with equivalent ease, but being a comercial product I would expect it from them.

DotSpatial, in contrast, was trying to make an in memory copy of the entire image, which would never work. I am of the opinion now that if DotSpatial is ever going to be something more than a tinker toy in the GIS space this will need to be addressed,

mudnug wrote Jul 18, 2012 at 7:45 PM

Yep, we agree. Do check to see if the Gdal extension is suitable to your task. It was improved recently to deal with larger files. There is still a ways to go on this, however. See http://dotspatial.codeplex.com/workitem/22214

fairbanj wrote Jul 19, 2012 at 2:13 PM

Thanks for the response and the helpful hint :-)