fused.bbox
delete_index
delete_index(
path: str,
*,
subset: str | Sequence[str] | None = None,
base_url: str | None = None
) -> dict[str, Any]
Delete your team's bbox index at path, or with subset (a folder
under path, or a non-empty list of them) only what is indexed under
those folders. The data files are untouched.
index
index(
path: str,
*,
bbox_columns: Sequence[str] | None = None,
time_column: str | None = None,
partition_columns: str | list[str] | None = None,
subset: dict[str, Any] | None = None,
redo: bool = False,
engine: str | None = "realtime",
visibility: str | None = None,
options: dict[str, Any] | None = None,
base_url: str | None = None
) -> TaskRun[Any] | Run
Index the parquet files under path, so fused.bbox.query can read
the rows in an area.
Running it again is incremental: only new, changed and removed files are indexed or dropped. A run that was stopped or partly failed resumes where it left off, and queries keep answering from the current index until the new one is ready.
Parameters:
- path (
str) – The folder to index, at any depth. - bbox_columns (
Sequence[str] | None) – The four columns holding each row's bounding box, as[xmin, ymin, xmax, ymax]. Only needed for files written neither byfused.ingestnor as GeoParquet with a bbox column. None keeps the columns the path was last indexed with. - time_column (
str | None) – A timestamp or date column of the files, or akey=valuefolder level holding aYYYY,YYYY-MMorYYYY-MM-DDperiod or an ISO timestamp. Letsfused.bbox.querytaketime_minandtime_max. Changing it on an indexed path needsredo=True. - partition_columns (
str | list[str] | None) – Thekey=valuefolder levels of the tree, in folder order: a single name or a list. - subset (
dict[str, Any] | None) – Limit the run to some folders, as{column: value or list of values}over the leading partition columns, or to some files with the key"file": a file name, a list of them, or glob patterns. - redo (
bool) – Read files again: withsubset, those files; without it, the whole tree from scratch, which is also how to change the indexed columns. - engine (
str | None) –"realtime"(the default) or a batch instance type such as"small", for a tree too large to read within a realtime run. - visibility (
str | None) –"team"(the default for a new index) or"public"(Fused admins only; the files must be publicly readable on S3). - options (
dict[str, Any] | None) –"workers": how many files are read at once."instances": how many instances share the work. - base_url (
str | None) – Base URL for the API. If None, uses the current environment.
Returns:
TaskRun[Any] | Run– A handle on the run:status(),done(),error(),logs(),tail().
index_status
index_status(
path: str, *, base_url: str | None = None
) -> dict[str, Any] | None
Describe the bbox index at path, or None when there is none.
Returns:
dict[str, Any] | None– A dictionary withpath,status("indexing"during the first run,"ready", or"failed"),indexing(True while a run is in progress),job_id,files,row_groups,rows,bytes,bounds(the box holding everything indexed),time_column(None when the index has none),indexed_as_of,last_run_finished_atandfailures(a list of{path, error}for files the last run could not index).
query
query(
path: str,
bbox: Bounds | None = None,
*,
polygon: PolygonLike = None,
cell: str | None = None,
time_min: TimeBound | None = None,
time_max: TimeBound | None = None,
columns: Iterable[str] | None = None,
base_url: str | None = None
) -> gpd.GeoDataFrame | pd.DataFrame
Read the rows under path in an area and, optionally, a time window.
Give at most one of bbox, polygon and cell; with none, every row is
read. A row is returned when its geometry is in the area: with bbox,
when the geometry's own bounding box overlaps or touches it; with
polygon or cell, when the geometry intersects it. Rows without a
geometry are left out of an area query, and in data without a geometry
column, rows near the area may be returned too. The result is a
GeoDataFrame when its columns include the geometry, with the CRS the
files declare.
Parameters:
- path (
str) – A location indexed withfused.bbox.index. - bbox (
Bounds | None) –(min_lng, min_lat, max_lng, max_lat), in the coordinates of the data. - polygon (
PolygonLike) – A geometry to select by, in the coordinates of the data: a shapely geometry, a GeoDataFrame or GeoSeries (the union of its geometries), a WKT string, WKB bytes, GeoJSON (a dict or JSON string), or an object with__geo_interface__. - cell (
str | None) – An H3 cell id (e.g."8928308280fffff"): the area it covers. Needs theh3package. For data in longitude and latitude. - time_min (
TimeBound | None) – Keep rows at or after this time: an ISO string or a datetime. Needs an index made withtime_column. When that is a folder level, every row of a folder whose period meets the window is kept. - time_max (
TimeBound | None) – Keep rows at or before this time. - columns (
Iterable[str] | None) – Read only these columns. A column only some files have is null in the rows of the others; one no file read has raises ValueError. - base_url (
str | None) – Base URL for the API. If None, uses the current environment.
row_groups
row_groups(
path: str,
bbox: Bounds | None = None,
*,
polygon: PolygonLike = None,
cell: str | None = None,
time_min: TimeBound | None = None,
time_max: TimeBound | None = None,
base_url: str | None = None
) -> pd.DataFrame
The indexed row groups under path that can hold rows in an area
and a time window.
Parameters:
- path (
str) – A location indexed withfused.bbox.index. - bbox (
Bounds | None) –(min_lng, min_lat, max_lng, max_lat), in the coordinates of the data. - polygon (
PolygonLike) – A geometry to select by instead ofbbox; seequery. - cell (
str | None) – An H3 cell to select by instead ofbbox; seequery. - time_min (
TimeBound | None) – Leave out row groups wholly before this time; seequery. - time_max (
TimeBound | None) – Leave out row groups wholly after this time; seequery. - base_url (
str | None) – Base URL for the API. If None, uses the current environment.
Returns:
DataFrame– One row per row group, in file then row-group order:path,row_group_index, its box (xmin,ymin,xmax,ymax),num_rows, its byte range in the file (start_offset,end_offset), and its range of the index's time column (time_min,time_max; null without one).
set_visibility
set_visibility(
path: str, visibility: str, *, base_url: str | None = None
) -> dict[str, Any]
Make your team's bbox index at path "team" (readable by your team
only) or "public" (readable by every Fused user). A public index needs
files that are publicly readable on S3.
Returns:
dict[str, Any]– The index summary, asfused.bbox.index_status.