Coder Social home page Coder Social logo

sentinel-hub / custom-scripts Goto Github PK

View Code? Open in Web Editor NEW
644.0 56.0 292.0 1.13 GB

A repository of custom scripts to be used with Sentinel Hub

Home Page: https://custom-scripts.sentinel-hub.com/

License: Creative Commons Attribution Share Alike 4.0 International

JavaScript 97.04% HTML 0.52% SCSS 0.33% Ruby 0.02% Jupyter Notebook 2.09%
sentinel-hub remote-sensing earth-observation

custom-scripts's Issues

Chlorophyll Red-Edge on Sentinel Hub - correct equation

I noticed that on the Sentinel Hub custom scripts page which is used in EO Browser and Sentinel Playground, for Chlorophyll Red-Edge the equation is not the correct one. It states:

General formula: ([760:800]/[690:720])^(-1), and the custom script also uses the equation with mathematical power (if the power was indeed -1, it would be just the inverse equation).

The correct formula should be (B07 / B05) -1, ie like in this paper:
(https://www.mdpi.com/2072-4292/13/14/2732)

Multi-temporal Data isuue

Hi,
I am unable to run the script (sar_multi-temporal_backscatter_coefficient_composite) in EO browser custom scipt.
can please you help me in this?
I think there is issue with temporal data.
Thank you!

Contrast and Luminance

Hello,

In my web application, I wanted to include a slider that allows the user to control the contrast and luminosity of the images. While using Sentinel Playground, I noticed the WMS service has parameters "Gain" and "Gamma", I tried using both of them in my application but I had no results. So I searched even more online, and found this 2017 article:
https://www.sentinel-hub.com/faq/what-has-changed-2017-11-release
It says that the parameters Gamma and Gain were deprecated, and should now be defined in a custom Script.
It would be nice if you could explain to me how can I do this.
Ps: I don't want to overwrite the script that is already used for my layer, but just change contrast and luminosity.

Thank you.

Example query for agricultural growth stage

Hi! I would like to try this @hareldunn script (https://github.com/sentinel-hub/custom-scripts/blob/master/sentinel-2/agriculture_growth_stage/script.js) but I get this error [CDATA[ Failed to evaluate script!\nTypeError: Cannot read property \'getMonth\' of undefined ]].

My query has parameters:

{'TIME': '2016-05-01/2018-04-21', 
'GEOMETRY': <shapely.geometry.polygon.Polygon object at 0x7f90505e0b70>, 
'WIDTH': 1280, 'HEIGHT': 1280, 
'CRS': 'EPSG:4326', 
'ATM_FILTER': 'ATMCOR', 
'EVALSCRIPTURL': 'https://raw.githubusercontent.com/sentinel-hub/custom-scripts/master/sentinel-2/agriculture_growth_stage/script.js', 
'LAYER': 'NDVI'}

querying the FIS service (though I get the same error querying WMS too). I'm sure I'm making a simple mistake, could I get an example of a working query using this script?

Thanks! Let me know if this wasn't clear enough.

Issues using EvalScript Parameter

Hello,

I am currently working on a project in which I am using Sentinel Hub 2 WMS URLs. I need to point out that I am very noob in web development.

In my project, I use I have a small interface allowing the user to choose 3 bands to allocate to the RGB Bands (juste like in the Sentinel Hub Playground custom tool). Using HTML and JavaScript, I collect the data from the interface and create a variable for the custom Eval Script according to the basic script style (return [ 2.5*B01...).

I then set this variable as the parameter 'EVALSCRIPT' of the URL:
_source.getParams()['EVALSCRIPT']=_customScript;

This doesn't seem to work.

On the other hand, using the parameter EVALSCRIPTURL seems to work if I give it the URL to a JS file containing the script:
_source.getParams()['EVALSCRIPTURL']='https://geobretagne.fr/apps/sentinel/customcontrols/evalscript.js';

For various reasons, I need to use the EVALSCRIPT parameter and not the EVALSCRIPTURL one. Do you have an idea why isn't it working ? Or is my understanding of the EVALSCRIPT parameter wrong ?

Thank you.

Text in geology composite wrong

This composite, often called the Agriculture RGB composite, uses bands SWIR-1 (B11), near-infrared (B08) and blue (B02). It’s mostly used to monitor crop health, as both short-wave and near infrared bands are particularly good at highlighting dense vegetation, which appears dark green in the composite. SWIR measurements can help scientists estimate how much water is present in plants and soil, as water reflects SWIR light. Shortwave-infrared bands are also useful for distinguishing between snow, and ice, all of which appear white in visible light. Newly burned land reflects strongly in SWIR bands, making them valuable for mapping fire damage.

Question about directly using LAI calculation codes in GEE

Hi there,

It is great to see the shared codes on LAI calculation using Sentinel-2 images. I want to run the script in GEE to calculate the LAI actually, but was wondering about which Sentinel-2 sensor the weights and bias in your codes fit as the algorithm handbook reads different neural networks were deployed for S2A and S2B respectively.

Many thanks,
Alex

Broken datafusion script

The following script has issues and will not display in Eo Browser: https://custom-scripts.sentinel-hub.com/data-fusion/s2l1c_s1grd_cloud_replacement/

  • First error Invalid script! Band 'VV' of collection 'S1GRD' requested in unsupported units 'REFLECTANCE'! Supported units for this band: [LINEAR_POWER]. -> the units need to be replaced by LINEAR_POWER
  • Second error: Invalid script! Band 'CLM' of collection 'S2L1C' requested in unsupported units 'REFLECTANCE'! Supported units for this band: [DN]. -> the easiest fix would be to change the units to DN and adjust the return for the RGB (factor of 10k).

Sentinel-2 indices might be invalid

Many indices for Sentinel-2 are based on https://www.indexdatabase.de website.

Consider Sentinel-2A entry from indexdatabase.de.
Notice table Bands/Channels with columns Nr. and Name.

After analysis I've came up with interpretation of this site, which is significantly different from
interpretation postulated in many indices on this repo.

Proposed index formula interpretation

(The interpretation is based on my guess, however the following reasoning supports it.
Please correct me if I am wrong.)

  • band value in violet italic is entry from Nr. column,
  • band value in violet straight is entry from Name column.

For example:

  • 9 in violet italic is Band B8A,
  • 9 in violet straight is Band B09.

Why this interpretation is valid?

Consider sentinel-hub ARVI script.

The general formula has as a first term NIR. Specific formula starts (on indexdatabase.de) with 9 in violet italic.

  • in proposed interpretation, this corresponds to row with Nr. = 9, which is a band with Name = 8a. This gives "Narrow NIR" band.
  • on this repo this is interpreted as band with Name = 9. This gives "Water vapour".

Since general formula mentions "NIR", I believe that proposed interpretation in this issue is valid.

I've attached PR with proposed fix for ARVI, which follows this reasoning.

Which indices are affected?

Many Sentinel-2 indices, including:

  • ARVI
  • EVI, which assigned to 9 in violet italic a band B08 (instead of B09 like in ARVI),
  • many other indices, which refer to bands higher than 8.

Potentially this interpretation problem can be present in indices for other satellites.

Log scale

Is there any function that i could use to visualize my values with colours in logarithmic scale?

Why is the LAI output divided by 3

Hello,

Looking at the code I was wondering what was the rational of divided the LAI output by 3 ?

var lai = denormalize(l2, 0.000319182538301, 14.4675094548151);
return {
default: [lai / 3]
}

Thanks for your input,
Best
HB

custom-scripts/sentinel-1/sar_false_color_visualization

Cannot get the Sentinel-1 false-color script (custom-scripts/sentinel-1/sar_false_color_visualization) to work, using standard S1 GRD products from the Copernicus SciHub (linear amplitude, UINT16) as input.
Apologies for the trivial questions:

  • what is the expected input backscatter type of the "VV" and "VH" variables (logaritmic scale (dB), linear amplitude, linear power) and data type (UINT16, FLOAT32?) for the script?
  • what is the expected data type of the output variables "band1", "band2", "band3?
    Many thanks - AR

NBR formula

According to the reference page reported in the script, the bands that should be used for this index are 9 and 12, not 8 and 12.

Can anyone help me to isolate any of the indicators one by one? Se2WaQ

Hi, herewith down this post is the complete script for analysing all 6 indicators Se2WaQ (Sentinel-2 Water Quality Script),
Could anybody help me to isolate the script for anyone of them?
Im afraid my knowledge in scripting is still very basic,

I really appreciate it!
Alberto
geovisualization.net

var FLAGparam = 4;
var FLAGbackGround = 2;

var Black = [0]; // FLAGbackGround = 0
//var NDVI = index(B08, B04); // FLAGbackGround = 1
var NDVI = 1;
var NDWI = index(B03, B08);
var TrueColor = [B042.5, B032.5, B022.5]; // FLAGbackGround = 2
var Chl_a = 4.26 * Math.pow(B03/B01, 3.94); // FLAGparam = 0; S2-L2A; [1] Unit: mg/m2;
var Cya = 115530.31 * Math.pow(B03 * B04 / B02, 2.38); // FLAGparam = 1; S2-L2A; [1] Unit: 10^3 cell/ml;
var Turb = 8.93 * (B03/B01) - 6.39; // FLAGparam = 2; S2-L2A; [1] Unit: NTU;
var CDOM = 537 * Math.exp(-2.93
B03/B04); // FLAGparam = 3; S2-L1C; [2] Unit: mg/l;
var DOC = 432 * Math.exp(-2.24B03/B04); // FLAGparam = 4; S2-L1C; [2] Unit: mg/l;
var Color = 25366 * Math.exp(-4.53
B03/B04); // FLAGparam = 5; S2-L1C; [2] Unit: mg.Pt/l;

var scaleChl_a = [0, 6, 12, 20, 30, 50];
var scaleCya = [0, 10, 20, 40, 50, 100];
var scaleTurb = [0, 4, 8, 12, 16, 20];
var scaleCDOM = [0, 1, 2, 3, 4, 5];
var scaleDOC = [0, 5, 10, 20, 30, 40];
var scaleColor = [0, 10, 20, 30, 40, 50];

var s = 255;
var colorScale =
[
[73/s, 111/s, 242/s],
[130/s, 211/s, 95/s],
[254/s, 253/s, 5/s],
[253/s, 0/s, 4/s],
[142/s, 32/s, 38/s],
[217/s, 124/s, 245/s]
];

if (NDWI<0) {
if ( FLAGbackGround == 0 ) {
return Black;
} else if ( FLAGbackGround == 1 ) {
return [0, .5*(NDVI+1), 0];
} else if ( FLAGbackGround == 2 ) {
return TrueColor;
}
} else {
switch ( FLAGparam ) {
case 0:
return colorBlend(Chl_a, scaleChl_a, colorScale);
break;
case 1:
return colorBlend(Cya, scaleCya, colorScale);
break;
case 2:
return colorBlend(Turb, scaleTurb, colorScale);
break;
case 3:
return colorBlend(CDOM, scaleCDOM, colorScale);
break;
case 4:
return colorBlend(DOC, scaleDOC, colorScale);
break;
case 5:
return colorBlend(Color, scaleColor, colorScale);
break;
default:
return TrueColor;
}
}

How to run the code

Greetings from WA,

Many thanks for the code @sabinadolenc . I am new here and was wondering how to run the code of https://github.com/sentinel-hub/custom-scripts/tree/master/sentinel-1/seldom_and_regular_water_surface_detection . (apologies if this is not the right place to post this).

The way I did was

  1. select Sentinel-1 from the eo-browser from
    https://apps.sentinel-hub.com/eo-browser/?lat=-31.95995&lng=115.83967&zoom=13

  2. search from 2019-01-01 - 2019-10-20, resulting in 32 results (select the most recent one for viewing)

  3. create custom rendering and choose custom script

  4. Use URL and put "https://raw.githubusercontent.com/sentinel-hub/custom-scripts/master/sentinel-1/seldom_and_regular_water_surface_detection/seldom_and_regular_water_surface_detection.js" in

  5. Then I got nothing similar to what has been shown here.

I am sure I missed something very simple, but can you please kindly help?

Thanks.
BT

V variable ?

Thank you for code
I translat it to GEE
It is not clear for what V wariable , gain?
why always return the same?
Thanks

Question about data fusion

Hi all, I would like to use different datasets for doing some partical detection, specifically I want to use data from Sentinel-1 and Sentinel-2.
I am using this script as guidance https://github.com/sentinel-hub/custom-scripts/blob/master/data-fusion/ship_detection_s1_s2/script.js
however I am stuck at its execution because of an incomprensible error for me, that is the following:

Failed to evaluate script!
evalscript.js:20: TypeError: Cannot read property 'B03' of undefined
let ndwi = (S2L1C.B03 - S2L1C.B08) / (S2L1C.B03 + S2L1C.B08)
^
TypeError: Cannot read property 'B03' of undefined
at evaluatePixel (evalscript.js:20:19)
at executeForMultipleSources (:17:17)

I try different broswers but the results is exactly the same. What I am doing wrong ?

B12 of Observation outlier detector

Frist, Than you so much for sharing your great script.

I have a question about Observation outlier detector.
Line 22 of script is below

let shadow = predict(sample.B01, sample.B02, sample.B03, sample.B04, sample.B05, sample.B06, sample.B07, sample.B08, sample.B08A, sample.B09, sample.B10, sample.B11, sample.B11, NDVI, NBSI) > 0.5

Why do you use two B11? Should it be B12?

ARVI formula says NIR, so shouldn't use B08?

Hi, nice work, just one question, about ARVI:
The present script for ARVI used at
https://github.com/sentinel-hub/custom-scripts/blob/master/sentinel-2/arvi/script.js
states:
let index = (B09 - B04 - y * (B04 - B02)) / (B09 + B04 - y * (B04 - B02));

But, since:

  1. As said in https://www.indexdatabase.de/db/si-single.php?sensor_id=96&rsindex_id=4 :

General Formula: NIR−RED−y(RED−BLUE) / NIR+RED−y(RED−BLUE)
Specific Formula: 9−5−y(5−1) / 9+5−y(5−1)

  1. true NIR is B08, and true RED is B04 (https://en.wikipedia.org/wiki/Sentinel-2#Instruments);
  2. it was already changed in the script "5" for "B04" (so it could be expected to change "9" for "B08");
    So, isn't a mistake in both the "Specific Formula" and the "arvi/script.js"?
    Shouldn't it be used just B08|B04|B02 , like :
    let index = (B08 - B04 - y * (B04 - B02)) / (B08 + B04 - y * (B04 - B02));

?
Thanks in advance

How to run these scripts

HI just wondering is there any documentation on how to use/run these scripts?

Thanks in advance for help

Add breadcrumbs to script pages

Accessing the scripts through search (or direct links) presents the user with a page without a clear information on what satellite data the script uses. Sometimes it is written in the description, but that's not so straightforward and the information is sometimes missing altogether. Using a script with the wrong satellite data collection will result in errors.

I'd suggest to add breadcrumbs to the individual script pages right on the top of the page, so a user always knows to which source the script applies.

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.