ndvi-gee

Get the land images, apply the NDVI filter, take the image with few clouds and be happy.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
ndvi-gee
1.0.3-beta2 years ago3 years agoMinified + gzip package size for ndvi-gee in KB

Readme

ndvi-gee
ndvi-gee is a TypeScript library for acquiring NDVI (normalized difference vegetation index) images with few clouds from a satellite database from Google Earth Engine and it returns a promise fulfilled with an object of interesting data.

maintenance npm version License: MIT downloads

Table of Contents

- Parameters - Return Values

Quick Start

ndvi-gee uses geometry system to crop a satellite image, and calculate the size of the image acquired from Google Earth Engine (GEE) using a given image width in pixels, and returns an object with many interesting data.
// Import the library, define your `devKey` with the `Private Key`:
const devKey = require('YOUR PRIVATE KEY');

// Define a polygon like:
const polygon = [
  {
    lat: 27.888807653809973,
    lng: -80.62262288406416
  },
  {
    lat: 27.866105444225745,
    lng: -80.62282725565235
  },
  {
    lat: 27.866415627190747,
    lng: -80.67262206251358
  },
  {
    lat: 27.889321367722737,
    lng: -80.67230056069523
  }
];

// Define the width of the polygon area in pixels:
let width = 500;

// Finally, define the dateStart and dateEnd:
let dateStart = 1617753600000;
let dateEnd = 1620518400000;

// Call the following function:
ndviGee.ndviGen(devKey, polygon, width, dateStart, dateEnd).then((result) => {
  console.log(result.img_url);
});

Image example

example

Quick Start ndvi image example


Installation

Install with npm:
npm install ndvi-gee

To use with node just import the module:
const ndviGee = require('ndvi-gee');

Usage

ndvi-gee acquires NDVI images with few clouds from Google Earth Engine and gives a promise with an object of interesting data.
The library uses the Google Earth Engine for acquiring the NDVI image of a region of longitude and latitude coordinates.
It is necessary passing the private key as parameter to the function. See Private key authentication.

Parameters

You can call the following function:
ndviGee.ndviGen(devKey, polygon, width, dateStart, dateEnd).then((result) => {
  // Your code here
});

The parameters are described as:
| Param | Type | Description | | --------- | ------------------- | -------------------------------------------------------- | | devKey | Object | The JSON content of private key. | | polygon | Array<Object> | The longitude and latitude coordinates of a given map. | | width | Number | The width of an image in pixels. | | dateStart | Number | The first date in timestamp of an image collection date. | | dateEnd | Number | The last date in timestamp of an image collection date. |

Return Values

The function returns a promise that is fulfilled with an object containing:
| Param | Type | Description | | ---------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | width | Number | The width of an image in pixels. | | height | Number | The height of an image in pixels normalised by the given width. It is an rounded integer number. | | centroid | Object | The centroid or geometric centre of a plane figure. It is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. | | bounds | Array<Object> | Corners of the bounding box of the polygon. | | timestart | Number | It is set to the nominal composite start period for temporal composites. It is a timestamp number format. | | timeend | Number | The ending timestamp is set to the nominal image acquisition time for single scenes. It is set to midnight on the day after the nominal composite end period for MODIS temporal composites. | | index | String | The image index given by the satellite system. | | imgurl | String | The NDVI cropped image url. |

Contributors

License

MIT License
Copyright (c) 2021 Leonardo Schneider
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.