godem

package module
v0.0.0-...-d715c16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2023 License: GPL-3.0 Imports: 12 Imported by: 1

README

godem -SRTM HGT Reader and GDAL Interpolation Library

This is an advanced library designed to read Shuttle Radar Topography Mission (SRTM) HGT files and use the Geospatial Data Abstraction Library (GDAL) to perform elevation interpolation. This library aims to simplify the process of acquiring topographic data and translating it into practical, usable formats.

Key Features

  • Caching of Downloads: This feature reduces data redundancy and speeds up the reading process by storing previously downloaded data for future use. The next time you need the same HGT file, it retrieves the data from cache instead of initiating a new download.

  • Resolution Support: The library is compatible with both 30m (1 arc-second) and 90m (3 arc-second) resolution files. This range of resolution support allows for versatility in your topographic data manipulation and visualization.

  • Data Source Support: Our library can extract data from three primary sources:

These diverse sources ensure access to a comprehensive and accurate global topographic data set.

Why Use This Library?

By incorporating GDAL for interpolation, our library brings together two powerful tools for processing and interpreting SRTM HGT files. It does so in a way that minimizes the technical barrier for users and maximizes the accessibility of the data.

Moreover, with caching functionality, the library also ensures efficient use of resources, saving both time and space during subsequent data processing.

Comparison of results with different sources

Original 2023-03-05_09-27_Sun gpx

Source ESA 2023-03-05_09-27_Sun esa

Source GPXSEE 2023-03-05_09-27_Sun gpxsee

Source Viewfinder 2023-03-05_09-27_Sun view

** Make with gpxchart

Usage

package main

import (
	"fmt"

	"github.com/inode64/godem"
)

func main() {
	srtm, err := godem.NewSrtm(godem.SOURCE_ESA)
	if err != nil {
		panic(err.Error())
	}
	elevation, dem, err := srtm.GetElevation(http.DefaultClient, 43.37012643, -8.39114853)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println("A coruña elevation is", elevation)
}

Requirements


NOTE: This library is continuously updated and maintained. Contributions and suggestions for improvements are always welcome!

Documentation

Index

Constants

View Source
const (
	DEM1          = "dem1"
	DEM3          = "dem3"
	DEMURL0       = "http://viewfinderpanoramas.org/"
	DEMURL1       = "http://dem.gpxsee.org/"
	DEMURL2       = "https://step.esa.int/auxdata/dem/SRTMGL1/"
	SOURCE_VIEW   = 0
	SOURCE_GPXSEE = 1
	SOURCE_ESA    = 2
)

Variables

This section is empty.

Functions

func GetElevationFromLocalFile

func GetElevationFromLocalFile(path string, lat, lon float64) (float64, error)

Types

type LocalFileSrtmStorage

type LocalFileSrtmStorage struct {
	// contains filtered or unexported fields
}

func NewLocalFileSrtmStorage

func NewLocalFileSrtmStorage(source int) (*LocalFileSrtmStorage, error)

func (LocalFileSrtmStorage) FileExists

func (ds LocalFileSrtmStorage) FileExists(dem, zip, fn string) (string, error)

func (LocalFileSrtmStorage) IsNotExists

func (ds LocalFileSrtmStorage) IsNotExists(err error) bool

func (LocalFileSrtmStorage) LoadFile

func (ds LocalFileSrtmStorage) LoadFile(dem, zip, fn string) ([]byte, error)

func (LocalFileSrtmStorage) SaveFile

func (ds LocalFileSrtmStorage) SaveFile(dem, zip, fn string, bytes []byte) error

func (LocalFileSrtmStorage) Unzip

func (ds LocalFileSrtmStorage) Unzip(dem, fn string, data []byte) error

type Srtm

type Srtm struct {
	// contains filtered or unexported fields
}

func NewSrtm

func NewSrtm(source int) (*Srtm, error)

func (*Srtm) GetElevation

func (self *Srtm) GetElevation(lat, lon float64) (float64, string, error)

func (*Srtm) GetSrtm

func (self *Srtm) GetSrtm(lat, lon float64) (string, string, string, string)

type SrtmLocalStorage

type SrtmLocalStorage interface {
	// LoadFile loads a file, if not available, then err!=nil and IsNotExists(err) must be true
	FileExists(dem, zip, fn string) (string, error)
	LoadFile(dem, zip, fn string) ([]byte, error)
	IsNotExists(err error) bool
	SaveFile(dem, zip, fn string, bytes []byte) error
	Unzip(dem, fn string, data []byte) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL