Scaling a Sentinel-2 Image Collection
Tutorial created by **David Montero Loaiza**: GitHub | Twitter
GitHub Repo: https://github.com/davemlz/eemont
PyPI link: https://pypi.org/project/eemont/
Conda-forge: https://anaconda.org/conda-forge/eemont
Documentation: https://eemont.readthedocs.io/
More tutorials: https://github.com/davemlz/eemont/tree/master/docs/tutorials
Let’s start!
If required, please uncomment:
[1]:
#!pip install eemont
#!pip install geemap
Import the required packages.
[2]:
import ee, eemont, geemap
Authenticate and Initialize Earth Engine and geemap.
[3]:
Map = geemap.Map()
Example point of interest to filter the image collection.
[4]:
point = ee.Geometry.Point([-75.92, 2.86])
Get and filter the Sentinel-2 Surface Reflectance image collection and filter it by region and time.
[5]:
S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(point)
.filterDate('2020-01-01','2021-01-01'))
Image Scaling
As you might know, most images in Google Earth Engine are scaled in order to fit the int datatype. To get the original values, scalars must be multiplied. This scaling changes with bands, and for the supported platforms, all bands are scaled using the scaleAndOffset() method, that is an extended method provided by the eemont package.
[6]:
S2a = S2.scaleAndOffset()
The scaleAndOffset() method does not require any additional argument, as it identifies the platform and scales the whole image collection.
Visualization
Set the visualization parameters.
[7]:
rgbUnscaled = {'min':0, 'max':3000, 'bands':['B4','B3','B2']}
rgbScaled = {'min':0, 'max':0.3, 'bands':['B4','B3','B2']}
Use geemap to display results.
[8]:
Map.centerObject(point,10)
Map.addLayer(S2.first(),rgbUnscaled,'Unscaled RGB')
Map.addLayer(S2a.first(),rgbScaled,'Scaled RGB')
Map