terrain50

package
v0.0.0-...-88a5242 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 14 Imported by: 0

README

terrain50

One of the datasets available under OS OpenData. is Terrain 50, which provides elevation data for the whole of the UK, with 0.1 m vertical and 50 m horizontal resolution.

This package provides a way to work with this dataset, giving easy access to elevation data by grid-reference.

The terrain50.Database object represents the data set. To use it, simply download the Terrain 50 "ASCII Grid" dataset, and extract it to a location. Use this location to open the database. The path should be to the directory which contains the data directory:

package main

import (
	"fmt"
	"os"

	"github.com/usedbytes/osgrid"
	"github.com/usedbytes/osgrid/osdata/terrain50"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Println("Provide path to raster data as only argument")
		return
	}

	db, err := terrain50.OpenDatabase(os.Args[1], 10 * osgrid.Kilometre)
	if err != nil {
		panic(err)
	}

	summit, _ := osgrid.ParseGridRef("SH 60986 54375")
	elevation, _ := db.GetFloat64(summit)
	fmt.Printf("Snowdon's summit is at %f m\n", elevation)
}

A tile cache is used (with 16 entries by default), storing the parsed data for the 16 most-recently-used tiles so that queries which are geographically close to each other are fast, and to ensure memory usage doesn't grow unbounded.

The GenerateSurface() function in lib/geometry provides the functionality to query elevation data for a rectangular region.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDatabase

func OpenDatabase(path string, tileSize osgrid.Distance) (osdata.Float64Database, error)

Types

type Database

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

func (*Database) DumpStats

func (d *Database) DumpStats() string

func (*Database) GetData

func (d *Database) GetData(ref osgrid.GridRef) (float32, error)

func (*Database) GetFloat64

func (d *Database) GetFloat64(ref osgrid.GridRef) (float64, error)

func (*Database) GetFloat64Tile

func (d *Database) GetFloat64Tile(ref osgrid.GridRef) (osdata.Float64Tile, error)

func (*Database) GetTile

func (d *Database) GetTile(ref osgrid.GridRef) (osdata.Tile, error)

func (*Database) Precision

func (d *Database) Precision() osgrid.Distance

type Tile

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

func OpenTile

func OpenTile(path string) (*Tile, error)

func ParseASCTile

func ParseASCTile(r io.Reader) (*Tile, error)

func (*Tile) BottomLeft

func (t *Tile) BottomLeft() osgrid.GridRef

func (*Tile) Get

func (t *Tile) Get(ref osgrid.GridRef) (float32, error)

func (*Tile) GetFloat64

func (t *Tile) GetFloat64(ref osgrid.GridRef) (float64, error)

func (*Tile) GridRef

func (t *Tile) GridRef() osgrid.GridRef

func (*Tile) Height

func (t *Tile) Height() osgrid.Distance

func (*Tile) Precision

func (t *Tile) Precision() osgrid.Distance

func (*Tile) String

func (t *Tile) String() string

func (*Tile) Width

func (t *Tile) Width() osgrid.Distance

Jump to

Keyboard shortcuts

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