Skip to content

Commit 1dc40ee

Browse files
Fix/playground (#299)
* Removed playground references, made parser for example links * Working for Sentinel 2 * Made examples more modular and machine readable. Removed playground links, added Copernicus Browser examples * fixed layouts
1 parent b43833e commit 1dc40ee

File tree

174 files changed

+3007
-1581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+3007
-1581
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For instructions on how custom scripts are structured have a look at this [tutor
2929
_Obviously, you'll want to remove this chapter, but use the rest of the file as a template._
3030
_Have a look around at other `README.md` files to see how to include images, format the text and generally use the GitHub [markdown](https://help.github.com/categories/writing-on-github/) (e.g. [here](../sentinel-2/cby_cloud_detection/README.md) for mathematical formulas or [here](../sentinel-2/ndvi_uncertainty/README.md) for adding images)._
3131
- Implement the product in the `script.js` file.
32-
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script. Of course the easiest is to do the custom script building/testing on [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/)._
32+
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script._
3333
- Add an entry pointing to your script to the top level markdown file (i.e. if adding a script for Sentinel 2 add the link to `sentinel-2.md` in the folder `sentinel-2`).
3434
_A link and a short description will do._
3535
- And create a pull request :).

_layouts/script.html

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
---
22
layout: default
3+
cdse_lookup:
4+
S2L2A: S2_L2A_CDAS
5+
S2L1C: S2_L1C_CDAS
6+
S1_AWS_IW_VVVH: S1_CDAS_IW_VVVH
7+
S3SLSTR: S3SLSTR_CDAS
8+
S3OLCI: S3OLCI_CDAS
9+
S5_AER_AI: S5_AER_AI_CDAS
10+
S5_CH4: S5_CH4_CDAS
11+
S5_NO2: S5_NO2_CDAS
12+
S5_CLOUD: S5_CLOUD_CDAS
13+
S5_CO: S5_CO_CDAS
14+
S5_HCHO: S5_HCHO_CDAS
15+
S5_O3: S5_O3_CDAS
16+
S5_SO2: S5_SO2_CDAS
17+
S1_AWS_EW_HHHV: S1_CDAS_EW_HHHV
318
---
419

520
<h1 class="d-inline" id={{page.slug}}> {{page.title}} </h1>
@@ -38,4 +53,28 @@ <h1 class="d-inline" id={{page.slug}}> {{page.title}} </h1>
3853

3954
</div>
4055

41-
{{content}}
56+
{% if page.examples %}
57+
<h2 class="d-inline"> Evaluate and Visualize </h2>
58+
{% for example in page.examples %}
59+
{% if example.name %}
60+
<h3 class="d-inline"> {{example.name}} </h2>
61+
{% endif %}
62+
{% capture additonalParams %}{% for query in example.additionalQueryParams %}&{{query[0]}}={{query[1] | url_encode}}{% endfor %}{% endcapture %}
63+
<ul>
64+
{% if example.platform contains "CDSE" %}
65+
<li>
66+
{% capture from %}{{ example.fromTime | slice: 0, 10 }}{% endcapture %}
67+
{% capture to %}{{ example.toTime | slice: 0, 10 }}{% endcapture %}
68+
<a href="https://dataspace.copernicus.eu/browser/?zoom={{example.zoom}}&lat={{example.lat}}&lng={{example.lng}}{% if example.evalscript %}&evalscript={{example.evalscript | url_encode}}{%- endif -%}{% if example.evalscripturl %}&evalscripturl={{example.evalscripturl | url_encode}}{%- endif -%}&datasetId={{layout.cdse_lookup[example.datasetId] | url_encode}}&fromTime={{example.fromTime | url_encode}}&toTime={{example.toTime | url_encode}}{% if from != to %}&dateMode=TIME RANGE{%- endif -%}{{additonalParams}}#custom-script" target="_blank">Copernicus Browser</a>
69+
</li>
70+
{% endif %}
71+
{% if example.platform contains "EOB" %}
72+
<li>
73+
<a href="https://apps.sentinel-hub.com/eo-browser/?zoom={{example.zoom}}&lat={{example.lat}}&lng={{example.lng}}{% if example.evalscript %}&evalscript={{example.evalscript | url_encode}}{%- endif -%}{% if example.evalscripturl %}&evalscripturl={{example.evalscripturl | url_encode}}{%- endif -%}&datasetId={{example.datasetId | url_encode}}&fromTime={{example.fromTime | url_encode}}&toTime={{example.toTime | url_encode}}{{additonalParams}}#custom-script" target="_blank">EO Browser</a>
74+
</li>
75+
{% endif %}
76+
</ul>
77+
{% endfor %}
78+
{% endif %}
79+
80+
{{content}}

_scripts/parse_example.ipynb

+428
Large diffs are not rendered by default.

contribute/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For instructions on how custom scripts are structured have a look at this [tutor
2626
_Obviously, you'll want to remove this chapter, but use the rest of the file as a template._
2727
_Have a look around at other `README.md` files to see how to include images, format the text and generally use the GitHub [markdown](https://help.github.com/categories/writing-on-github/) (e.g. [here](../sentinel-2/cby_cloud_detection/README.md) for mathematical formulas or [here](../sentinel-2/ndvi_uncertainty/README.md) for adding images)._
2828
- Implement the product in the `script.js` file.
29-
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script. Of course the easiest is to do the custom script building/testing on [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/)._
29+
_The most work is of course the JavaScript implementation of the product. The `example` folder includes an empty custom script with comments that will hopefully help you build your own custom script._
3030
- Add an entry pointing to your script to the top level markdown file (i.e. if adding a script for Sentinel 2 add the link to `sentinel-2.md` in the folder `sentinel-2`).
3131
_A link and a short description will do._
3232
- And create a pull request :).

dem/contour-lines/README.md

+47-44
Original file line numberDiff line numberDiff line change
@@ -6,96 +6,99 @@ permalink: /dem/contour-lines/
66
nav_exclude: true
77
---
88

9-
109
## Description
1110

12-
This script uses DEM to calculate and display contour lines. They are calculated using `c = 20 * Math.floor(d / 20)`. The visualization can be manipulated in a number of ways. The number `35` in the first conditional statement below sets the increments between the contour lines; in this case, the spacing between the contour lines means that the elevation difference between them is 35 meters. This means, that the contour lines will be further apart where the elevation is lower. The number `5` in the script below sets the contour line thickness to be pretty low. The first return statement `return [0,0,0]` sets the color of the contour lines to black, and the colorBlend maps the areas in between in terrain colors, based on the terrain elevation model borders.
11+
This script uses DEM to calculate and display contour lines. They are calculated using `c = 20 * Math.floor(d / 20)`. The visualization can be manipulated in a number of ways. The number `35` in the first conditional statement below sets the increments between the contour lines; in this case, the spacing between the contour lines means that the elevation difference between them is 35 meters. This means, that the contour lines will be further apart where the elevation is lower. The number `5` in the script below sets the contour line thickness to be pretty low. The first return statement `return [0,0,0]` sets the color of the contour lines to black, and the colorBlend maps the areas in between in terrain colors, based on the terrain elevation model borders.
1312

1413
## Representative Images and Examples
1514

1615
### Example 1
1716

18-
The following example will return black contour lines of thickness 5 in 35 meter increments on top of our standard DEM continuous color visualization.
17+
The following example will return black contour lines of thickness 5 in 35 meter increments on top of our standard DEM continuous color visualization.
1918

20-
[View in Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/?source=DEM&lat=41.645342272880455&lng=-7.038757314439863&zoom=13&preset=CUSTOM&layers=DEM,DEM,DEM&maxcc=20&gain=1.0&gamma=1.0&time=2019-05-01%7C2019-11-21&atmFilter=&showDates=false&evalscript=dmFyIGQgPSBERU07CmlmIChkICUgMzUgPCA1KSB7CiAgcmV0dXJuIFswLDAsMF0KfQp2YXIgYyA9IDIwICogTWF0aC5mbG9vcihkIC8gMjApOwpyZXR1cm4gY29sb3JCbGVuZChjLCBbLTEyMDAwLC05MDAwLC02MDAwLC0xMDAwLC01MDAsLTIwMCwtNTAsLTIwLC0xMCwwLDEwLDMwLDUwLDIwMCwzMDAsNDAwLDUwMCwxMDAwLDMwMDAsNTAwMCw3MDAwLDkwMDBdLApbWzAuMDAwLCAwLjAwMCwgMC4xNTddLApbMC4xMTgsIDAuMDAwLCAwLjM1M10sClswLjExOCwgMC4xMTgsIDAuNDcxXSwKWzAuMTU3LCAwLjE5NiwgMC43MDZdLApbMC4yMzUsIDAuMjM1LCAwLjkwMl0sClswLjIzNSwgMC4zMTQsIDAuOTYxXSwKWzAuMzUzLCAwLjMzMywgMC45ODBdLApbMC40NzEsIDAuNDcxLCAwLjkyMl0sClswLjYyNywgMC42MjcsIDEuMDAwXSwKWzAuNzg0LCAwLjc4NCwgMC43ODRdLApbMC4zOTIsIDAuMjIwLCAwLjIzNV0sClswLjQ3MSwgMC4xODAsIDAuMTU3XSwKWzAuNTQ5LCAwLjI5OCwgMC4xNTddLApbMC42NjcsIDAuMzc2LCAwLjAwMF0sClswLjQ3MSwgMC4yMjAsIDAuMzUzXSwKWzAuODI0LCAwLjU3MywgMC43MDZdLApbMC41NDksIDAuNDMxLCAwLjAwMF0sClswLjQ3MSwgMC41NDksIDAuNzA2XSwKWzAuNjI3LCAwLjY2NywgMC45NDFdLApbMC43NDUsIDAuNzg0LCAwLjk4MF0sClswLjg2MywgMC45NDEsIDEuMDAwXSwKWzEuMDAwLCAxLjAwMCwgMS4wMDBdXSk%3D)
19+
[See it in EO Browser](https://sentinelshare.page.link/uVTP)
2120

2221
```javascript
2322
var d = DEM;
2423
if (d % 35 < 5) {
25-
return [0,0,0]
24+
return [0, 0, 0];
2625
}
2726
var c = 20 * Math.floor(d / 20);
28-
return colorBlend(c, [-12000,-9000,-6000,-1000,-500,-200,-50,-20,-10,0,10,30,50,200,300,400,500,1000,3000,5000,7000,9000],
29-
[[0.000, 0.000, 0.157],
30-
[0.118, 0.000, 0.353],
31-
[0.118, 0.118, 0.471],
32-
[0.157, 0.196, 0.706],
33-
[0.235, 0.235, 0.902],
34-
[0.235, 0.314, 0.961],
35-
[0.353, 0.333, 0.980],
36-
[0.471, 0.471, 0.922],
37-
[0.627, 0.627, 1.000],
38-
[0.784, 0.784, 0.784],
39-
[0.392, 0.220, 0.235],
40-
[0.471, 0.180, 0.157],
41-
[0.549, 0.298, 0.157],
42-
[0.667, 0.376, 0.000],
43-
[0.471, 0.220, 0.353],
44-
[0.824, 0.573, 0.706],
45-
[0.549, 0.431, 0.000],
46-
[0.471, 0.549, 0.706],
47-
[0.627, 0.667, 0.941],
48-
[0.745, 0.784, 0.980],
49-
[0.863, 0.941, 1.000],
50-
[1.000, 1.000, 1.000]])
27+
return colorBlend(
28+
c,
29+
[
30+
-12000, -9000, -6000, -1000, -500, -200, -50, -20, -10, 0, 10, 30, 50,
31+
200, 300, 400, 500, 1000, 3000, 5000, 7000, 9000,
32+
],
33+
[
34+
[0.0, 0.0, 0.157],
35+
[0.118, 0.0, 0.353],
36+
[0.118, 0.118, 0.471],
37+
[0.157, 0.196, 0.706],
38+
[0.235, 0.235, 0.902],
39+
[0.235, 0.314, 0.961],
40+
[0.353, 0.333, 0.98],
41+
[0.471, 0.471, 0.922],
42+
[0.627, 0.627, 1.0],
43+
[0.784, 0.784, 0.784],
44+
[0.392, 0.22, 0.235],
45+
[0.471, 0.18, 0.157],
46+
[0.549, 0.298, 0.157],
47+
[0.667, 0.376, 0.0],
48+
[0.471, 0.22, 0.353],
49+
[0.824, 0.573, 0.706],
50+
[0.549, 0.431, 0.0],
51+
[0.471, 0.549, 0.706],
52+
[0.627, 0.667, 0.941],
53+
[0.745, 0.784, 0.98],
54+
[0.863, 0.941, 1.0],
55+
[1.0, 1.0, 1.0],
56+
]
57+
);
5158
```
5259

5360
![dem contour lines](fig/fig1.jpg)
5461

5562
### Example 2
5663

57-
We can make multiple contour lines, each in different increments and different color. It's also possible to return all other values transparent, so that contour lines can be downloaded and overlayed over other datasets. The following example returns 35 meter contour lines in black, 50 meter contour lines in red and all other pixels transparent. On the image, you can see Carto Voyager basemap under the contour lines.
64+
We can make multiple contour lines, each in different increments and different color. It's also possible to return all other values transparent, so that contour lines can be downloaded and overlayed over other datasets. The following example returns 35 meter contour lines in black, 50 meter contour lines in red and all other pixels transparent. On the image, you can see Carto Voyager basemap under the contour lines.
5865

59-
To display this script, either use a processing API, or EO Browser. In EO Browser, data fusion needs to be used to access DEM dataset.
66+
To display this script, either use a processing API, or EO Browser. In EO Browser, data fusion needs to be used to access DEM dataset.
6067

6168
[See it in EO Browser](https://apps.sentinel-hub.com/eo-browser/?zoom=13&lat=45.76735&lng=15.28576&themeId=DEFAULT-THEME&datasetId=S2L2A&fromTime=2020-09-30T00%3A00%3A00.000Z&toTime=2020-09-30T23%3A59%3A59.999Z&visualizationUrl=https%3A%2F%2Fservices.sentinel-hub.com%2Fogc%2Fwms%2Fbd86bcc0-f318-402b-a145-015f85b9427e&evalscript=Ci8vVkVSU0lPTj0zCi8vQXV0aG9yOiBNb25qYSBCLiDFoGViZWxhCgpmdW5jdGlvbiBzZXR1cCgpIHsKICByZXR1cm4gewogIAlpbnB1dDogWwogICAgCXtkYXRhc291cmNlOiAiUzJMMkEiLCBiYW5kczpbIkIwNCIsICJCMDMiLCAiQjAyIl19LAogICAgCXtkYXRhc291cmNlOiAiREVNIiwgYmFuZHM6WyJERU0iXX1dLAogIAlvdXRwdXQ6IFsKICAgIAl7aWQ6ICJkZWZhdWx0IiwgYmFuZHM6IDR9CiAgCV0KICB9Owp9CgpmdW5jdGlvbiBldmFsdWF0ZVBpeGVsKHNhbXBsZXMsIGlucHV0RGF0YSwgaW5wdXRNZXRhZGF0YSwgY3VzdG9tRGF0YSwgb3V0cHV0TWV0YWRhdGEpewogICAgdmFyIFMyID0gc2FtcGxlcy5TMkwyQVswXQogICAgdmFyIERFTU0gPSBzYW1wbGVzLkRFTVswXQogICAgdmFyIERFTSA9IERFTU0uREVNCgogICAgdmFyIGQgPSBERU07CmlmIChkICUgMzUgPCA1KSB7CiAgcmV0dXJuIFswLDAsMCwxXQp9CiAgaWYgKGQgJSA1MCA8IDUpIHsKICByZXR1cm4gWzEsMCwwLDFdCn0KCmVsc2V7CiAgcmV0dXJuIFswLDAsMCwwXQp9Cn0KICA%3D&dataFusion=%5B%7B%22id%22%3A%22AWS_S2L2A%22%2C%22alias%22%3A%22S2L2A%22%7D%2C%7B%22id%22%3A%22AWS_DEM%22%2C%22alias%22%3A%22DEM%22%7D%5D#custom-script).
6269

6370
```javascript
6471
var d = DEM;
6572
if (d % 35 < 5) {
66-
return [0,0,0,1]
73+
return [0, 0, 0, 1];
6774
}
6875
if (d % 50 < 5) {
69-
return [1,0,0,1]
70-
}
71-
else{
72-
return [0,0,0,0]
76+
return [1, 0, 0, 1];
77+
} else {
78+
return [0, 0, 0, 0];
7379
}
7480
```
7581

7682
![dem contour lines](fig/fig4.png)
7783

7884
### Example 3
7985

80-
Making contour lines very thick and returning them white, while returning everything else using a color visualization, gives the impression of colored contour lines on a white background.
86+
Making contour lines very thick and returning them white, while returning everything else using a color visualization, gives the impression of colored contour lines on a white background.
8187

82-
[View in Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/?source=DEM&lat=40.44593462678334&lng=-8.156147003173828&zoom=14&preset=CUSTOM&layers=DEM,DEM,DEM&maxcc=20&gain=1.0&gamma=1.0&time=2019-05-01%7C2019-11-21&atmFilter=&showDates=false&evalscript=dmFyIGQgPSBERU07CmlmIChkICUgMjAgPCAxOCkgewogIHJldHVybiBbMSwxLDFdCn0KdmFyIGMgPSAyMCAqIE1hdGguZmxvb3IoZCAvIDIwKTsKcmV0dXJuIGNvbG9yQmxlbmQoYywgWy0xMjAwMCwtOTAwMCwtNjAwMCwtMTAwMCwtNTAwLC0yMDAsLTUwLC0yMCwtMTAsMCwxMCwzMCw1MCwyMDAsMzAwLDQwMCw1MDAsMTAwMCwzMDAwLDUwMDAsNzAwMCw5MDAwXSwKW1swLjAwMCwgMC4wMDAsIDAuMTU3XSwKWzAuMTE4LCAwLjAwMCwgMC4zNTNdLApbMC4xMTgsIDAuMTE4LCAwLjQ3MV0sClswLjE1NywgMC4xOTYsIDAuNzA2XSwKWzAuMjM1LCAwLjIzNSwgMC45MDJdLApbMC4yMzUsIDAuMzE0LCAwLjk2MV0sClswLjM1MywgMC4zMzMsIDAuOTgwXSwKWzAuNDcxLCAwLjQ3MSwgMC45MjJdLApbMC42MjcsIDAuNjI3LCAxLjAwMF0sClswLjc4NCwgMC43ODQsIDAuNzg0XSwKWzAuMzkyLCAwLjIyMCwgMC4yMzVdLApbMC40NzEsIDAuMTgwLCAwLjE1N10sClswLjU0OSwgMC4yOTgsIDAuMTU3XSwKWzAuNjY3LCAwLjM3NiwgMC4wMDBdLApbMC40NzEsIDAuMjIwLCAwLjM1M10sClswLjgyNCwgMC41NzMsIDAuNzA2XSwKWzAuNTQ5LCAwLjQzMSwgMC4wMDBdLApbMC40NzEsIDAuNTQ5LCAwLjcwNl0sClswLjYyNywgMC42NjcsIDAuOTQxXSwKWzAuNzQ1LCAwLjc4NCwgMC45ODBdLApbMC44NjMsIDAuOTQxLCAxLjAwMF0sClsxLjAwMCwgMS4wMDAsIDEuMDAwXV0p)
88+
[See it in EO Browser](https://sentinelshare.page.link/xtqG)
8389

8490
![dem contour lines](fig/fig2.jpg)
8591

8692
### Example 4
8793

88-
It is also possible to return contour lines of any color on top of a true color visualization of anoter satellite. However, for this, data fusion is needed. In the example below, Landsat 8 true color visualization was used under white contour lines.
94+
It is also possible to return contour lines of any color on top of a true color visualization of anoter satellite. However, for this, data fusion is needed. In the example below, Landsat 8 true color visualization was used under white contour lines.
8995

9096
[DEM contour lines over Landsat 8 data fusion script](https://custom-scripts.sentinel-hub.com/data-fusion/dem_contour_over_l8/)
9197

9298
![dem contour lines](fig/fig3.jpg)
9399

94100
## Authors of the scripts
95101

96-
- Peter Gabrovšek
97-
- Marko Repše
98-
- Monja Šebela
99-
100-
101-
102+
- Peter Gabrovšek
103+
- Marko Repše
104+
- Monja Šebela

landsat-8/built_up_index/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ permalink: /landsat-8/built_up_index/
77
nav_exclude: true
88
---
99

10-
1110
## Evaluate and visualize
12-
- [Sentinel Playground](https://apps.sentinel-hub.com/sentinel-playground/?source=L8&lat=43.67072749862282&lng=-79.36901092529297&zoom=12&preset=CUSTOM&layers=B01,B02,B03&maxcc=20&gain=1.0&gamma=1.0&time=2018-12-01%7C2019-06-07&atmFilter=&showDates=false&evalscript=LyoKQXV0aG9yOiBLYXJsIENoYXN0a28KKi8KCmxldCBuZHZpID0gKEIwNSAtIEIwNCkgLyAoQjA1ICsgQjA0KTsKCmxldCBuZGJpID0gKEIwNiAtIEIwNSkgLyAoQjA2ICsgQjA1KTsKCmxldCBCVSA9IChuZHZpIC0gbmRiaSkKCnJldHVybltCVV07Cg%3D%3D){:target="_blank"}
13-
- [EO Browser](https://apps.sentinel-hub.com/eo-browser/?lat=43.6531&lng=-79.3621&zoom=12&time=2019-05-06&preset=CUSTOM&datasource=Landsat%208%20USGS&layers=B01,B02,B03&evalscript=LyoKQXV0aG9yOiBLYXJsIENoYXN0a28KKi8KCmxldCBuZHZpID0gKEIwNSAtIEIwNCkgLyAoQjA1ICsgQjA0KTsKCmxldCBuZGJpID0gKEIwNiAtIEIwNSkgLyAoQjA2ICsgQjA1KTsKCmxldCBCVSA9IChuZHZpIC0gbmRiaSkKCnJldHVybltCVV07Cg%3D%3D){:target="_blank"}
1411

12+
- [EO Browser](https://apps.sentinel-hub.com/eo-browser/?lat=43.6531&lng=-79.3621&zoom=12&time=2019-05-06&preset=CUSTOM&datasource=Landsat%208%20USGS&layers=B01,B02,B03&evalscript=LyoKQXV0aG9yOiBLYXJsIENoYXN0a28KKi8KCmxldCBuZHZpID0gKEIwNSAtIEIwNCkgLyAoQjA1ICsgQjA0KTsKCmxldCBuZGJpID0gKEIwNiAtIEIwNSkgLyAoQjA2ICsgQjA1KTsKCmxldCBCVSA9IChuZHZpIC0gbmRiaSkKCnJldHVybltCVV07Cg%3D%3D){:target="\_blank"}
1513

1614
## General description of the script
1715

0 commit comments

Comments
 (0)