GithubHelp home page GithubHelp logo

dem-reader's Introduction

dem-reader

This library can be used for extracting elevation data from a local GeoTIFF file.

Install

You can install it with NPM (npm install bojko108/dem-reader) or Yarn (yarn add bojko108/dem-reader) and then:

import DemReader from 'dem-reader';

Calculate elevation values

You can calculate elevation values for single points or GeoJSON geometries. Geometries are modified in place, meaning that the elevation value is appended to coordinates array as third element! Following GeoJSON geometries are supported:

Coordinates must be either geographical or in GeoTIFF file's coordinate system. If you pass geographical coordinates, the DEM file must be in UTM35 projection (or in WGS84) as the library supports only this projection for now.

Single points

import DemReader from 'dem-reader';

const file = 'path/to/GeoTIFF/file';
const point = [42.60788543745605, 23.35463742347579];

const dem = await DemReader.fromFile(file);

const elevation = await dem.getElevationForPoint(point, 'EPSG:4326');
// elevation is: 812.4079 meters

GeoJSON geometries

Point

import DemReader from 'dem-reader';

const file = 'path/to/GeoTIFF/file';
const point = {
  type: 'Point',
  coordinates: [23.237647338683313, 42.658865111793808]
};

const dem = await DemReader.fromFile(file);

await dem.calculateElevationForGeometry(point, 'EPSG:4326');
// point is now:
// {
//   type: 'Point',
//   coordinates: [23.237647338683313, 42.658865111793808, 664.9458]
// }

LineString

import DemReader from 'dem-reader';

const file = 'path/to/GeoTIFF/file';
const line = {
  type: 'LineString',
  coordinates: [...]
};

const dem = await DemReader.fromFile(file);

await dem.calculateElevationForGeometry(line, 'EPSG:4326');
// line now has elevation values

MultiLineString

import DemReader from 'dem-reader';

const file = 'path/to/GeoTIFF/file';
const multiLine = {
  type: 'MultiLineString',
  coordinates: [...]
};

const dem = await DemReader.fromFile(file);

await dem.calculateElevationForGeometry(multiLine, 'EPSG:4326');
// multiLine now has elevation values

Dependencies

License

dem-reader is MIT License @ bojko108


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.