Sentinel-3 data Visualization in EO Browser using a Custom Script

Custom script to create natural color and other visualizations from Sentinel-3 data

Sentinel-3 image of Queensland, Australia

Sentinel-3 image of Queensland, Australia

Creating Sentinel-3 images

A few people kept asking me how I process Sentinel-3 data in my images. Usually it is a mixture of things, I start with images processed by a custom script in the Sentinel Hub EO Browser and then further process those in Photoshop. However, even with custom scripts alone you can usually get very usable results.

Still, giving a single script will always be a bit limiting, as I usually change my settings a lot depending on the scene. This script here is a good start and allows for easy customization, it also allows to easily change the variables to adjust the result in regard to colors, contrast, and brightness. Have fun experimenting with it. And as I say again and again, don’t hesitate to use more than one tool. Custom scripts are a wonderful way to get quick results, but sometimes those images are just the beginning. Use QGIS or Photoshop, or whatever tool you feel comfortable with, and make them even better.

The Script

// Sentinel-3 data Visualization V1.0.0
// Twitter: Pierre Markuse (@pierre_markuse)
// Website: https://pierre-markuse.net/
// CC BY 4.0 International - https://creativecommons.org/licenses/by/4.0/
function stretch(val, min, max) {return (val - min) / (max - min);}
function blend(bArr1, bArr2, opa1, opa2) {
    return bArr1.map(function(num, index) {
        return (num / 100 * opa1 + bArr2[index] / 100 * opa2);
    });
}

var NaturalColors1 = [1.0 * B07 + 1.4 * B09 - 0.1 * B14, 1.1 * B05 + 1.4 * B06 - 0.2 * B14, (2.6 * B04 - B14 * 0.6)*1.00];
var NaturalColors2 = [1.0 * B07 + 1.4 * B09 - 0.2 * B14, 1.0 * B05 + 1.5 * B06 - 0.45 * B14, (2.6 * B04 - B14 * 1.0)*1.02];
var NaturalColors3 = [1.0 * B07 + 1.4 * B09 - 0.3 * B14, 1.0 * B05 + 1.5 * B06 - 0.6 * B14, (2.6 * B04 - B14 * 1.2)*1.03];
var NIR = [2.0 * B14, 2.0 * B07, 2.0 * B04];
var AC = [2 * B14, 2 * B14, 2 * B14];

var layer1 = NaturalColors1; // Visualization layer 1
var layer2 = NIR; // Visualization layer 2
var layer1Amount = 100; // Amount layer 1
var layer2Amount = 0; // Amount layer 2
var stretchMin = 0.15; //Change black point
var stretchMax = 0.80; //Change white point
var saturation = 0.00; //Change saturation in percent
var brightness = 1.50; //Brightness, default=1.5
var manualCorrection = [0.00, 0.00,0.00]; //Manual correction of RGB values

var visualization = blend(layer1, layer2, layer1Amount, layer2Amount);
var result = [visualization[0] * brightness, visualization[1] * brightness, visualization[2] * brightness];
result = [stretch(result[0],stretchMin,stretchMax)+manualCorrection[0],stretch(result[1],stretchMin,stretchMax)+manualCorrection[1],stretch(result[2],stretchMin,stretchMax)+manualCorrection[2]];
var avg = (result[0]+result[1]+result[2])/3;
saturation = saturation * (-1);
if (result[0]>avg) { result[0]=result[0]-(result[0]-avg)/100*saturation } else {result[0]=result[0]+(avg-result[0])/100*saturation};
if (result[1]>avg) { result[1]=result[1]-(result[1]-avg)/100*saturation } else {result[1]=result[1]+(avg-result[1])/100*saturation};
if (result[2]>avg) { result[2]=result[2]-(result[2]-avg)/100*saturation } else {result[2]=result[2]+(avg-result[2])/100*saturation};

return result;

Copy and paste the script or right-click and download it here. Together with many other scripts it is also available in the Sentinel Hub Custom Script Repository.

A few explanations

The script should be pretty much self-explanatory. But here are a few things that might be useful.

