Custom Script Tutorial

Create Beautiful Satellite Images with EO Browser

Home > Explore > Education > Custom Scripts Tutorial

Would you like to create beautiful and informative satellite images? This short guide will show you how.

This is a step-by-step tutorial for those interested in exploring custom satellite visualizations in EO Browser. After selecting the data, we will take a look at how to quickly create custom color composites. Next, we will start scripting and learn how to control the results better. Finally, we will examine the Betsiboka river delta example, where we will create a useful and appealing visualization.

Below is a short version of the tutorial, to get you started. It is also available in a video format on Youtube.

For the full tutorial, with a lot more to learn, check out our friendly pdf.

1. Search for Data 

We are going to be using the EO Browser application, that allows easy access to free satellite data. We will be using the Sentinel-2 satellite.

First, we will choose the data for the visualization. Follow the short steps below.

  • First, open the EO Browser.
  • Next, you can pan the window to your area of interest. We recommend you choose a vegetated area, since we will be working with vegetation. You can also simply stay in Italy, as is default.
  • You can use the deafult search criteria and skip to the next step. If you want to play with the search criterias a bit, you can lower the Max. cloud coverage or change the Time range like on the image below (left).
  • Scroll down and confirm by clicking search.
  • Choose one of the results, that covers your area well and has low cloud coverage by selecting visualize, like on the image below (right).
  • For more information on how to use the EO Browser, consult the Sentinel Hub user guide.

 

2. Create a Color Composite

Open the tabs below to learn how to create your first color composite.

 

The EO Browser already offers some visualization options, but since we want to create one ourselves, we will select the  Custom option on top. The drag and drop panel opens, where we can create custom images quickly. Hover the mouse over the circles to see basic information for each band.

EO Browser 
 

If we want to create a colorful image, we need to input 3 out of 13 available  bands  into the bottom 3 circles with the R (red), G (green) and B (blue) letters, also called color channels. This way we combine the bands with the corresponding colors and create a color composite, such as on the diagram below.

EO Browser

If we input bands B04 (red light), B03 (green) and B02 (blue) into the R, G, and B circles, respectively, we will get a true color image. Any other combination will produce a false color composite. The example below (right) uses band 8, which displays vegetation, band 4, which highlights bare ground areas and band 2 to produce the image, that shows vegetation in red.

EO Browser EO Browser

3. Start Scripting!

Sometimes we need more control over how we display the bands, e.g., we want a certain band to appear brighter. This is where we use custom scripts. Custom scripts are javascript code used to control the visualization and processing of satellite images with Sentinel Hub.  They allow the user to quickly calculate different band combinations and visualize them, without previously downloading data. Don’t worry, this is a complete beginner tutorial for those not familiar in programming.

To access custom scripts, click on the green hand symbol under custom, to toggle between draggable bands and custom scripts (</>).

 

As the white javascript window opens, you can start changing the code. When you’re done, scroll down and click refresh, since the image won’t update automatically.

To create the same composites as above, in the scripting window, we would simply write the bands by hand after the return statement, wrap them inside the square brackets and separate them with commas. Additionally, we multiply the bands by 2.5 to increase their brightness. In the first, false color example below, band B04 is visualized with red (R), since it is the first element in the brackets, band B03 with green (B), since it is second and B02 with blue, since it is third.

return [ B04 * 2.5, B03 * 2.5, B02 * 2.5 ]; // examine in EO Browser.
return [ B08 * 2.5, B04 * 2.5, B03 * 2.5 ]; // examine in EO Browser.

4. Visualise the Betsiboka River Delta

Let’s try out a fun challenge. We will visualize the Madagascar Betsiboka river delta, in an informative and appealing way. Open the tabs below to follow the steps. 

Below is the true color composite, we will try to enhance. Click on the image below to open it in the EO Browser.

Let’s suppose we want to separate vegetation from non-vegetation and highlight river sedimentation. To achieve that, we can input band 8 (vegetation) into the green channel, band 4 (bare ground) into the red channel and band 2 (which is used for deep water analysis) into the blue channel. We also multiply them by 2.5.

return [ B04 * 2.5, B08 * 2.5, B02 * 2.5 ]; // examine in EO Browser.

We can see, that band 8 is very bright and we can't see sedimentation or non-vegetated areas well.

Let’s increase the brightness of red and blue channels by increasing the value factor we multiply them with to 5.5

return [ B04 * 3.5, B08 * 2.5, B02 * 3.5 ]; // examine in EO Browser.

Although the result we got is informative enough, the image would be more expressive, if we increased the red values further. This is now only a matter of aesthetics and experimentation. Let’s increase the value of band 4 to 5.5.

return [ B04 * 5.5, B08 * 2.5, B02 * 3.5 ]; // examine in EO Browser.

Now we have created a color composite, that displays deeper water in dark purple, sedimentation and shallow waters in red, bare ground in orange and pink and vegetation in green.


You should take some time to practice and experiment. Try out different values and bands. Note that custom scripts can be used for scientific, as well as aesthetic purposes. Think about whether your script is useful to you.

There is a lot more to learn. If you would like to:

  • understand why certain bands highlight certain types of objects,
  • how color works,
  • create useful maps by implementing indices,
  • create your own custom color classes or
  • create continuous color scales,

we prepared a friendly guide in the pdf below. If you continue reading, you will understand everything we did above in depth and be able to create useful satellite visualizations yourself.

It’s time to create your own satellite visualizations!