tkrajina / go-elevations

SRTM parser for golang
Apache License 2.0
20 stars 5 forks source link

Elevation returns NaN #5

Closed dave closed 1 year ago

dave commented 1 year ago

I'm getting lots of NaNs from this point...

An example:

Lat: 30.404229
Lon: 79.547245

Locals in the debugger at that point are:

row = {int} 714
column = {int} 656
i = {int} 858170
byte1 = {uint8} 128
byte2 = {uint8} 0
result = {int} 32768

Any ideas why?

dave commented 1 year ago
package main

import (
    "fmt"
    "net/http"

    "github.com/tkrajina/go-elevations/geoelevations"
)

func main() {
    srtm, err := geoelevations.NewSrtm(http.DefaultClient)
    if err != nil {
        panic(err.Error())
    }
    elevation, err := srtm.GetElevation(http.DefaultClient, 30.404229, 79.547245)
    if err != nil {
        panic(err.Error())
    }
    fmt.Println("Elevation is", elevation)
}

Output:

[...]
2022/11/23 17:20:22 > http://srtm.kurviger.de/SRTM3//South_America/S56W070.hgt.zip -> S56W070.hgt.zip
2022/11/23 17:20:22 > http://srtm.kurviger.de/SRTM3//South_America/S56W071.hgt.zip -> S56W071.hgt.zip
2022/11/23 17:20:22 > http://srtm.kurviger.de/SRTM3//South_America/S56W072.hgt.zip -> S56W072.hgt.zip
2022/11/23 17:20:22 > South_America
2022/11/23 17:20:22 load contents
2022/11/23 17:20:22 File N30E079.hgt.zip not retrieved => retrieving: http://srtm.kurviger.de/SRTM3//Eurasia/N30E079.hgt.zip
2022/11/23 17:20:26 Written 1755068 bytes to N30E079.hgt.zip
2022/11/23 17:20:26 Loaded 2884802bytes from N30E079.hgt.zip, squareSize=0
Elevation is NaN
dave commented 1 year ago

Aah reading through the documentation it looks like this is a void in the data. I'll close this and work on an interpolation script.

dave commented 1 year ago

Here's a very quick and dirty interpolation algorithm: https://github.com/dave/go-elevations if anyone is interested.