Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to working with DEM files but have a need to be able to work with SRTM3 DEM files to calculate elevation given a Lat,lon coordinates.

I understand from reading the documentation that the file contains binary data that represents Signed Int16 data that has height in meters.

My question is this, given a file say that has its bottom left corner being -33, 152 and covers 1 degree of lat, long how would do read a location in the file based on a given latitude, longitude point.

So if I had a position that was -33.456 152.434 how do I calculate the position of that height reading in the file?

I have read the file in to memory I just need to work out how to select the correct location in the resulting array.

Hope this makes sense.

Thanks for you help

share|improve this question
Do you have to code from scratch? What's stopping you from using say a GIS package? – R.K. Sep 22 '12 at 5:26
Yes doing it from scratch, mainly as the data will need to be on a website. I have looked at using Google's elevation API but find the usage restrictions are quite light. Also I figured it would be a good challenge. – SCB Sep 22 '12 at 5:30
... or use Try for example:… (the point seems to be in water). – markusN Sep 22 '12 at 19:50

I'm assuming you've loaded it to an array or some similar data structure, correct? A DEM is basically a grid/raster. Your problem now is to map the lon lat coordinates the cells in the grid. As the DEM has a fixed cell size, the precision of your coordinates like say your example

-33.456 152.434

would have to be approximated to match the cells on the raster. Basically, you're doing coordinate conversion. From lon lat to x,y or the cell/pixel addresses.

If you do get tired of trying to do it from scrach, you can try using Sharpmap.

SharpMap is an easy-to-use mapping library for use in web and desktop applications. It provides access to many types of GIS data, enables spatial querying of that data, and renders beautiful maps. The engine is written in C# and based on the .Net 4.0 framework. SharpMap is released under GNU Lesser General Public License.

Happy coding :)

share|improve this answer
Yep So from my understanding the file is 1201 x 1201 grid resulting in an array of 1,442,401 measurements. It is sampled at 3 ac seconds, dont know if that is important? Im just struggling with how to calculate which position I need to read. My current best guess is ((1201 * 0.456) * 1201) + (0.434 * 1201), but that doesn't seem to give the correct value. – SCB Sep 22 '12 at 5:44
Why are you adding btw? Aren't you trying to get an x,y coordinate pair? You have to express the arc seconds in terms of grids. Think of it as coordinate conversion. – R.K. Sep 22 '12 at 5:46
Not sure to be honest, Just been playing around with trying to split a 1 dimensional array into a grid – SCB Sep 22 '12 at 8:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.