Select to view content in your preferred language

[ArcEngine] [DotNet] How to load .hgt files into a dataset and then elevation layer

4810
12
Jump to solution
03-13-2012 01:25 AM
ManfredLauterbach
Deactivated User
Hi,

Despite some significant time spent searching documentation and reading the ArcGIS online help and forums I still can't find a solution for this.
This thread is a child of : http://forums.arcgis.com/threads/52661-DotNet-Is-it-possible-to-create-an-elevation-Profile-layer-us...

The objective is to create a dataset from a folder containing .HGT files (SRTM data) programatically, and then to create an elevation layer from the dataset .
Is this possible for ArcEngine?

The closest documentation example I have found only refers to .gdb data file under the topic "How to open a terrain dataset" :
IWorkspaceFactory WSFact = new FileGDBWorkspaceFactoryClass(); IFeatureWorkspace FWS; FWS = WSFact.OpenFromFile("C:\\project\\terrain.gdb", 0)as IFeatureWorkspace;


I have tried working with IRasterDataset in a similar manner to opening raster maps but this is obviously not the correct interface to read elevation data?

What namespace must be used to read .hgt files from a file folder (with the intention of creating an elevation layer later)?
Thanks.



UPDATE [1] : Having a look at the Visual Studio DotNet "Map Control Application" Template, the add data dialog provides for 5 different types of data
1) Shape files
2) GeoDatabases
3) Rasters
4) Servers
5) Layers
but these options do not include support for SRTM data - is there a sample / template available which describes how SRTM data can be imported?
0 Kudos
12 Replies
GeorgeFaraj
Frequent Contributor
Much appreciated - thanks for the help thus far.

It seems that the path I'm walking down is not very popular - ESRI undoubtedly wants customers to stick with their flagship products : ArcDesktop, View, Map etc. and customize them only when necessary - instead of using their own SDK to redevelop features.
In our defence I must state that we are upgrading a product which used MapObjects 2.2 - and want to keep functional and interface changes to a minimum.

My bad feeling at this point is that we're still going to be implementing a lot of features ourselves (e.g. terrain profile) if it turns out to be this difficult just to find out how to load STRM data into a data set.


The file loads using the esriControls.ControlsAddDataCommand. (That extension does not show but the file does load.)
0 Kudos
NeilClemmons
Honored Contributor
The following worked for me as far as getting the data into ArcMap.  I wasn't able to figure out how to access the data through a workspace though.

            Dim rasterLayer As ESRI.ArcGIS.Carto.IRasterLayer = New ESRI.ArcGIS.Carto.RasterLayer
            rasterLayer.CreateFromFilePath("E:\Development\N10E012.hgt")
            rasterLayer.Name = "test layer"
            DirectCast(m_application.Document, IMxDocument).FocusMap.AddLayer(rasterLayer)
            DirectCast(m_application.Document, IMxDocument).UpdateContents()


As for having to recreate functionality for your app, be sure to investigate all of the builtin tools that Engine offers as well as the geoprocessing library.  There's quite a bit of functionality there may be something you can use in your app.
0 Kudos
ManfredLauterbach
Deactivated User
Thanks Neil and Charles,

Your success with loading the file prompted me to double check my code again - and to my surprise the problem was exactly what Neil suggested in the first place : the pathname. (so I'm marking that as the solution)

 IRasterWorkspace rasterWorkspace = (IRasterWorkspace)workspaceFactory.OpenFromFile(folderPath, 0); 
  expects a folder path.



 IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset(filename); 
  expects a filename (without path).


One could probably argue that OpenFromFile is misleading (because we're passing a folder path, where the method name is suggesting a filename) - but the documentation does state that the parameter may be either filename or directory. I assume that the forum MVP's have had to suggest this on numerous occasions 🙂
0 Kudos