Skip to main content

EarthNet Minicuber

Project description

EarthNet Minicuber

A Python library for creating EarthNet-style minicubes.

PyPI License Twitter

GitHub: https://github.com/earthnet2021/earthnet-minicuber

PyPI: https://pypi.org/project/earthnet-minicuber/

This package creates minicubes from cloud storage using STAC catalogues. A minicube usually contains a satellite image time series of Sentinel 2 imagery alongside other complementary information, all re-gridded to a common grid. This package implements a cloud mask based on deep learning, which allows for analysis-ready Sentinel 2 imagery.

It is currently under development, thus do expect bugs and please report them!

Tutorial

  1. Loading the package
import earthnet_minicuber as emc
  1. Creating a dictionary with specifications of the desired minicube
specs = {
    "lon_lat": (43.598946, 3.087414), # center pixel
    "xy_shape": (256, 256), # width, height of cutout around center pixel
    "resolution": 20, # in meters.. will use this on a local UTM grid..
    "time_interval": "2021-07-01/2021-07-31",
    "providers": [
        {
            "name": "s2",
            "kwargs": {"bands": ["B02", "B03", "B04", "B8A"], "best_orbit_filter": True, "five_daily_filter": False, "brdf_correction": True, "cloud_mask": True, "aws_bucket": "planetary_computer"}
        },
        {
            "name": "s1",
            "kwargs": {"bands": ["vv", "vh"], "speckle_filter": True, "speckle_filter_kwargs": {"type": "lee", "size": 9}, "aws_bucket": "planetary_computer"} 
        },
        {
            "name": "ndviclim",
            "kwargs": {"bands": ["mean", "std"]}
        },
        {
            "name": "cop",
            "kwargs": {}
        },
        {
            "name": "esawc",
            "kwargs": {"bands": ["lc"], "aws_bucket": "planetary_computer"}
        }
        ]
}
  1. Downloading the minicube
mc = emc.load_minicube(specs, compute = True)
  1. Plotting cloud-masked Sentinel 2 RGB imagery
emc.plot_rgb(mc)

See notebooks/example.ipynb for a more detailed usage example.

Data Providers

The minicuber is centered around the concept of data providers, which wrap a data source and handle data loading of that source. The emc.Minicuber class then manages these data providers, by telling them the spatio-temporal range for which data needs to be loaded and afterwards re-gridding all data to a common reference frame (UTM grid).

Sentinel 2

The Sentinel 2 provider loads and processes Copernicus Sentinel 2 imagery.

Kwargs:

  • bands: choose any subset from ["B01", "B02", "B03", "B04", "B05", "B06", "B07", "B08", "B8A", "B09", "B11", "B12", "WVP", "AOT", "SCL"].
  • aws_bucket: We currently support data loading from three cloud buckets: Microsoft Planetary Computer ("planetary_computer"), Element84 AWS bucket (element84) and DigitalEarthAfrica AWS bucket (dea). We recommend using the Microsoft planetary computer with the keyword argument aws_bucket = "planetary_computer".
  • best_orbit_filter: Sentinel 2 has a regular overpass frequency of 5 days. However, sometimes it can be smaller due to off-nadir captures. Such captures change the viewing angle of the scene. If True, this filter finds the best orbit and then only returns imagery from a regular 5-daily cycle.
  • five_daily_filter: If True returns a regular 5-daily cycle starting with the first date in full_time_interval. It has no effect, if best_orbit_filter is used.
  • brdf_correction: If True, does BRDF correction based on the Sentinel 2 Metadata (illumination angles).
  • cloud_mask: If True, creates a cloud and cloud shadow mask based on deep learning. It automatically finds the best available cloud mask for the requested bands.
  • correct_processing_baseline: If True (default): corrects the shift of +1000 that exists in Sentinel 2 data with processing baseline >= 4.0

Installation

Prerequisites (We use an Anaconda environment):

conda create -n minicuber python=3.10 gdal cartopy -c conda-forge
conda deactivate
conda activate minicuber
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install scipy matplotlib seaborn netCDF4 xarray zarr dask shapely pillow pandas s3fs fsspec boto3 psycopg2 pystac-client stackstac planetary-computer rasterio[s3] rioxarray odc-algo segmentation-models-pytorch folium ipykernel ipywidgets sen2nbar

Install this package with PyPI:

pip install earthnet-minicuber

or install this package in developing mode with

git clone https://github.com/earthnet2021/earthnet-minicuber.git
cd earthnet-minicuber
pip install -e .

or directly with

pip install git+https://github.com/earthnet2021/earthnet-minicuber.git

Similar Packages

This package is build on top of stackstac, which allows accessing data stored in cloud-optimized geotiffs with xarray.

Similar to this package, cubo provides a high-level interface to stackstac.

Acknowledgement

This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 101004188 (DeepCube Horizon 2020). We are grateful to David Montero Loaiza for providing the sen2nbar package used for the Sentinel 2 BRDF correction. We are grateful to César Aybar and the CloudSEN12 team, their work forms the basis for the cloud mask implemented in earthnet-minicuber.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

earthnet-minicuber-0.1.2.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

earthnet_minicuber-0.1.2-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file earthnet-minicuber-0.1.2.tar.gz.

File metadata

  • Download URL: earthnet-minicuber-0.1.2.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for earthnet-minicuber-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4be50411c31a72df29a563d834774b8c1b87817e0be53896406253ecfe18506e
MD5 f6151614314cce49e8b0757de16b9f01
BLAKE2b-256 4764f4ea2836761aa7408c5961d9c22942b0397010c3a25646bb5e084a96ec91

See more details on using hashes here.

File details

Details for the file earthnet_minicuber-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for earthnet_minicuber-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3c113630e238c37aad9aa23462fc8bb8e88d9ea575d87dbb46061139805261a
MD5 73aa2e347e97fdb7ac3774b7a7df243c
BLAKE2b-256 09655137986edacb42c3d6074c6d4a48b35d723e6a28cc66e606ac930f4b7277

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page