S3 Compatible Storage#

Let’s use EOReader with products stored in a S3 compatible storage cloud.

This tutorial is a bit tricky as EOReader uses rasterio and cloudpathlib libraries and they are currently handling S3 buckets differently.

Note: This is experimental for now, use it at your own risk !


  • S3 compatible storage is not well handled by rasterio for now, you should use Linux or Docker instead !
  • This tutorial assumes that you have correctly set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as environment variables
  • # Imports
    import os
    from cloudpathlib import S3Client, AnyPath
    import matplotlib.pyplot as plt
    import rasterio
    from eoreader.reader import Reader
    from eoreader.bands import MNDWI, CLOUDS
    # Other
    AWS_S3_ENDPOINT = os.getenv("AWS_S3_ENDPOINT")
    # Create your S3 compatible storage path with cloudpathlib
    # See here for more insights about this awesome lib: https://cloudpathlib.drivendata.org/
    client = S3Client(
    path = AnyPath("s3://sertit-eoreader-ci").joinpath(
    # Create an rasterio env to enable S3 compatible storage
    with rasterio.Env(
        # Create the reader
        reader = Reader()
        # Open your product
        prod = reader.open(path, remove_tmp=True)  # No need to unarchive here
        # Load this band
        band_ds = prod.load([MNDWI, CLOUDS])
    # Display
    nrows = len(band_ds)
    fig, axes = plt.subplots(nrows=nrows, figsize=(3 * nrows, 6 * nrows), subplot_kw={"box_aspect": 1})  # Square plots
    for i, band in enumerate(band_ds.values()):
        band[::10, ::10].plot(x="x", y="y", ax=axes[i])