Out of memory exception while loading GeoTiff

Nov 12, 2010 at 10:45 AM
Edited Nov 12, 2010 at 11:17 AM

I am trying to run the sample application and loading a tiff file of size 4.5 MB and I am getting this error - Out of Memory. on 

	     /// <summary>
        /// Opens the file, assuming that the fileName has already been specified using a Dot Net Image object
        /// </summary>
        public override void Open()
        {
            if (_myImage != null) _myImage.Dispose();
            Image temp = Image.FromFile(Filename);

I am new to DotSpatial, I tried loading the file in mapwindow application and it works fine there. Any help is appreciated. 

 

 

Nov 12, 2010 at 10:55 AM

Have you tried with the latest build and TestForm.exe? I use latest build it to load very large TIFF images, larger than 200MB using GDAL extension, but it should work even without it in case of images small as 10MB, I think. Here is one similar topic.

http://dotspatial.codeplex.com/Thread/View.aspx?ThreadId=226170

Dragan

Developer
Nov 12, 2010 at 4:00 PM
GeoTiff cannot be read by the standard Microsoft .Net image reader unfortunately. Something about the tags doesn't work well with it. So in order to read them you will need to be using the GDAL extension. I have renamed the test viewer as "DemoMap" and it is located with the source code. To allow your project to use the GDAL plugin, you need to first drag and drop an AppManager onto your form. (possibly ApplicationManger, I forget which). Anyway, that will automatically enable the data extensions to become active from the "Data Extensions" directory. Copy and paste all the files from the GDAL subfolder in the Data Extensions directory it a subfolder within the DataExtensions in your own project. Folder depth shouldn't matter, and only the name of the "Data Extensions" folder matters, and keeping the unmanaged dll libraries at the same depth as the "DotSpatial.Data.Rasters.GdalExtension.dll". The name of the subfolder being used can be changed via the ApplicationManager.DataManger. If you want to make the GDAL files appear in the correct place whenever you build your project output, I recommending adding them all to an appropriate subfolder in the project solution explorer. Then open up the properties on them and set the build action to "content" and the "copy behavior" or something to "copy if newer". This will allow you to have the required dependencies when you update your build path without having to do a lot of file wrangling.

Ted


On Fri, Nov 12, 2010 at 2:55 AM, dragandm <notifications@codeplex.com> wrote:

From: dragandm

Have you tried with the latest build and TestForm.exe? I use latest build it to load very large TIFF images, larger than 200MB using GDAL extension, but it should work even without it in case of images small as 10MB, I think. Here is one similar topic.

http://dotspatial.codeplex.com/Thread/View.aspx?ThreadId=226170

Dragan

Read the full discussion online.

To add a post to this discussion, reply to this email (DotSpatial@discussions.codeplex.com)

To start a new discussion for this project, email DotSpatial@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Nov 15, 2010 at 10:35 AM

Thanks Shade1974, I was able to load the GeoTiff file of around 10MB but I can't load file of around 1.72GB. I was able to load the same file in MapWindow Desktop application. I wonder if you could give me some clue about it.

I followed the steps as described above but with some minor changes. I would list down the steps, which may help other developers. 

1. Open the MainForm in design mode from the demo project (DemoMap / Testviewer), check if the AppManager1 instance exist on the form otherwise drag AppManager from DotSpatial.Controls.Components to the Form. 

2. Create a folder "Data Extensions" under the DemoMap project. 

3. Copy folder "DotSpatial.Data.Rasters.GdalExtension" from DotSpatial.Data.Raster.GdalExtension project to Data Extension DemoMap project. 

4. Build project DotSpatial.Data.Rasters.GdalExtension. 

4. In DemoMap add reference to DotSpatial.Data.Rasters.GdalExtension and DotSpatial.Projections project. 

5. In DemoMap add referenec to gdal_csharp.dll from /Data Extensions/DotSpatial.Data.Rasters.GdalExtension folder in the demo project. 

Build and run the application. It will be able to load GeoTiff files and display accordingly.