Crate nasadem

Crate nasadem 

Source
Expand description

§NASA Digital Elevation Model (NASADEM)

Load and query NASADEM/SRTM tiles for earth elevation data. NASADEM is a refinement over the original SRTM dataset collected during the STS-99 Space Suttle mission. The file format (.hgt) is identical between the orignal SRTM and NASADEM datasets, and this library handles both transparently.

§Usage

use nasadem::{geo::Coord, Tile};

/// Sample tile included in this repo.
let tile_path = format!(
    "{}/../data/nasadem/1arcsecond/N38W105.hgt",
    env!("CARGO_MANIFEST_DIR")
);

let tile = Tile::load(tile_path).unwrap();

// Query the tile with a absolute geograpic
// coordinates and assert the elevation is 3772 meters.
assert_eq!(
    tile.get(Coord {
        x: -104.993_472_222_222_22,
        y: 38.790_972_222_222_22,
    }),
    Some(3772)
);

// Query the tile with a linear index and
// assert the elevation is 3772 meters.
assert_eq!(tile.get(2_707_976), Some(3772));

// Query the tile with a relative cartesian
// index and assert the elevation is 3772 meters.
assert_eq!(tile.get((24, 752)), Some(3772));

§Helpful Resources:

§Tile Layout

NASADEM height .hgt files use a simple, headerless binary format with no metadata. The only variable parameter—resolution—can be inferred from the file size.

§Example: N51W001.hgt

For this example, a 3-arcsecond resolution tile (1201x1201) might be named N51W001.hgt. In this case, the bottom-left (southwest) corner of the tile is located at 51°N, 1°W. The the non-header values in the following table represent the linear offset of each i16 elevation value in the flat memory array.

Col 0Col 1Col 2Col 3Col 1200
Row 0(52°N, 1°W) 0123(52°N, 0°) 1200
Row 112011202120312042400
Row 224012402240324043600
Row 336013602360336044800
Row 1200(51°N, 1°W) 1441200144120114412021441203(51°N, 0°) 1442400

Note that while NASADEM filenames correspond to the southwest corner of a tile, the first elevation value in a .hgt file is the northwest corner.

§License

This project is licensed under one of the following licenses:

§Contributions

By default, contributions you make to this project are considered dual-licensed under both the Apache 2.0 License and the MIT License, with no additional conditions.

Re-exports§

pub use geo;

Structs§

Sample
A NASADEM elevation sample.
Tile
A NASADEM tile.

Enums§

NasademError
TileIndex
Represents various ways to index into a Tile.

Type Aliases§

C
Base floating point type used for all coordinates and calculations.
Elev
Bit representation of elevation samples.