Comments (4)
Dear Mahlatse,
please find the attached NDVI Change Ratio scripts and EO Browser links below. I'm sending you the script in 3 different visualizations, tested on Nile river agriculture, as you will see below.
I took a multitemporal NDVI script, made by Harel Dan, and modified it for your needs. The script first gets the month of the most recent acquisition available and then loops through all the acquisitions and checks if each of them was acquired in the same month. Then you have an else statement, where all the other acquisitions fall. To make this work, the filterScenes function at the end is set to 2 months. This means the script should take the first and second month from the Until date you choose (either in EO Browser timespan or in your request body).
Finally, the NDVI Change Ratio is calculated from the average NDVI of the first month (avg1) and average NDVI of the second month (avg2) as: NDVI Change Ratio = (avg1-avg2) / avg2.
Grayscale visualization
The visualization in this script is grayscale, which makes it possible to see how the index looks like without visualization manipulation. The lighter the pixel, the higher the value of the NDVI Change ratio.
Please find the script in EO Browser and in the NDVI Change Ratio, Grayscale.txt file.
Visualization from your Table 1. Legend
I implemented the visualization with the same borders and colors as in Table 1. Legend from your question. However, the result does not look good. I think the values in the table are not ok, as it seems that most values of the index are between 0 and 5, which falls into one single category in the legend (No change), hence, the result is mostly yellow. This might be ok, if the vegetation really would not change at all, but I checked the results in Ljubljana as well, and I'm confident there should be quite a lot of vegetation changes between July and September, and the script returned all yellow there as well. So I believe this is probably not a good way to visualize this index.
Please find the script in EO Browser and in the NDVI Change Ratio, suggested visualization.txt file.
New visualization between 0 and 5
My suggestion would be to instead make a visualization with more differentiation between 0 and 5. I prepared an example visualization with the borders 0,0.5,1,3 and 5, and colors going from black to blue, then green and finally red for the highest values.
Please find the script in EO Browser and in the NDVI Change Ratio, new visualization 0-5.txt file.
I wish you all the best,
Monja
from custom-scripts.
Hi Monja,
Thank you very much for your timely response and implementation of this idea. I highly appreciate it.
I noted that when switching between dates (months) in EO browser, the following error occurs. I am not sure what is the cause.
//----------------------------------------------------------------------------------
An error has occurred while fetching images:
Failed to evaluate script!
evalscript.js:19: TypeError: Cannot read property 'date' of undefined
var endMonth = scenes[0].date.getMonth(); //get month of the most recent scene
^
TypeError: Cannot read property 'date' of undefined
at evaluatePixel (evalscript.js:19:27)
at executeForMultipleScenes (:988:14)
//---------------------------------------------------------------------------------
I think the blank yellow image on the second code, i.e., suggested visualisation.txt, required multiplication by 100 to work. Otherwise, I managed to make the suggested visualisation to work by adapting the third code, i.e., new visualization 0-5.txt, as follows:
//---------------------------------------------------------------------------------
let NDVI_change_ratio = ((avg1-avg2)/(avg2))*100
return colorBlend (NDVI_change_ratio, [-25,-15,-5,0,5,15,25], [
[204,41,0], //values <= -25, red,Significant decrease
[179,89,0], //values <= -15, brown, Moderate decrease
[255,153,0], //values <= -5, orange, Low decrease
[255,255,0], //values = 0, yellow, No change
[153,255,153], //values >=5, lime green, Low increase
[0,204,0], //values >=15, light green, Moderate increase
[0,128,0]//values >=25, Green, Significant increase
]);
}
//---------------------------------------------------------------------------------
Regards,
Mahlatse
from custom-scripts.
Dear Mahlatse,
I missed your answer, sorry for a late response. Technically this should work in EO Browser with a single date, as you have it all specified in filterScenes, but for some reason it doesn't work, when you change the date. It's important to have a timespan turned on and to select before-to months so they cover at least 2 months. If you change the Until date, you should also change the From date. I changed it to February 6 to April 6 and it worked. So set a timespan, and it should work (I hope).
Oh yes, it does work better if I multiply it by 100. Cool.
Best,
Monja
from custom-scripts.
Hi Monja,
Thanks a lot.
from custom-scripts.
Related Issues (20)
- ARVI formula says NIR, so shouldn't use B08? HOT 3
- NDVI MAX, does it work? HOT 4
- How to run these scripts HOT 1
- custom-scripts/sentinel-1/sar_false_color_visualization HOT 6
- How to calculate NDVI from Sentinel-2 to any AOI with coordinates based on python API HOT 1
- Why is the LAI output divided by 3 HOT 2
- B12 of Observation outlier detector HOT 2
- V variable ? HOT 1
- Question about data fusion HOT 3
- Question about directly using LAI calculation codes in GEE
- Can anyone help me to isolate any of the indicators one by one? Se2WaQ HOT 1
- Broken link
- Custom script not working in Playground
- Text in geology composite wrong
- Broken datafusion script HOT 2
- Add breadcrumbs to script pages HOT 3
- Chlorophyll Red-Edge on Sentinel Hub - correct equation HOT 3
- Multi-temporal Data isuue HOT 2
- Sentinel-2 indices might be invalid HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from custom-scripts.