I'm doing a programming project. It consists of generating a Map (like Google Maps) from height files .HGT

Currently, I can read each file .hgt (each .hgt file have 1201 * 1201 elevation data). For each point I assign a color depending on the elevation. And from this I can generate an image.

My problem Is Not reading the hgt file or generate the image.

To be exact, my problem is to generate the structure of the map and the square projection (by levels). The image below makes it clear what I want to do.

enter image description here

Each tile of each level will have a size of 256px * 256px.

How can I use the .hgt files to create a square projection? (As I said: I'm not an geographic information systems expert)

I have the idea of generate a big image with all .hgt files. After that, I will cut it into into equal pieces of increments of 2^(2x). But the main problem is the square projection...

Additional information: I am not allowed to use third-party software. It is a complete programming project. I have a cluster of 30 machines to do all the work, so you don't have to worry about the calculation power.

  • First of all, I think you should know in which system the height files are projected. Then reproject them (to longitude / latitude as an intermediate step) to Web Mercator. Spherical Web Mercator is a projection that transform polar coordinates on a sphere of 6378137m radius to cartesian coordinates. This is the Mathematical definition from PROJ4 (lambda is longitude and phi is latiude). And this is their GitHub. I hope that helps you in your project. – Gabriel De Luca Jan 22 at 2:32
  • Note that in the Mercator projection, the meridians are vertical lines. In the latitudes a deformation takes place in order to be a conformal projection, in such a way that the loxodromes are seen as straight lines. This deformation tends to infinity at the poles. Google maps is seen as a square because it only represents a range of latitudes. Those that match the +/- PI()*6378137m of y coordinate (something like from 85ºS to 85ºN). – Gabriel De Luca Jan 22 at 3:09
  • Actually I found this info: "The SRTM (.HGT) data is a nonprojected coordinate system. They are provided in geographical (latitude/longitude) coordinates, they are generally unsuitable for most analysis unless the are projected onto a planar coordinate system where the (x,y) units are the same as the elevation units. Each file covers a 1 degree by 1 degree section of the earth's surface". Before I create the PNGs, should I project first? – Xenetrix Jan 22 at 12:16
  • Yes, if you want something to resemble the dimensions, the shapes or the surfaces that the terrain has on the earth. If you are not concerned about retaining the spatial relationship between the objects and their representation, you can consider the polar coordinates as flat, and make a map of flat lon/lat, where lat pixels = 2 * lon pixels is a square. – Gabriel De Luca Jan 22 at 12:24
  • Okis. What I don't understand very well is How to preserve the .hgt elevation when I make the projection to Web Mercator? And how to link it to the new projection. – Xenetrix Jan 22 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.