srtm

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

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 6 Imported by: 0

README

SRTM Library

Introduction

The Shuttle Radar Topography Mission (SRTM) was a NASA mission to provide digital elevation data for the entire world. The data is free and available for use by anyone. A good place to find data is on this website.

This library provides simple functions to read and convert SRTM data. Both the SRTM1 and SRTM3 data are supported.

Usage

image.go provides simply functions to convert the SRTM data files to Go's image implementation, which can be processed further.

Commands

The cmd subdirectory contains simple scripts to convert the SRTM data to gray scale images directly.

Docs

The docs subdirectory contains NASA's SRTM documentation, which can currently be found on the Web Archive as the webpage does not exist anymore.

N48E12

Documentation

Index

Constants

View Source
const (
	SRTM1Format = SRTMFormat(iota)
	SRTM3Format
)
View Source
const (
	SRTM1Size = 3601
	SRTM3Size = 1201
)

Variables

View Source
var ErrIndexOutOfBounds = errors.New("index out of bounds for SRTM image format")
View Source
var ErrPointOutOfBounds = errors.New("point out of bounds for SRTM image format")
View Source
var SRTMByteOrder = binary.BigEndian

Functions

func CoordinatesToIndex

func CoordinatesToIndex(point image.Point, format SRTMFormat) (int, error)

CoordinatesToIndex converts x,y coordinates to an index into the data array for the given SRTMFormat.

func IndexToCoordinates

func IndexToCoordinates(index int, format SRTMFormat) (image.Point, error)

IndexToCoordinates converts an index into the data array of a SRTMImage with the given format to x,y coordinates.

func IsIndexInBounds

func IsIndexInBounds(index int, format SRTMFormat) bool

IsIndexInBounds returns true if the given index is inside the data array of the given SRTMFormat.

func IsPointInBounds

func IsPointInBounds(point image.Point, format SRTMFormat) bool

IsPointInBounds checks if the given point is inside the data array of the given SRTMFormat.

Types

type SRTMFormat

type SRTMFormat int

func (SRTMFormat) Size

func (f SRTMFormat) Size() int

func (SRTMFormat) String

func (f SRTMFormat) String() string

type SRTMImage

type SRTMImage struct {
	Data   []int16
	Format SRTMFormat
}

func NewSRTMImage

func NewSRTMImage(r io.Reader, format SRTMFormat) (*SRTMImage, error)

func (*SRTMImage) ElevationAt

func (srtmImg *SRTMImage) ElevationAt(point image.Point) (int16, error)

ElevationAt returns the elevation value at the given coordinates.

func (*SRTMImage) ElevationMean

func (srtmImg *SRTMImage) ElevationMean() int16

ElevationMean returns the mean elevation value. Overflows as well as voids are mitigated. Thus may not be the actual mean.

func (*SRTMImage) ElevationMinMax

func (srtmImg *SRTMImage) ElevationMinMax() (min int16, max int16)

ElevationMinMax returns the minimum and maximum elevation values. Data voids are ignored and not interpreted as minimum. Values may be erroneous, because of other invalid data.

func (*SRTMImage) ElevationPercentile

func (srtmImg *SRTMImage) ElevationPercentile(percentile float64) int16

ElevationPercentile returns the nearest-ranked percentile of the elevation values. Percentile must be between 0 and 1. Data voids are not ignored and part of the percentile calculation.

func (*SRTMImage) ElevationVoids

func (srtmImg *SRTMImage) ElevationVoids() []image.Point

DataVoidIndices returns points of all voids in the srtmImage. Data voids are represented by the value -32768 as per the SRTM documentation.

func (*SRTMImage) FullImage

func (srtmImg *SRTMImage) FullImage() *image.Gray16

FullImage returns the full data range as a 16 bit-depth grayscale image. This preserves the original data completely and allows for further processing.

Please note that some image viewers are not able to display 16 bit images. In many cases, the image will be displayed as a 8 bit image or will be displayed incorrectly.

func (*SRTMImage) HeightCenteredImage

func (srtmImg *SRTMImage) HeightCenteredImage(height int16) *image.Gray

HeightCenteredImage centeres the elevation data to the provided elevation value. No scaling is applied. The center value corresponds to the value of 128 in the resulting image. Smaller values are darker, larger values are brighter. If there are values too large or too small, these values will be set to white or black, respectively. Values may be erroneous, because of voids or other invalid data.

func (*SRTMImage) MeanCenteredImage

func (srtmImg *SRTMImage) MeanCenteredImage() *image.Gray

MeanCenteredImage centeres the elevation data to the mean elevation value. No scaling is applied. The calculated mean value corresponds to the value of 128 in the resulting image. Smaller values are darker, larger values are brighter. If there are values too large or too small, these values will be set to white or black, respectively. Values may be erroneous, because of voids or other invalid data.

func (*SRTMImage) ScaledHeightImage

func (srtmImg *SRTMImage) ScaledHeightImage(factor, centerHeight int16) *image.Gray

ScaledHeightImage returns a grayscale image with the elevation data scaled to the provided factor. The factor determines how many meters are represented by one brightness value. The center height determines the elevation value that corresponds to the brightness value of 128.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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