Sentinel-2¶
Overview¶
Sentinel-2 is a wide-swath, high-resolution, multi-spectral imaging mission supporting Copernicus Land Monitoring services. It provides optical imagery at 10m, 20m, and 60m resolution with a revisit time of 5 days at the equator.
In GeeFetch, Sentinel-2 data is accessed via the Google Earth Engine collection COPERNICUS/S2_SR (Surface Reflectance).
Processing¶
- Filtering by date range and area of interest
- Cloud masking using the
COPERNICUS/S2_CLOUD_PROBABILITYproduct (see configuration options)
a. Remove images whereCLOUDY_PIXEL_PERCENTAGE > 100 - cloudless_portion
b. Remove images whereHIGH_PROBA_CLOUDS_PERCENTAGE > 50 - cloudless_portion/2
c. Mask pixels which have a probability of being a cloud> cloud_prb_threshold
d. Mask pixels based on theQA60band - Resampling to target resolution
- Mosaicking of multiple images
- Scaling to maximize precision within the requested data type. Pixels outside of the range \((0, 3000)\) saturate. For instance, if the requested datatype is
uint8, the image is scaled by \(255/3000\).
Available Bands for download¶
| Band | Description | Native resolution | Download by default |
|---|---|---|---|
| B1 | Coastal aerosol | 60m | no |
| B2 | Blue | 10m | yes |
| B3 | Green | 10m | yes |
| B4 | Red | 10m | yes |
| B5 | Red Edge 1 | 20m | yes |
| B6 | Red Edge 2 | 20m | yes |
| B7 | Red Edge 3 | 20m | yes |
| B8 | NIR | 10m | yes |
| B8A | Narrow NIR | 20m | yes |
| B9 | Water vapor | 60m | no |
| B11 | SWIR 1 | 20m | yes |
| B12 | SWIR 2 | 20m | yes |
| QA60 | Cloud mask | 60m | no |
| AOT | Aerosol Optical Thickness | 10m | no |
| WVP | Water Vapor Pressure | 10m | no |
| SCL | Scene Classification | 20m | no |
| TCI_R | True Color Red | 10m | no |
| TCI_G | True Color Green | 10m | no |
| TCI_B | True Color Blue | 10m | no |
| MSK_CLDPRB | Cloud Probability | 20m | no |
Refer to COPERNICUS/S2_SR for more details.
Configuration Options¶
See common configuration options for non Sentinel-2-specific configuration. Additionnally, you may provide the following options.
Attributes:
| Name | Type | Description |
|---|---|---|
cloudless_portion |
int
|
Threshold for the portion of filled pixels that must be cloud/shadow free (%). Images that do not fullfill the requirement are filtered out before mosaicking. Default is 40. |
cloud_prb_threshold |
int
|
Threshold for cloud probability above which a pixel is filtered out (%). Default is 40. |
Example Usage¶
Command Line¶
Write the following config.yaml
data_dir: ~/satellite_data
satellite_default:
aoi:
spatial:
left: 2.2
bottom: 48.7
right: 2.5
top: 49
epsg: 4326
temporal:
start_date: "2023-06-01"
end_date: "2023-06-30"
gee:
ee_project_ids: ["your-gee-id"]
tile_size: 2000
resolution: 10
s2: # more scrict cloud filtering than the defaults
cloudless_portion: 60
cloud_prb_threshold: 20
then download with
Python API¶
Though this is not geefetch main intended use, you can bypass the configuration and directly download Sentinel-2 data with the geefetch.data.get.download_s2 function.
For instance, the CLI command above is roughly equivalent to
import logging
from pathlib import Path
from geobbox import GeoBoundingBox
from geefetch.data.get import download_s2
from geefetch.utils.gee import auth
from geefetch.utils.log import setup
setup(level=logging.INFO)
data_dir = Path("geefetch_data/")
data_dir.mkdir(exist_ok=True)
auth("your-gee-id")
download_s2(
data_dir,
bbox=GeoBoundingBox(2.2, 48.7, 2.5, 49),
start_date="2023-06-01",
end_date="2023-06-30",
tile_shape=2000,
cloudless_portion=60,
cloud_prb_thresh=20,
)
See the API reference of geefetch.data.get.download_s2 for more details.