var layer1 = NaturalColors1; // Visualization layer 1
var layer2 = NIR; // Visualization layer 2
var layer1Amount = 100; // Amount layer 1
var layer2Amount = 0; // Amount layer 2

The script supports two visualizations that are active at the same time and can be mixed. You can either use the predefined visualizations or come up with your own. The layer1Amount and layer2Amount variables define the visibility of the layer. This can also be used to lighten up a dark image (by setting the amount to a value over 100) or to subtract one visualization from the other (by setting one of them to a negative value).

var stretchMin = 0.15; //Change black point
var stretchMax = 0.80; //Change white point

An easy way to help with the contrast of the resulting image. Values below stretchMin will be rendered black, values above stretchMax will be rendered white.

var saturation = 0.00; //Change saturation in percent
var brightness = 1.50; //Brightness, default=1.5

Use saturation to change the color saturation of the image, negative values will desaturate the image, with a value of -100.0 resulting in a monochromatic image. Brightness can be used to get the resulting image brighter or darker. Default for the pre-defined visualizations is 1.5, but feel free to experiment.

var manualCorrection = [0.00, 0.00,0.00]; //Manual correction of RGB values

More or less a “cheat” variable. You can use it to adjust the RGB balance in the image. Positive values will be added to the image, negative values subtracted. Can be useful to get a more natural looking image.

Examples

Here are a few examples of images created with the script and no further post-processing. The script includes three slightly different natural color visualizations, you should try them all. I tried to get a balanced color result with nice water colors, however, depending on the scene you might have to adapt it a bit.

Sentinel-3 image of Beira, Mozambique

NaturalColors1 visualization, as you will see with the following two visualizations, the differences between those predefined natural color visualizations are subtle, but  you should give them a try in different scenes, and don’t shy away from using the other settings to get the perfect image. Image is centered on Beira, Mozambique. Date is March 25th, 2019.

Sentinel-3 image of Beira, Mozambique

NaturalColors2 visualization. Showing more contrast.

Sentinel-3 image of Beira, Mozambique

NaturalColors3 visualization. Even more contrast, but depending on the scene sometimes better than the other versions.

Sentinel-3 image of Beira, Mozambique

NIR, using one NIR channel for red, quite nice in showing sediments.

Sentinel-3 image of Beira, Mozambique

AC, just a monochromatic view using band 14.

Sentinel-3 image of Beira, Mozambique

Close-up view using NaturalColors2.

Sentinel-3 image of Queensland, Australia

And another NaturalColors2 image, showing Queensland, Australia.

Feedback / Questions

If you have some kind of feedback or questions regarding this script, or ideas how it could be made better, feel free to share. Comment on this post or contact me via email or on . I would also very much like to see images you create with the script, so in case you do, let me know where I can find them or tag me in your images on Twitter. You might also want to follow for news about the EO Browser.

In case you have general questions about the EO Browser you should read this FAQ and register at the Sentinel Hub Forum here to ask questions or maybe contribute your own scripts for the EO Browser.

Should you find settings and combinations that work particularly well, maybe consider to post an example image along with the settings used to the Sentinel Hub Forum, so other users can benefit from it as well.

Further reading

You might also want to take a look at my wildfire visualization script, which actually can be used to visualize a lot more than just wildfires using Sentinel-2 data. You can read more about it here in this blog post.

If you are new to remote sensing I would also recommend that you read my blog post “Satellite Image Guide for Journalists and Media” and my guest blog post “Why Newsrooms need People with Expertise in Remote Sensing” on the Sentinel Hub blog.

Sentinel Hub Custom Script Contest

Sentinel Hub Custom Script Contest

If you have a useful script yourself or a good idea that you could turn into a custom script for the Sentinel Hub EO Browser maybe consider to take part in the Sentinel Hub Custom Script Contest. You can hand in scripts in different categories and maybe even win a trip to the ESA Centre for Earth Observation near Rome, Italy.

Take part on your own or as part of group and make remote sensing data more accessible and easier to use with your custom script.

You can learn more about the contest here on the contest website.

To get you started, maybe take a look at the scripts already in the Custom Script Repository?

Images if not otherwise stated: Contains modified Copernicus Sentinel data [2019], processed by Pierre Markuse, CC BY 4.0 license