https://github.com/watergis/terrain-rgb
This module is to get elevation from terrain RGB / terrarium tilesets by longitude and latitude.
https://github.com/watergis/terrain-rgb
elevation terrain-rgb terrarium
Last synced: about 1 month ago
JSON representation
This module is to get elevation from terrain RGB / terrarium tilesets by longitude and latitude.
- Host: GitHub
- URL: https://github.com/watergis/terrain-rgb
- Owner: watergis
- License: mit
- Created: 2020-12-13T10:46:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-14T01:34:45.000Z (4 months ago)
- Last Synced: 2025-04-22T04:09:44.307Z (about 1 month ago)
- Topics: elevation, terrain-rgb, terrarium
- Language: TypeScript
- Homepage: https://watergis.github.io/terrain-rgb/
- Size: 564 KB
- Stars: 18
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# terrain-rgb

[](https://www.npmjs.com/package/@watergis/terrain-rgb)

This module is to get elevation from terrain RGB tilesets by longitude and latitude.
## Install
```
npm i @watergis/terrain-rgb
```## demo
[code sandbox](https://codesandbox.io/s/terrain-rgb-g4nym)
## Usage
This module can be used for PNG or WEBP terrain RGB tilesets.
```ts
import { TerrainRGB } from "@watergis/terrain-rgb";const url = "https://wasac.github.io/rw-terrain/tiles/{z}/{x}/{y}.png";
const trgb = new TerrainRGB(url, 512);const elevation = await trgb.getElevation([30.0529622, -1.9575129], 15);
console.log(elevation);
```TMS(Tile Map Service) tiles are also supported with
```ts
const trgb = new TerrainRGB(url, 512, 5, 15, true);
```If it can't find tile, it will return 404 error.
If its terrain RGB tilesets was resampled by gdal2tiles, the result of elevation might not be the same with original DEM image.
If you want to use `terrarium` DEM, use `Terrarium` class as follows.
```ts
import { Terrarium } from "@watergis/terrain-rgb";
```both `png` and `webp` formats are supported by the library.