This project has moved and is read-only. For the latest updates, please go here.

SRTM (hgt files) World Elevation Data

Topics: Data Access
Mar 31, 2007 at 4:57 AM
Is it possible to read SRTM hgt files using SharpMap?

I tried searching the discussion but the search seems to be broken, no matter what I search for, even if I search for "Map" I get no results...
Mar 31, 2007 at 7:17 AM

patricker wrote:
Is it possible to read SRTM hgt files using SharpMap?

It is possible to read them with the GDAL raster data provider, which is on the Extensions page.

There is no 3D mesh topology, however - just raster data.
Mar 31, 2007 at 8:38 AM
I got it all setup, added my references, and everything but now I am getting an error.

The type initializer for 'OGR.ogr' threw an exception.

The error happens in this block of code in OgrProvider.cs:
public Ogr(string Filename, int LayerNum)
this.Filename = Filename;

ogr.RegisterAll();Error happens here

_OgrDataSource = OGR.ogr.Open(this.Filename, 0);
_OgrLayer = _OgrDataSource.GetLayerByIndex(LayerNum);

My Code looks like this:
SharpMap.Layers.VectorLayer myLayer = new SharpMap.Layers.VectorLayer("My layer");
myLayer.DataSource = new SharpMap.Data.Providers.Ogr("N15W062.hgt"); This is when the error occurs
myLayer.MaxVisible = 40000;

--End Error--

Any help would be greatly appreciated, thanks in advance.

Mar 31, 2007 at 7:13 PM
Edited Mar 31, 2007 at 7:13 PM
Do you have the FwTools installed?

Volleyknaller has a write up about these here:
Apr 1, 2007 at 3:46 AM
I do have FwTools installed. When I re-read the directions I noticed that it said that the PATH variable does not update immediately. So I tried running my code again and this time it gets past that point.. well by two lines.

New Error:

Object reference not set to an instance of an object.

Same Block of code just two lines down
_OgrDataSource = OGR.ogr.Open(this.Filename, 0);
_OgrLayer = _OgrDataSource.GetLayerByIndex(LayerNum);This is where the error pops up.

--End Error--

When debugging the code I can see that _OgrDataSource is always null, eve after the OGR.ogr.Open command is executed it still remains null.

Thanks allot for your previous reply, any further help would be greatly appreciated.
Apr 2, 2007 at 2:49 AM
It also doesn't seem to matter whether the file exists or not. If I pass in the name of a file that is in the debug directory or I pass in the name of a file that does not exist, either way I get the same error.
Jan 28, 2010 at 4:26 PM

Hi patricker,


Did you find the solution? Have you read a SRTM hgt file?



Kleber Muffato