From 4477bcf20a471f632ff48d251294dbee042745b5 Mon Sep 17 00:00:00 2001 From: Jonas Viehweger Date: Wed, 27 Nov 2024 10:03:47 +0100 Subject: [PATCH] Integrated back rebased files --- planet/planetscope/ndvi/index.md | 2 +- planet/planetscope/ndvi_difference/index.md | 2 +- planet/planetscope/ndwi/eob.js | 70 ++++++++++----------- planet/planetscope/ndwi/script.js | 11 ++-- planet_scope/ndvi/README.md | 46 -------------- planet_scope/ndvi_difference/README.md | 43 ------------- planet_scope/ndwi/script.js | 30 --------- 7 files changed, 41 insertions(+), 163 deletions(-) delete mode 100644 planet_scope/ndvi/README.md delete mode 100644 planet_scope/ndvi_difference/README.md delete mode 100644 planet_scope/ndwi/script.js diff --git a/planet/planetscope/ndvi/index.md b/planet/planetscope/ndvi/index.md index a47c9d14..e5fb5343 100644 --- a/planet/planetscope/ndvi/index.md +++ b/planet/planetscope/ndvi/index.md @@ -17,7 +17,7 @@ examples: toTime: '2023-04-19T23:59:59.999Z' platform: - EOB - evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/planet/planetscope/ndvi/eob.js + evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/planet_scope/ndvi/eob.js additionalQueryParams: - - themeId - PLANET_SANDBOX diff --git a/planet/planetscope/ndvi_difference/index.md b/planet/planetscope/ndvi_difference/index.md index efbc4537..bb5c3882 100644 --- a/planet/planetscope/ndvi_difference/index.md +++ b/planet/planetscope/ndvi_difference/index.md @@ -15,7 +15,7 @@ examples: - zoom: '14' lat: '52.24714' lng: '9.20886' - datasetId: Planetscope + datasetId: 'ccb1f8f0-e5bf-4c31-afe5-d8803bcbde2a' fromTime: '2023-04-02T00:00:00.000Z' toTime: '2023-06-01T23:59:59.999Z' platform: diff --git a/planet/planetscope/ndwi/eob.js b/planet/planetscope/ndwi/eob.js index b4af6cd2..f7a0bc8f 100644 --- a/planet/planetscope/ndwi/eob.js +++ b/planet/planetscope/ndwi/eob.js @@ -2,46 +2,44 @@ //PlanetScope NDWI EO Browser function setup() { - return { - input: [{ - bands: [ - "green", - "nir", - "dataMask", - "clear"] - }], - output: [ - { id: "default", bands: 4 }, - { id: "index", bands: 1, sampleType: "FLOAT32" }, - { id: "eobrowserStats", bands: 2, sampleType: "FLOAT32" }, - { id: "dataMask", bands: 1 }, - ] - } + return { + input: [ + { + bands: ["green", "nir", "dataMask", "clear"], + }, + ], + output: [ + { id: "default", bands: 4 }, + { id: "index", bands: 1, sampleType: "FLOAT32" }, + { id: "eobrowserStats", bands: 2, sampleType: "FLOAT32" }, + { id: "dataMask", bands: 1 }, + ], + }; } function evaluatePixel(sample) { + let ndwi = index(sample.green, sample.nir); - let ndwi = index(sample.green, sample.nir) + const clear = sample.dataMask && sample.clear; - const clear = sample.dataMask && sample.clear; + let ndwi_colored = colorBlend( + ndwi, + [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], + [ + [1, 0, 1], + [1, 0.5, 0], + [1, 1, 0], + [0.2, 1, 0.5], + [0, 0, 1], + [0, 0, 0.3], + [0, 0, 0], + ] + ); - let ndwi_colored = colorBlend(ndwi, - [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], - [ - [1, 0, 1], - [1, 0.5, 0], - [1, 1, 0], - [0.2, 1, 0.5], - [0, 0, 1], - [0, 0, 0.3], - [0, 0, 0], - ] - ); - - return { - default: [...ndwi_colored, clear], - index: [ndwi], - eobrowserStats: [ndwi, !clear], - dataMask: [sample.dataMask], - }; + return { + default: [...ndwi_colored, clear], + index: [ndwi], + eobrowserStats: [ndwi, !clear], + dataMask: [sample.dataMask], + }; } diff --git a/planet/planetscope/ndwi/script.js b/planet/planetscope/ndwi/script.js index 3e56a725..258a8087 100644 --- a/planet/planetscope/ndwi/script.js +++ b/planet/planetscope/ndwi/script.js @@ -4,16 +4,15 @@ function setup() { return { input: [{ bands: ["green", "nir", "dataMask"] }], - output: [ - { id: "default", bands: 4 }, - ] - } + output: [{ id: "default", bands: 4 }], + }; } function evaluatePixel(sample) { - let ndwi = index(green, nir); + let ndwi = index(sample.green, sample.nir); - let id_default = colorBlend(ndwi, + let id_default = colorBlend( + ndwi, [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], [ [1, 0, 1], diff --git a/planet_scope/ndvi/README.md b/planet_scope/ndvi/README.md deleted file mode 100644 index 6f960cb9..00000000 --- a/planet_scope/ndvi/README.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Normalized difference vegetation index, PlanetScope -parent: PlanetScope -grand_parent: Planet -layout: script -permalink: /planetscope/ndvi/ -nav_exclude: true -scripts: - - [EO Browser, eob.js] -examples: -- zoom: '16' - lat: '-32.10671' - lng: '116.00704' - datasetId: 'ccb1f8f0-e5bf-4c31-afe5-d8803bcbde2a' - fromTime: '2023-04-19T00:00:00.000Z' - toTime: '2023-04-19T23:59:59.999Z' - platform: - - EOB - evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/planet_scope/ndvi/eob.js - additionalQueryParams: - - - themeId - - PLANET_SANDBOX ---- - -The example data is using Planet Sandox data. This data is restricted to Sentinel Hub users with active paid plans. If you are already a Planet Customer, see [here](https://community.planet.com/sentinel-hub-81/access-new-tools-for-analyzing-your-planet-data-on-sentinel-hub-732) on how to get access. - -## General description - -The well known and widely used NDVI is a simple, but effective index for quantifying green vegetation. It normalizes green leaf scattering in Near Infra-red wavelengths with chlorophyll absorption in red wavelengths. - -The value range of the NDVI is -1 to 1. Negative values of NDVI (values approaching -1) correspond to water. Values close to zero (-0.1 to 0.1) generally correspond to barren areas of rock, sand, or snow. Low, positive values represent shrub and grassland (approximately 0.2 to 0.4), while high values indicate temperate and tropical rainforests (values approaching 1). It is a good proxy for live green vegetation; see [1] for details. - -The normalized difference vegetation index, abbreviated NDVI, is defined as - -$$NDVI := \mathtt{Index}(nir,red) = \frac{nir-red}{nir+red}.$$ - -This is an example script which can be used with EO Browser and is configured to return statistics in a format which can be used with the statistical info chart. For more information, see How Can I Configure My Layers For Statistical Information In EO Browser? - -## Representative images - -NDVI of agriculture fields in Iowa. - - - -## References - [1] Wikipedia, [Normalized Difference Vegetation Index](https://en.wikipedia.org/wiki/Normalized_Difference_Vegetation_Index). Accessed on October 4th 2017. diff --git a/planet_scope/ndvi_difference/README.md b/planet_scope/ndvi_difference/README.md deleted file mode 100644 index 7b43dd1f..00000000 --- a/planet_scope/ndvi_difference/README.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: NDVI difference between two dates -parent: Planetscope -grand_parent: Planet -layout: script -permalink: /planet_scope/ndvi_difference/ -nav_exclude: true -scripts: -- - Visualization - - script.js -- - EO Browser - - eob.js -- - Raw Values - - raw.js -examples: -- zoom: '14' - lat: '52.24714' - lng: '9.20886' - datasetId: 'ccb1f8f0-e5bf-4c31-afe5-d8803bcbde2a' - fromTime: '2023-04-02T00:00:00.000Z' - toTime: '2023-06-01T23:59:59.999Z' - platform: - - EOB - evalscripturl: https://raw.githubusercontent.com/sentinel-hub/custom-scripts/master/planet_scope/ndvi_difference/script.js - additionalQueryParams: - - - themeId - - PLANET_SANDBOX ---- - -## General description -This script aims to obtain the diffence of NDVI between the latest acquisition and the acquisition 10-day prior to the latest on within a specified time period. Multi-temporal analysis is common in the Earth Observation field. Here we take NDVI as an example and demonstrate how to calculate the difference of NDVI between two acquisitions using [`mosaicking: ORBIT`](https://docs.sentinel-hub.com/api/latest/evalscript/v3/#mosaicking) and [`preProcessScenes`](https://docs.sentinel-hub.com/api/latest/evalscript/v3/#preprocessscenes-function-optional) in one single request. - -To implement multi-temporal analysis in the Evalscript, we apply `ORBIT` mosaicking to query daily mosaic in the specified time period. Then, by using the optional `preProcessScenes` function, we find out the acquisition acquired on the date closest to the date 10-day prior to the latest acquisition and filter the out the other unused acquisitions to save Processing Units. Last but not least, in the `evaluatePixel` function we initialise a combined mask to ensure the difference of NDVI between two acquisitions exists only if there is data on both dates. - -**Note**: The example script is used to obtain the raw value of NDVI difference. For visualisation purpose, please follow the EO Browser link in the [Evaluate and visualize](#evaluate-and-visualize) section. The visualisation script contains 4 outputs: default, index, eobrowserStats and dataMask. The default layer is a visualisation layer to visualise NDVI difference in EO Browser. The index layer is the actual value of the NDVI difference. The eobrowserStats and the dataMask layer is configured to activate statistical features on EO Browser. Please see the [FAQ](https://www.sentinel-hub.com/faq/#how-configure-your-layers-statistical-info-eo-browser) for more details. - -## Author of the script - -William Ray - -## Description of representative images -The following image shows the NDVI difference between the latest acquisition and the acquisition 10-day prior to the latest one during the time period from 2nd of April, 2023 to 2nd June, 2023. -![NDVI difference example](fig/fig1.png) diff --git a/planet_scope/ndwi/script.js b/planet_scope/ndwi/script.js deleted file mode 100644 index ba9e200e..00000000 --- a/planet_scope/ndwi/script.js +++ /dev/null @@ -1,30 +0,0 @@ -//VERSION=3 -//NDWI - -function setup() { - return { - input: [{ bands: ["green", "nir", "dataMask"] }], - output: [ - { id: "default", bands: 4 }, - ] - } -} - -function evaluatePixel(sample) { - let ndwi = index(sample.green, sample.nir); - - let id_default = colorBlend(ndwi, - [-1, -0.5, -0.2, 0, 0.2, 0.5, 1.0], - [ - [1, 0, 1], - [1, 0.5, 0], - [1, 1, 0], - [0.2, 1, 0.5], - [0, 0, 1], - [0, 0, 0.3], - [0, 0, 0], - ] - ); - - return { default: [...id_default, sample.dataMask] }; -}