Skip to main content

fused.catalog

imagery​

imagery(
collection: str,
bounds: Any,
time: TimeRange | None = None,
bands: str | Sequence[str] | None = None,
mask_clouds: bool | None = None,
h3_res: int | None = None,
sql: str | None = None,
*,
max_cloud_pct: int = 100,
composite: str | None = None,
reducer: str | None = None,
output: str = "hex",
stats: str | Sequence[str] | None = None,
return_timings: bool = False
) -> pd.DataFrame | tuple[pd.DataFrame, dict[str, int]]

Read Harmonized Landsat Sentinel-2 imagery over an area.

With output="hex" (the default), each H3 cell whose centre is in the area takes the pixel under its centre, for every scene in the range, so the result has one row per cell and scene. Values are not averaged and keep the band's stored type. Scenes on different tile grids are each read on their own grid. With output="chip", the result has one row per scene and tile with the pixels of the area as they are stored. With output="stats", it has one row per polygon with statistics of its pixels per date.

With composite, the scenes of each period are reduced to one value per cell (or per pixel) and band instead of being returned one by one.

Parameters:

  • collection (str) – The collection to read, e.g. "hls2-l30" or "hls2-s30". fused.catalog.list() lists the available collections.
  • bounds (Any) – The area, in EPSG:4326: (west, south, east, north), or any geometry: a shapely geometry, or a GeoJSON geometry or Feature as a dict (a dict needs no shapely). A geometry may have at most 100,000 vertices: simplify a larger one or pass its bounds. Only the cells or pixels inside the geometry are returned; a polygon includes a pixel when the pixel's centre is inside it, and a line or point includes the pixels it touches. Each row of a GeoDataFrame or GeoSeries, or each geometry of a list or FeatureCollection, is a polygon on its own, at most 4,096, and with output="stats" a single geometry is one polygon (a box is sent as bounds, as for the other outputs). A frame or series in another CRS is sent in EPSG:4326 and returned as given.
  • time (TimeRange | None) – Dates to read, inclusive. A year ("2025"), a month ("2025-06") or a date ("2025-06-03") covers all of its days; a "start/end" string or a (start, end) pair of those, dates or datetimes covers from the first day of start to the last day of end, and either end of a pair may be None to leave it open. Default: every date.
  • bands (str | Sequence[str] | None) – Bands to return, in this order; a single name is one band. The result has exactly these band columns on every call, whether or not a scene is found. A file that stores several bands per pixel names each as "<asset>_b<k>", from 1, such as "image_b1" to "image_b4". A name the files read cannot give (the asset name alone of such a file, a number past its bands, or a number on a file of one band) is refused with the names to use. fused.catalog.list() gives the names where it knows them. Default: every band of the scenes found, sorted by name and, within such a file, by number.
  • mask_clouds (bool | None) – Mask pixels the scene's cloud mask band marks as cloud or as no data: HLS "fmask" (cloud, adjacent to cloud, cloud shadow), Sentinel-2 "SCL" (cloud shadow, medium or high probability cloud; saturated or defective is no data), Landsat "qa_pixel" (dilated cloud, cloud, cloud shadow) or ALOS PALSAR "mask" (layover, shadowing). Cirrus, snow and water are not masked. With output="hex", those pixels take the band's no-data value and rows with no data in any band are dropped. With output="chip", those pixels take each band's no-data value (-9999 for reflectance bands; for an unsigned band, its own no-data value or the type's largest value) and scenes with no clear pixel are left out. When off (the default except with output="stats"), nothing is masked and no scene is left out. mask_clouds=True on a collection with no cloud mask band is an error; output="stats" reads such a collection unmasked.
  • h3_res (int | None) – H3 resolution of the cells, 0 to 15. Default: the coarsest resolution whose cells are no larger than a pixel of the finest tile grid read, so 12 for 30 m pixels, 13 for 10 m and 5 for 0.25 degrees. Only for output="hex".
  • sql (str | None) – A DuckDB SQL query to run over the result, available as the table df. With several polygons, its rows are grouped per polygon only when it keeps system_index.
  • max_cloud_pct (int) – Skip a scene whose percentage of cloud pixels (as mask_clouds marks them) among its pixels with data inside the area (each polygon on its own) is above this value, 0 to 100, before any composite. Default: 100, keep every scene. A value below 100 needs cloud masking and raises a ValueError without it, and is an error on a collection with no cloud mask band.
  • composite (str | None) – Reduce the scenes of each period to one observation per cell (output="hex") or pixel (output="chip"): "day", "month" or "year" give one result per calendar period (UTC), "weekly" one per ISO week (Monday to Sunday), "biweekly" one per pair of ISO weeks of the ISO year (W01 and W02, and so on; W53 alone), and "all" one over the whole range. A scene counts only where every requested band has a valid value: not no-data, not NaN, and not masked when mask_clouds is on. Default: None or "none", one row per scene. For output="stats", the default is "day", and "none" takes, per polygon and date, the scene whose tile holds most of the polygon.
  • reducer (str | None) – How the valid observations of a period are combined with composite: "first" or "last" take the earliest or latest observation (all bands from the same scene), and "median", "mean", "min" and "max" combine each band on its own. Not with "none"; needs composite except for output="stats". Default: "first", or "median" for output="stats".
  • output (str) – "hex" for H3 cells, "chip" for the pixels of bounds in each scene, or "stats" for statistics of each polygon per date. A chip covers the geometry's bounding box, and its pixels outside the geometry are no data (-9999 for reflectance bands; for an unsigned band, its own no-data value or the type's largest value), cloud mask band included. With mask_clouds, a scene is kept only if some pixel inside the geometry is clear.
  • stats (str | Sequence[str] | None) – For output="stats", any of "mean", "std" (population), "min" and "max". Default: all four.
  • return_timings (bool) – Also return how long each step took.

