ThinkGeo.com    |     Documentation    |     Premium Support

How to Load a Satellite Image?

Hi,


I have an image with [1KM x 1KM]. this image is:


TIF.with all related files: hdr, jgw, and tfw.


I did apply this code:


___________




winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
GdiPlusRasterLayer worldImageLayer = new GdiPlusRasterLayer(@"D:\TesSolution\image.tif");
worldImageLayer.UpperThreshold = double.MaxValue;
worldImageLayer.LowerThreshold = 0;
worldImageLayer.IsGrayscale = false;
LayerOverlay ImageOverlay = new LayerOverlay();
ImageOverlay.Layers.Add("WorldImageLayer", worldImageLayer);
winformsMap1.Overlays.Add(ImageOverlay);
winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);
winformsMap1.Refresh();



But the result I just get the blue empty color.


but if I use the World.tif, wich comes with SampleData, I get the World.tif?


Where is the problem in my loading for the image.tif?


 


Kind Regards,


Bandar


 


 


 



Hi Bandar,


Thanks for your post. We need to clarify some information with you to solve this issue;
 
1.       Are you sure your Tif data is in WGS 84 coordinate system? If not, you could not set the map unit to decimal degree.
2.       You should also make sure that the current extent of your data is “-118.098, 84.3, 118.098, -84.3”.
3.       We also have a class called GeoTiffRasterLayer which is used to handle the GeoTiff data specifically, could you please have a try using this class? The code could be like this:

GeoTiffRasterLayer worldImageLayer = new GeoTiffRasterLayer(@"..\..\SampleData\Data\world.tif");
worldImageLayer.UpperThreshold = double.MaxValue;
worldImageLayer.LowerThreshold = 0;
worldImageLayer.IsGrayscale = false;

 
Any more information is appreciated.
 
Thanks,
 
Sun

Bandar,



  To check if the bounding box is right is you can get it from the layer itself.  Once you load the GeoTiffRasterLayer you can call the worldImageLayer.GetboundingBox() and verify that you are zooming into the right area.  Before you make the call make sure to call the Open first.



David




  worldImageLayer.Open();
  RectangleShape boundingBox = worldImageLayer.GetBoundingBox();
  worldImageLayer.Close();
 



Thank you Sun & David, 

1- I checked the TIF file and it is end with WGS84. so the TIF file is OK. 

2- my code now is: 

 


winformsMap1.MapUnit = GeographyUnit.DecimalDegree;


winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);


GeoTiffRasterLayer worldImageLayer = new GeoTiffRasterLayer(@"D:\TesSolution\image.tif"); //Not Working :( even I copied to the folder


//GeoTiffRasterLayer worldImageLayer = new GeoTiffRasterLayer(@"D:\TesSolution\World.tif"); //Working I copied World.tif in the folder


worldImageLayer.UpperThreshold = double.MaxValue;


worldImageLayer.LowerThreshold = 0;


worldImageLayer.IsGrayscale = false;


worldImageLayer.Open();


RectangleShape boundingBox = worldImageLayer.GetBoundingBox();


worldImageLayer.Close();


LayerOverlay ImageOverlay = new LayerOverlay();


ImageOverlay.Layers.Add("WorldImageLayer", worldImageLayer);


winformsMap1.Overlays.Add(ImageOverlay);


winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);


winformsMap1.Refresh(); 




By the way I am using the "Map Suite Desktop Evaluation Edition 3.0" because the download center is broking and I could not download the official suite? 

Does this make proplem of using the above code?


Kind Regards,

Bandar



Bandar,


I saw that you didn’t set the bounding box of your tiff image to the CurrentExtent of the map control from the code snippet. Could you please have a try using the bounding box? You just need to modify one line of your code from
 

winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);

 
to
 

winformsMap1.CurrentExtent = boundingBox;


 
Any more questions please let us know.
 
Thanks,
 
Sun

Yes! It is working right now! Many thanks!  
  
 But is there ability to add fuction to display the loading progress depending to the image size? i.e: if the image is lag a progress bar to the % of loading? or I need to estimate this time regarding to the image size?  
  
 Regards, 
 Bandar

Bandar, 
  
 I am glad that it’s working with your code. 
  
 After did some research for your new requirement, I am afraid that we don’t support this kind of function so far, sorry for inconvenience. 
  
 The investigation is still going on, if you have any insights might help please let us know. 
  
 Thanks 
 James