ThinkGeo.com    |     Documentation    |     Premium Support

WPF GeoTiff Example

Hi Ethan

Did you mean use MultiGeoRasterLayer class?

Hi Mohamad,

I means you can do that like this:

            string[] files = System.IO.Directory.GetFiles("YourPath");
        foreach (string file in files)
        {
            GeoTiffRasterLayer tiffLayer = new GeoTiffRasterLayer(file);
            myOverlay.Layers.Add(tiffLayer);                
        }

Regards,

Ethan

Hi Ethan,

I already combine all the code and it work, I can get the raster map file from folder without having to add one by one. But when I run it sometimes will appear this trouble “ArgumentOutOfRangeException Class”.

string[] files = System.IO.Directory.GetFiles(@“C:\Users\User\Documents\Visual Studio 2012\Projects\RasterMapViewer\RasterMapViewer\Data”);
foreach (string file in files)
{

            Map1.MapUnit = GeographyUnit.Meter;

            LayerOverlay myOverlay = new LayerOverlay();
            GeoTiffRasterLayer tiffLayer = new GeoTiffRasterLayer(file);
            myOverlay.Layers.Add(tiffLayer);
            tiffLayer.Open();
            Map1.CurrentExtent = tiffLayer.GetBoundingBox();
            tiffLayer.Close();
            Map1.Overlays.Add(myOverlay);

            myOverlay.TileCache = new FileBitmapTileCache(@"C:\Users\User\Documents\Visual Studio 2012\Projects\RasterMapViewer\RasterMapViewer\Data");
        }

Hi Mohamad,

Please move other code out of the loop.

You only need the code to build layer and add them into overlay.

Other code don’t need to be run many times.

And if you met exception, please let us know which code throw it, detail stack information or a sample is welcome.

Regards,

Ethan

Hi Ethan,

It seem after I remove the code out of the loop it does display exception.Thank you. Then how i can layer it with Dted layer so that I can retrieve elevation data from the map?

Hi Mohamad,

It looks I don’t understand your question here, could you please let me know more detail about it?

Regards,

Ethan

Hi Ethan,

Sorry typo. After I remove the other code out of the loop the exception does not occur. Then i want to know how can i add dted layer to this raster map so that i can retrieve elevation data.

Hi Mohamad,

The DTED format is not supported by our map.

You can find which data is supported here: http://wiki.thinkgeo.com/wiki/map_suite_data_format_guide

Regards,

Ethan

Hi Ethan

So there is no other way for me to import Dted format for the map suite? Because my project require me to retrieve elevation data from DTed data. But first how can I retrieve lat long data from the raster map? I try to use this code but it come out with ArgumentOutOfRangeException.

private void tetikusGerak_Loaded(object sender, MouseEventArgs e)
{
//Get the pointshape in world coordinates from screen coordinates.
Point currentPoint = e.GetPosition(Map1);
PointShape worldPoint = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, new ScreenPointF((float)currentPoint.X, (float)currentPoint.Y), (float)Map1.ActualWidth, (float)Map1.ActualHeight);

        string x = worldPoint.X.ToString("f6", CultureInfo.InvariantCulture);
        string y = worldPoint.Y.ToString("f6", CultureInfo.InvariantCulture);
        textBlockSatu.Text = string.Format("Long: {0}, Lat: {1}", DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPoint.X), DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(worldPoint.Y));
    }

Hi Mohamad,

If you understand the format of DTED file, you can write custom function to read data from it.

And for your code, I think your map unit is Meter, so you cannot use DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree API, it only support decimal degree coordinates: -180 < x < 180, -90 < y < 90.

So you should want to convert the worldPoint from meter to decimal degree by our Proj4Projection, as below is a simple sample to show how to convert it.

Proj4Projection proj4 = new Proj4Projection(3857, 4326);
        proj4.Open();
        PointShape point4326 = proj4.ConvertToExternalProjection(point3857);

Regards,

Ethan

Hi Ethan,

I don’t understand the convert method. the number 3857 and 4326 what the use for? and where did I get the numbers?
Please share me an example.

Proj4Projection proj4 = new Proj4Projection(3857, 4326);
proj4.Open();
PointShape point4326 = proj4.ConvertToExternalProjection(point3857);

Hi Ethan,

May i know can i retrieve Dted data by using Fdo extension? How to add the fdo extension to map suite?

Thank you and best regards,

Hi Mohamad,

3857 and 4326 is the projection number, you can learn more about it from some website for example: epsg.io

And I think you don’t need to add Fdo extension manual, if you use target class which need support by Fdo, the package will be referenced by the project. And Fdo extension also don’t support DTED, what’s the special type you want to support via Fdo?

Regards,

Ethan

Hi Ethan,

That means the fdo reference already in map suite?
I going through other forum from thinkgeo. It said by using fdo extension it allow us to use GdalRasterLayer right? And from that I saw that it support Military Elevation Data. I attach the Dted data for your reference if you have any idea, but if either map suite and fdo does not support the Dted data that means i have to find other platform.

Thank you and best regards.

Hi Mohamad,

Thanks for your data and information.

Just like you mentioned, this format is supported by GDAL, but our FDO have a wrapper for the functions, I did some try based on your data but it looks our currently API cannot make this data render correct.

Because the forum and ticket is only for solve common tech problems, your requirement is related with function enhancement, so you should want to contact your sales for professional service.

Regards,

Ethan

Hi Ethan,

Your FDO have wrapper for the functions meaning that it can’t read the Dted file ? or It can display but can’t get the elevation data from Dted file.

Thank you and best regards,

Hi Mohamad,

It means you cannot call FDO directly in our map, we wrap the functions to make it follow our map API design rule, and I make sure not all functions in FDO is created its wrap API in our wrapper.

That’s why I failed to load your DTED data by our currently API.

Maybe our development team can enhancement the wrapper to support DTED, but the possibility is related with further technical investigation. And that’s why I mentioned you can contact sales for professional service, because I don’t have more information about this problem.

Regards,

Ethan

HI Ethan

May i know if ThinkGeo support the projection for the Gdm2000?

Thank you and best regards

Hi Mohamad,

It looks Gdm2000 is a group of projection: http://epsg.io/?q=Gdm2000

If you make sure its epsg id for example we think it’s 4742, then you can open the page http://epsg.io/4742, and found the Export to PROJ.4 in the page.

Now you can pass the string into our Proj4Projection: +proj=longlat +ellps=GRS80 +no_defs

If you hadn’t found the string in this page, you can try to search it in Google.

Of course you can pass the epsg id into our Proj4Projection, but not all id is include in our default list, so get string is better.

Regards,

Ethan

Hi Ethan,

can you share example for proj for wpf platform?

Thank you and best regards,