sentinel-2-tif is a Python package that simplifies the process of generating georeferenced .tif images from Sentinel-2 Level-2A satellite data. It offers tools for spatial buffering, time window generation, scene compositing, and automatic .tif file creation using Microsoft’s Planetary Computer STAC API.
With this package, you will be able to generate multiple .tif images in a single data pull, each with different bounding box sizes and time windows. This flexibility is designed to help you efficiently explore and compare composite imagery, enabling you to identify the optimal composite for your analysis.
- Access Sentinel-2 L2A imagery via Planetary Computer
- Create minimum bounding rectangles (MBRs) from coordinates, a DataFrame, or a dictionary
- Generate bounding box buffers in kilometers
- Create symmetrical time windows around an event date
- Develop scene search grids with bounding box and time window combinations
- Composite scenes using
medianormean - Save georeferenced
.tifoutputs with full metadata - Designed for both notebook and production workflows
Install using pip:
pip install sentinel_2_tif# imports
from sentinel_2_tif.spatial import mbr_buffer, mbr_buffers
from sentinel_2_tif.temporal import time_wrapper, time_windows
from sentinel_2_tif.search import st_grid
from sentinel_2_tif.pipeline import tif_generator
from shapely.geometry import box
# instantiating minimim bounding rectangle (MBR)
bbox = mbr(west=-123.0, south=37.0, east=-121.0, north=38.5)
# generating a grid of spatial + temporal search combinations
scene_search = st_grid(
mbr=bbox,
buffers=[0, 1, 5],
wrap_sizes=[1, 2],
event_date="2022-08-07",
as_records=False
)
# pulling scenes and generating composite .tif(s)
summary = tif_generator(
scene_search=scene_search,
composite="median",
out_dir="./Collected TIFF Files"
)spatial: MBR and MBR buffer generationtemporal: Time window generation to expand scene selectionsearch: Spatial-temporal search grid generatorpipeline: Scene extraction and.tifwriter
MIT License. See LICENSE for details.