Sources — geocatalog.sources¶
Discover scenes in external archives: the Source protocol, the
STAC / CMR / earthaccess / Earth Engine adapters, and building a
catalog straight from STAC. Adapters are extras-gated and imported
lazily.
Protocol¶
geocatalog.sources.Source
¶
Bases: Protocol
A remote catalog that can be queried by bounds + interval.
Implementations live in geocatalog._src.sources.<name> and are
extras-gated: EarthAccessSource requires
pip install 'geotoolz-catalog[earthaccess]', etc. Importing this
Protocol never pulls in any optional dependency.
Two methods. query returns an iterator (so adapters can
stream paginated results); auth_status is the introspection
hook callers use to fail fast.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/_base.py
auth_status()
¶
Report whether the adapter can talk to its upstream.
Never raises. Tools can call this before query to surface
login problems early; query itself raises on auth failures.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/_base.py
query(bounds, interval=None, *, collection=None, filters=None, limit=None)
¶
Yield matching rows from the upstream catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Bounds
|
|
required |
interval
|
Interval | None
|
Optional time window. |
None
|
collection
|
str | None
|
Upstream collection / short-name. Adapters that target a single collection may ignore this; most require it. |
None
|
filters
|
Mapping[str, Any] | None
|
Free-form key/value pairs forwarded to the
upstream API (e.g. STAC's CQL-2 filters, earthaccess's
|
None
|
limit
|
int | None
|
Cap on the number of rows returned. |
None
|
Yields:
| Type | Description |
|---|---|
SourceRow
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/_base.py
geocatalog.sources.SourceRow
dataclass
¶
Normalized output of every Source.query adapter.
Decoupled from the existing in-catalog CatalogRow because the
set of fields is broader (STAC-style asset map, per-row provenance,
sensor-specific properties). Ingestion maps SourceRow to a
CatalogRow by promoting the primary asset to filepath and
folding the rest into extras. See design §4.3.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Stable identifier — granule UR, STAC item id, EE asset
path. Round-trips into |
source |
str
|
Stable adapter name ( |
collection |
str
|
Upstream collection identifier — e.g.
|
geometry |
BaseGeometry
|
Footprint polygon (or multipolygon) in EPSG:4326. The catalog will reproject into its target CRS at ingestion time. |
interval |
Interval
|
Observation time window. |
assets |
Mapping[str, str]
|
Mapping of asset key → URI. For STAC this is the
native asset map; for earthaccess it's the granule's
data-URL set; for GEE it's a single |
properties |
Mapping[str, Any]
|
Sensor-specific metadata — cloud cover, sun zenith, orbit number, processing level, etc. Carried opaquely. |
provenance |
Mapping[str, Any]
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/_base.py
geocatalog.sources.AuthStatus
dataclass
¶
Reported by Source.auth_status so callers can fail fast.
Adapters never raise on construction; they raise on
query / ingest if credentials are missing. auth_status
is the introspection hook for tooling that wants to surface "you
need to log in" before kicking off a long workflow.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/_base.py
STAC (extras: [stac])¶
geocatalog.sources.STACSource
¶
Bases: Source
STAC API data discovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Root STAC API URL (the catalog landing page). |
required |
sign_assets
|
bool
|
If |
False
|
name
|
str
|
Stable adapter identifier. Defaults to |
'stac'
|
Examples:
>>> src = STACSource.planetary_computer()
>>> rows = list(src.query(
... bounds=(-10, 35, 5, 45),
... interval=pd.Interval(
... pd.Timestamp("2024-06-01", tz="UTC"),
... pd.Timestamp("2024-06-30", tz="UTC"),
... closed="both",
... ),
... collection="sentinel-2-l2a",
... filters={"eo:cloud_cover": {"lt": 20}},
... limit=10,
... ))
>>> rows[0].assets["B04"] # signed red-band URL
'https://sentinel2l2a01.blob.core.windows.net/...?...&sig=...'
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/stac.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
client
property
¶
Lazily-opened, cached pystac_client.Client.
auth_status()
¶
Open the client and probe the root catalog.
Most public STAC catalogs (PC, Earth Search) don't actually gate the search endpoint — auth is on individual assets (PC blob SAS, USGS M2M token). So "authenticated" here really means "the endpoint is reachable and serves STAC".
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/stac.py
earth_search()
classmethod
¶
Element 84 Earth Search — public AWS-hosted Sentinel/Landsat.
planetary_computer()
classmethod
¶
Microsoft Planetary Computer — signs blob URLs automatically.
query(bounds, interval=None, *, collection=None, filters=None, limit=None)
¶
Yield SourceRows for STAC items matching the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Bounds
|
|
required |
interval
|
Interval | None
|
Optional time window. STAC's |
None
|
collection
|
str | None
|
STAC collection id (e.g. |
None
|
filters
|
Mapping[str, Any] | None
|
Forwarded to pystac-client's |
None
|
limit
|
int | None
|
Cap on the number of items. |
None
|
Yields:
| Type | Description |
|---|---|
SourceRow
|
|
SourceRow
|
downloads asset data. Asset URLs are signed in place if |
SourceRow
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/stac.py
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
earthaccess (extras: [earthaccess])¶
geocatalog.sources.EarthAccessSource
¶
Bases: Source
NASA CMR / earthaccess data discovery.
Construct without arguments; authentication is handled by the
underlying earthaccess library (earthaccess.login() or a
netrc / token in the standard locations). Call auth_status
to check whether credentials are usable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
daac
|
str | None
|
Optional DAAC short-name filter (e.g. |
None
|
cloud_hosted
|
bool | None
|
When True, restrict to Earthdata-Cloud granules. Useful if you want direct S3 reads downstream and don't care about on-prem holdings. |
None
|
retries
|
int
|
Retries of the search call on transient failures
(network errors, HTTP 408 / 429 / 5xx). |
3
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/earthaccess.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 | |
auth_status()
¶
Check whether earthaccess is logged in.
Builds a requests session via
earthaccess.get_requests_https_session() and inspects
the earthaccess.__auth__ singleton's authenticated
flag — a cheap, non-network probe of the cached login
state. The adapter does not call earthaccess.login()
automatically; surface the bare credential state and let
the caller decide whether to prompt for credentials.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/earthaccess.py
query(bounds, interval=None, *, collection=None, filters=None, limit=None)
¶
Yield SourceRows for CMR granules matching the query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Bounds
|
|
required |
interval
|
Interval | None
|
Optional time window. earthaccess expects
|
None
|
collection
|
str | None
|
CMR |
None
|
filters
|
Mapping[str, Any] | None
|
Forwarded as additional kwargs to
|
None
|
limit
|
int | None
|
Cap on the number of granules. |
None
|
Yields:
| Type | Description |
|---|---|
SourceRow
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/earthaccess.py
CMR¶
geocatalog.sources.CMRSource
¶
Bases: Source
Direct CMR REST adapter.
Construct without arguments. Anonymous queries cover most public
collections; restricted ones need an EDL bearer token via the
token argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
Optional EDL bearer token for protected collections. |
None
|
endpoint
|
str
|
CMR root URL — override for non-prod environments. |
_CMR_ROOT
|
retries
|
int
|
Retries per page on transient failures (network
errors, HTTP 408 / 429 / 5xx). |
3
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/cmr.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
auth_status()
¶
Probe the CMR root.
Anonymous queries against public collections always work,
so "authenticated" here means "we can reach the endpoint".
Token presence is reported via detail.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/cmr.py
query(bounds, interval=None, *, collection=None, filters=None, limit=None)
¶
Yield SourceRows for CMR granules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Bounds
|
|
required |
interval
|
Interval | None
|
Optional time window → |
None
|
collection
|
str | None
|
CMR |
None
|
filters
|
Mapping[str, Any] | None
|
Forwarded directly as URL parameters. Useful for
|
None
|
limit
|
int | None
|
Cap on rows. |
None
|
Yields:
| Type | Description |
|---|---|
SourceRow
|
|
SourceRow
|
so a large collection doesn't materialise in one chunk. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/cmr.py
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 | |
Earth Engine (extras: [gee])¶
geocatalog.sources.GEESource
¶
Bases: Source
Google Earth Engine asset discovery.
Construct without arguments; authentication is handled by the
underlying ee client (ee.Authenticate() + ee.Initialize()
or a service-account credentials file). Call auth_status to
check.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
str | None
|
GCP project the EE API requests are billed to. Some collections refuse anonymous reads; pin a project here. |
None
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/gee.py
auth_status()
¶
Report whether the ee client can reach Earth Engine.
Scaffolding — not yet implemented (design §8).
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always, until the adapter is implemented. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/gee.py
query(bounds, interval=None, *, collection=None, filters=None, limit=None)
¶
Enumerate EE assets intersecting bounds + interval.
Scaffolding — not yet implemented (design §8). The shared
limit contract already holds: limit=0 yields nothing
and a negative limit raises ValueError.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
For any query that could return rows,
until the staging layer can materialize |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/sources/gee.py
Catalogs from STAC (extras: [stac])¶
geocatalog.sources.from_stac_items(items, *, asset_key='data', engine='memory', crs=None, out_path=None, extra_properties=())
¶
Build a raster catalog from STAC items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
Iterable[Item]
|
STAC items to index. |
required |
asset_key
|
str | Literal['*']
|
Asset key to index. Pass |
'data'
|
engine
|
StorageEngine
|
|
'memory'
|
crs
|
Any | None
|
Optional CRS for catalog footprints. Item geometries are
lon/lat (EPSG:4326) and are reprojected, with edge
densification, when supplied. ( |
None
|
out_path
|
Path | None
|
GeoParquet destination required by |
None
|
extra_properties
|
Sequence[str]
|
STAC property keys to preserve as catalog columns. Must not name one of the columns the builder writes itself. |
()
|
Returns:
| Type | Description |
|---|---|
GeoCatalog
|
A raster |
GeoCatalog
|
Footprints come from |
GeoCatalog
|
the geometry is missing), split at the antimeridian; |
GeoCatalog
|
the asset's native CRS from the projection extension |
``proj
|
code |
``proj
|
projjson |
GeoCatalog
|
|
GeoCatalog
|
(re-sign them, e.g. with |
GeoCatalog
|
reading once the token has lapsed). Times are naive UTC. |
GeoCatalog
|
An item with neither a geometry nor a bbox, or with no time, is |
GeoCatalog
|
skipped with a warning. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/storage/stac.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 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 | |
geocatalog.sources.from_stac_search(client, *, collections, bounds=None, datetime=None, asset_key='data', engine='memory', limit=None, crs=None, out_path=None, extra_properties=())
¶
Run a STAC API search and build a raster catalog from its items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Any | str
|
Open |
required |
collections
|
Sequence[str]
|
Collection IDs to search. |
required |
bounds
|
tuple[float, float, float, float] | None
|
Optional lon/lat search box |
None
|
datetime
|
str | None
|
Optional STAC datetime interval string. |
None
|
asset_key
|
str | Literal['*']
|
Asset key to index. Pass |
'data'
|
engine
|
StorageEngine
|
|
'memory'
|
limit
|
int | None
|
Optional maximum number of returned search items to index.
( |
None
|
crs
|
Any | None
|
Optional CRS for catalog footprints. ( |
None
|
out_path
|
Path | None
|
GeoParquet destination required by |
None
|
extra_properties
|
Sequence[str]
|
STAC property keys to preserve as catalog columns. |
()
|
Returns:
| Type | Description |
|---|---|
GeoCatalog
|
A raster |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/storage/stac.py
To export a catalog as a STAC collection, see
to_stac_collection.
Source rows to catalog rows¶
geocatalog.sources.source_row_to_gdf_row(row, *, crs, primary_asset=None)
¶
Map a SourceRow to a flat dict suitable for a GeoDataFrame row.
Output keys:
* geometry: the footprint, reprojected from EPSG:4326 to
crs if necessary.
* start_time / end_time: pulled from the interval.
* filepath: chosen asset URL (see primary_asset resolution).
* id, source, collection: as-is from the SourceRow.
* assets, properties, provenance: JSON-encoded
dicts (Parquet can't store nested dicts directly without
schema acrobatics; JSON-as-string is the boring-but-robust path).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row
|
SourceRow
|
The source row to convert. |
required |
crs
|
CRS
|
CRS to reproject the geometry into. SourceRow geometries come in EPSG:4326 by convention. |
required |
primary_asset
|
str | None
|
Asset key to promote to |
None
|
Raises:
| Type | Description |
|---|---|
KeyError
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/storage/bundle.py
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 | |