npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ndvi-gee

v1.0.3-beta

Published

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

Downloads

2

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


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


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. | | time_start | Number | It is set to the nominal composite start period for temporal composites. It is a timestamp number format. | | time_end | 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. | | img_url | 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.