Returns:

  • DataFrame | tuple[DataFrame, dict[str, int]] – With output="hex", a DataFrame with hex (the H3 cell id), one column per band in the band's stored type (int16 for reflectance bands), system_time_start (the scene's UTC timestamp, null for a scene with no date, such as an elevation model) only when time is given.

With output="chip", a DataFrame with one row per scene and tile grid the area touches: id (the scene), system_time_start (UTC timestamp), tile, epsg (the grid's coordinate system, 32767 when user-defined), crs ("EPSG:<code>", or the PROJ string of a user-defined system, for pyproj.CRS), geotransform (six floats in GDAL order: x of the chip's top-left corner, pixel width, 0, y of the corner, 0, pixel height, in crs), corners (longitude and latitude of the chip's top-left, top-right, bottom-right and bottom-left corners, eight floats, NaN for a corner outside the projection's domain), h and w (the chip's rows and columns), and one column per band with the chip's pixels as little-endian bytes of the band's stored type: int16 for reflectance bands, with -9999 for no data. With mask_clouds, masked pixels take the band's no-data value (-9999 for the reflectance bands; the band's own no-data value, or the type's largest value, for an unsigned band). Every scene of one tile has the same window.

With composite, the bands are float32 with NaN where a period has no observation, and system_time_start is the UTC timestamp of the period's start: midnight of the day, the Monday of the week or pair of weeks, the first of the month or 1 January; it is null for "all". With output="hex" the frame has hex, system_time_start and one column per band, a row for each cell and period with an observation. With output="chip" it has one row per period and grid with system_time_start, epsg, crs, geotransform, corners, h, w and one column per band of little-endian float32 bytes, on a grid that holds every chip of the period.

With output="stats", a GeoDataFrame with a row per polygon, in the order given: the polygon's own row (its columns or properties, and its geometry), then lists in date order, one value per UTC date it was seen (empty when none): system_time_start (the UTC timestamp of the period's start, or with "none" of the scene read), n_px (the polygon's pixels) and a float <band>_<stat> per band and statistic over the valid pixels (null when none is). An input column named like one of these gets _input added.

With several polygons, output="hex" and output="chip" also give a GeoDataFrame with a row per polygon, in the order given: the polygon's own row, then each column above as a list of what a request with that polygon alone would give, in its row order (empty when none).

With return_timings, a tuple of that frame and a dict mapping each step to its milliseconds.

Examples:

df = fused.catalog.imagery(
"hls2-l30",
(-122.5, 37.7, -122.4, 37.8),
time="2025-06-01/2025-06-30",
bands=["red", "nir"],
)

Read the pixels of a scene back as an array:

import numpy as np

chips = fused.catalog.imagery(
"hls2-l30",
(-122.5, 37.7, -122.4, 37.8),
time="2025-06-01/2025-06-30",
bands=["red"],
output="chip",
)
row = chips.iloc[0]
red = np.frombuffer(row.red, "<i2").reshape(row.h, row.w)

A monthly median per cell:

monthly = fused.catalog.imagery(
"hls2-l30",
(-122.5, 37.7, -122.4, 37.8),
time="2025-04-01/2025-09-30",
bands=["red", "nir"],
mask_clouds=True,
composite="month",
reducer="median",
)

The mean red and NIR of each field per date, with the columns of fields:

fields = gpd.read_file("fields.geojson")
df = fused.catalog.imagery(
"hls2-s30",
fields,
time="2025-06",
bands=["red", "nir"],
output="stats",
stats=["mean"],
)

list​

list() -> pd.DataFrame

List the imagery collections of the catalog.

Returns:

  • DataFrame – A DataFrame with one row per collection, sorted by name, and the columns name (pass it as collection), title (a display name), bands (a list of band names; a file known to store several bands per pixel lists each as <asset>_b<k>, from 1, and any other file is listed by its asset name), time_min and time_max (the first and last scene dates as YYYY-MM-DD, null for a collection whose scenes have no date, such as an elevation model), cadence (how often a place has a new scene: sub-daily, daily, weekly, monthly, yearly, or static for a single date), resolution_m (the pixel size in metres), mask_band (the band mask_clouds masks by, such as "fmask" or "SCL") and unreadable_reason (why fused.catalog.imagery cannot read it, null when it can). title, cadence, resolution_m and mask_band are null where they are not known.

Examples:

collections = fused.catalog.list()
collections[["name", "cadence", "time_min", "time_max"]]