Mapping deforestation with Sentinel Hub

Nicolas Karasiak
Jun 11 · 4 min read

Foreword by Sentinel Hub

This script by Nicolas Karasiak has won the second prize in the “Agriculture and Forestry” category of the Sentinel Hub Custom Script Contest. This post is part of a series of guest blog posts written by script authors, talking about some of their entries to our Custom Script Contest, giving some more insight in how the scripts are working and what can be achieved using them.

In addition to this script, which you can also find here on GitHub, Nicolas also wrote the winning script in the “Snow and Glaciers” category “Monthly snow report” which can be found here, and the second place script in the “Other scripts” category with his “Monthly composite” script, which can be found here.


Mapping deforestation with Sentinel Hub

Forests are essential for wildlife, biodiversity and to fight climate change. Mapping the forest cuts and its amplitude may be a way to raise awareness in order to initiate change in personal habits.

The NDVI (Normalized Difference Vegetation Index) is one of the most used indices in remote sensing. As the vegetation strongly reflects a part of the spectrum, comparing the red and the near infrared band allows to detect the vegetation easily. NDVI values ranges from -1 to 1, the higher this index is, the higher probability it is to have a vegetation. Generally values above 0.2 can be considered as vegetation, and forest is generally close to 1 during the summer. It is therefore possible to detect forest clear cuts using the difference of NDVI.

Highlighted in red, the deforestation in Brazil between 2017 and 2018 (GitHub)

How does the script detect the forest cuts?

Avoiding clouds

The script gathers the three months since the selected date to compute the mean NDVI and compares this value to the mean NDVI of these same three months but from the previous year. When the NDVI drop is at least 0.25, then the script considers that there is certainly a cut. In order to avoid clouds when computing the NDVI, and as the forest has a very low reflectance in the blue band unlike the clouds, each date with blue pixel above 0.18 is dismissed.

The script uses the three months from the current scene and the same three months from the previous year to detect forest cuts.

Getting the needed data

The function getNeededDates retrieves the three months since the selected image and handles the situation when the three months are in two different years (if the user chooses an image from February for example):

How to avoid crops in the detection?

Forests are often confused with crops as the NDVI is high for both of these two vegetation types. The easiest solution found is to compute the mean NDVI for each of the 3 months in the previous year and to track when each month’s NDVI is above 0.7. Crops rarely last 3 months with the NDVI this high. This method is not perfect but it allows to avoid a lot of cultivated fields.

Detection of forest cut from 2017 to 2018.

Representing the cuts and its probability

Code to saturate in red the clear cut

In order to represent the forest cuts, the higher the difference of NDVI between the two years, the more the script will represent the pixel in red. With this representation, and using a minimum NDVI difference of 0.25 as the lower threshold for detecting deforestation, confusions are rare. Or to put it simple, the more red a pixel is colored, the higher the confidence of deforestation.

Another caveat is, that the script can’t differentiate the reason of the forest loss. The forest could have been cut or have been lost in a wildfire. Another reason for a quick and big drop in the NDVI, and therefore a positive response of the script could be the usage of defoliant chemicals in an area.

Highlighted in red, the deforestation in Madagascar between 2017 and 2018 (GitHub)

We at Sentinel Hub would once again like to thank Nicolas for his participation in our Custom Script Contest. You can find Nicolas here on Twitter or read his personal blog here.

You may also want to take a look at the other scripts of the contest, you can find all the winning scripts here.

Should you want to read more about remote sensing and how custom scripts may be helpful tackling remote sensing problems take a look at our education pages. We are always working to extend those and you can already find interesting introductions into using remote sensing to take a look at volcanoes, wildfires, and measuring air pollution from space.

Sentinel Hub Blog

Stories from the next generation satellite imagery platform

Thanks to Pierre Markuse

Nicolas Karasiak

Written by

Phd in Remote Sensing, I study the potential of dense Satellite Image Time Series to map tree species. I write on www.karasiak.net :)

Sentinel Hub Blog

Stories from the next generation satellite imagery platform

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade