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

3824
12
Jump to solution
03-13-2012 01:25 AM
ManfredLauterbach
Occasional Contributor
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
1 Solution

Accepted Solutions
NeilClemmons
Regular Contributor III
I'm not familiar with that type of data but according to the chart in the link you provided it is a single file with the *.hgt extension.  So, to open it using a raster workspace I would guess that you need to provide the path to the file instead of the path to the folder when opening the workspace.

View solution in original post

0 Kudos
12 Replies
ManfredLauterbach
Occasional Contributor
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009t0000000q000000 shows that STRM data is indeed supported by Raster datasets.
Why the does last line in the code segment below fail with a 'HRESULT = E_FAIL' ComException when the relevant folder contains only valid .hgt files?
      string filePath = @"C:\Elevation Files\srtm";
      IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
      IRasterWorkspace rasterWorkspace = (IRasterWorkspace)workspaceFactory.OpenFromFile(filePath, 0);
0 Kudos
NeilClemmons
Regular Contributor III
I'm not familiar with that type of data but according to the chart in the link you provided it is a single file with the *.hgt extension.  So, to open it using a raster workspace I would guess that you need to provide the path to the file instead of the path to the folder when opening the workspace.
0 Kudos
ManfredLauterbach
Occasional Contributor
No luck there - specifying the filename throws the same exception 😐

This was actually quite a critical requirement we specified when purchasing ArcObjects 10.

Would you be able to confirm whether the supported raster dataset formats mentioned in http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009t0000000q000000 apply to ArcDesktop desktop only?
I'd have to get back to the ESRI product specialist in that case 🙂
0 Kudos
NeilClemmons
Regular Contributor III
Just to make sure the problem isn't something else, is your application binding to a product and checking out a license before you attempt to run this code?  You'd get the same type of error at the same line of code if the application isn't initialized with a proper license.
0 Kudos
ManfredLauterbach
Occasional Contributor
Agreed.
I've successfully tested loading and displaying of tiff files, shapefiles, character symbols (using the tracking layer) and several other features with the same WinForms test application.

Using the following code to authenticate:
      if (RuntimeManager.Bind(ProductCode.Engine))
      {
        licenseController = licenseController ?? new AoInitializeClass();
        esriLicenseStatus licenseStatus = licenseController.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeEngine);
        if (licenseStatus == esriLicenseStatus.esriLicenseAlreadyInitialized ||
          licenseStatus == esriLicenseStatus.esriLicenseCheckedOut)
        {
          result = true;
        }
      }
0 Kudos
NeilClemmons
Regular Contributor III
That looks correct to me.  One thing I would try is to load this data as a layer into ArcMap.  Right click the layer and save it out as a layer file then load the layer file into your map control using IMapControl.AddLayerFromFile and see what happens.
0 Kudos
ManfredLauterbach
Occasional Contributor
Unfortunately I have only been given ArcEngine to work with (EDN) : Our upgrade from MapObjects is very specific to a custom stand alone application - with very specific functionality.
Thus our requirement for being able to manually manipulate data (raster map data, SRTM elevation data, shapefile data, etc), while also benefiting from new features and speed improvements in ArcObjects.
The ESRI marketing consultant assured us that we would be able to do everything we were previously doing with MapObjects, in ArcObjects 10 - in addition to certain new features (such as being able to import SRTM data).

I've tried checking the web quickly for an ArcObjects elevation layer data file, but can't find one - even with the help of all-powerful google. I obviously havn't looked hard enough :j

In the mean time, I'm going to attach one of the SRTM files that I'm trying to work with : N10E012.zip�??
0 Kudos
NeilClemmons
Regular Contributor III
I should have some time later today to see if I can load the data you posted into ArcMap through code.  I don't have a current EDN subscription so I can't try it with an Engine app but the process should be the same.  I'll let you know if I manage to figure it out.
0 Kudos
ManfredLauterbach
Occasional 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.
0 Kudos