Patch — geocatalog.patch¶
The bridge to geopatcher: turn catalog rows
into a RasterField to split, or iterate a catalog's footprint as a
patcher Domain. field_for needs the [patch] extra.
Fields from a catalog¶
geocatalog.patch.field_for(catalog, slice_=None, *, asset=None, band_indexes=None, resampling=None, merge_method='last', nodata=None, materialize=True, mode='raster')
¶
Build a geopatcher RasterField over a staged catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog
|
InMemoryGeoCatalog
|
A raster catalog whose rows reference local files —
typically the output of |
required |
slice_
|
GeoSlice | None
|
The grid to build the field on: its bounds, CRS and
resolution. |
None
|
asset
|
str | None
|
Asset key to read from each row's |
None
|
band_indexes
|
Sequence[int] | None
|
1-indexed bands to keep (see |
None
|
resampling
|
Any | None
|
A |
None
|
merge_method
|
str
|
How overlapping rows combine (see |
'last'
|
nodata
|
float | None
|
Nodata override for the mosaic (see |
None
|
materialize
|
bool
|
|
True
|
mode
|
str
|
Field flavour; only |
'raster'
|
Returns:
| Type | Description |
|---|---|
RasterField | list[RasterField]
|
One |
Raises:
| Type | Description |
|---|---|
ImportError
|
If geopatcher, or (for |
TypeError
|
If |
ValueError
|
If |
KeyError
|
If |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/patch/field_for.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
A catalog as a patcher domain¶
geocatalog.patch.CatalogDomain
dataclass
¶
A patcher Domain view of a GeoCatalog.
Use this when you want to run a SpatialPatcher (or any consumer
that takes a Domain) across a multi-file archive instead of a
single in-RAM raster. Each catalog row becomes one sub-domain; the
patcher iterates them, the loader opens each in turn, the operator
runs per file, and stitching reassembles the result.
The dataclass is frozen=True so it can be cached, hashed, and
safely shipped across function boundaries — useful when feeding the
same domain into multiple parallel pipelines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog
|
GeoCatalog
|
The catalog being adapted. Any backend tag ( |
required |
resolution
|
tuple[float, float]
|
Target |
required |
Example
Tiled per-row inference across a multi-file S2 archive::
import geocatalog as gc
import numpy as np
catalog = gc.build.build_raster_catalog(paths)
domain = gc.patch.CatalogDomain(catalog, resolution=(10.0, 10.0))
for slice_ in domain.slices():
chip = gc.load.load_raster(catalog, slice_) # (C, H, W) GeoArray
predictions.append(model(np.asarray(chip)))
Source code in packages/geotoolz-catalog/src/geocatalog/_src/patch/domain.py
bounds
property
¶
Union bbox over the catalog — the outer envelope of every row.
Returns:
| Type | Description |
|---|---|
float
|
|
float
|
if the catalog is empty. |
crs
property
¶
The catalog's CRS — catalog.crs; never materialises rows.
__len__()
¶
get_config()
¶
Return a JSON-serialisable summary — for logging and audits.
Returns:
| Type | Description |
|---|---|
``{"catalog"
|
|
dict[str, Any]
|
Round-trippable through |
dict[str, Any]
|
own |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/patch/domain.py
slices()
¶
Materialise the catalog's per-row GeoSlice list.
Eager (returns a list) rather than lazy because most callers
want len(slices()) for progress bars or to shard work
upfront. Iterate the catalog's iter_slices directly if you
want streaming.
Returns:
| Type | Description |
|---|---|
Sequence[GeoSlice]
|
A list of |
Sequence[GeoSlice]
|
carrying this domain's |
Sequence[GeoSlice]
|
footprint + interval. |