1
- from typing import Any , AsyncIterator , Optional , Tuple
1
+ from typing import Any , AsyncIterator , Literal , Optional , Tuple
2
2
3
3
import arro3 .core
4
4
@@ -142,29 +142,6 @@ class DuckdbClient:
142
142
A list of STAC Collections
143
143
"""
144
144
145
- def migrate_href (href : str , version : Optional [str ] = None ) -> dict [str , Any ]:
146
- """
147
- Migrates a STAC dictionary at the given href to another version.
148
-
149
- Migration can be as simple as updating the `stac_version` attribute, but
150
- sometimes can be more complicated. For example, when migrating to v1.1.0,
151
- [eo:bands and raster:bands should be consolidated to the new bands
152
- structure](https://github.com/radiantearth/stac-spec/releases/tag/v1.1.0-beta.1).
153
-
154
- See [the stac-rs
155
- documentation](https://docs.rs/stac/latest/stac/enum.Version.html) for
156
- supported versions.
157
-
158
- Args:
159
- href (str): The href to read the STAC object from
160
- version (str | None): The version to migrate to. If not provided, the
161
- value will be migrated to the latest stable version.
162
-
163
- Examples:
164
- >>> item = stacrs.migrate_href("examples/simple-item.json", "1.1.0-beta.1")
165
- >>> assert item["stac_version"] == "1.1.0-beta.1"
166
- """
167
-
168
145
def migrate (value : dict [str , Any ], version : Optional [str ] = None ) -> dict [str , Any ]:
169
146
"""
170
147
Migrates a STAC dictionary to another version.
@@ -179,8 +156,8 @@ def migrate(value: dict[str, Any], version: Optional[str] = None) -> dict[str, A
179
156
supported versions.
180
157
181
158
Args:
182
- value (dict[str, Any]) : The STAC value to migrate
183
- version (str | None) : The version to migrate to. If not provided, the
159
+ value: The STAC value to migrate
160
+ version: The version to migrate to. If not provided, the
184
161
value will be migrated to the latest stable version.
185
162
186
163
Returns:
@@ -270,35 +247,35 @@ async def search(
270
247
Searches a STAC API server.
271
248
272
249
Args:
273
- href (str) : The STAC API to search.
274
- intersects (str | dict[str, Any] | GeoInterface | None) : Searches items
250
+ href: The STAC API to search.
251
+ intersects: Searches items
275
252
by performing intersection between their geometry and provided GeoJSON
276
253
geometry.
277
- ids (list[str] | None) : Array of Item ids to return.
278
- collections (list[str] | None) : Array of one or more Collection IDs that
254
+ ids: Array of Item ids to return.
255
+ collections: Array of one or more Collection IDs that
279
256
each matching Item must be in.
280
- max_items (int | None) : The maximum number of items to iterate through.
281
- limit (int | None) : The page size returned from the server. Use
257
+ max_items: The maximum number of items to iterate through.
258
+ limit: The page size returned from the server. Use
282
259
`max_items` to actually limit the number of items returned from this
283
260
function.
284
- bbox (list[float] | None) : Requested bounding box.
285
- datetime (str | None) : Single date+time, or a range (`/` separator),
261
+ bbox: Requested bounding box.
262
+ datetime: Single date+time, or a range (`/` separator),
286
263
formatted to RFC 3339, section 5.6. Use double dots .. for open
287
264
date ranges.
288
- include (list[str]] | None) : fields to include in the response (see [the
265
+ include: fields to include in the response (see [the
289
266
extension
290
267
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
291
268
for more on the semantics).
292
- exclude (list[str]] | None) : fields to exclude from the response (see [the
269
+ exclude: fields to exclude from the response (see [the
293
270
extension
294
271
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
295
272
for more on the semantics).
296
- sortby (list[str] | None) : Fields by which to sort results (use `-field` to sort descending).
297
- filter (str | dict[str, Any] | none) : CQL2 filter expression. Strings
273
+ sortby: Fields by which to sort results (use `-field` to sort descending).
274
+ filter: CQL2 filter expression. Strings
298
275
will be interpreted as cql2-text, dictionaries as cql2-json.
299
- query (dict[str, Any] | None) : Additional filtering based on properties.
276
+ query: Additional filtering based on properties.
300
277
It is recommended to use filter instead, if possible.
301
- use_duckdb (bool | None) : Query with DuckDB. If None and the href has a
278
+ use_duckdb: Query with DuckDB. If None and the href has a
302
279
'parquet' or 'geoparquet' extension, will be set to True. Defaults
303
280
to None.
304
281
kwargs: Additional parameters to pass in to the search.
@@ -340,40 +317,40 @@ async def search_to(
340
317
Searches a STAC API server and saves the result to an output file.
341
318
342
319
Args:
343
- outfile (str) : The output href. This can be a local file path, or any
320
+ outfile: The output href. This can be a local file path, or any
344
321
url scheme supported by [stac::object_store::write].
345
- href (str) : The STAC API to search.
346
- intersects (str | dict[str, Any] | GeoInterface | None) : Searches items
322
+ href: The STAC API to search.
323
+ intersects: Searches items
347
324
by performing intersection between their geometry and provided GeoJSON
348
325
geometry.
349
- ids (list[str] | None) : Array of Item ids to return.
350
- collections (list[str] | None) : Array of one or more Collection IDs that
326
+ ids: Array of Item ids to return.
327
+ collections: Array of one or more Collection IDs that
351
328
each matching Item must be in.
352
- max_items (int | None) : The maximum number of items to iterate through.
353
- limit (int | None) : The page size returned from the server. Use
329
+ max_items: The maximum number of items to iterate through.
330
+ limit: The page size returned from the server. Use
354
331
`max_items` to actually limit the number of items returned from this
355
332
function.
356
- bbox (list[float] | None) : Requested bounding box.
357
- datetime (str | None) : Single date+time, or a range ('/' separator),
333
+ bbox: Requested bounding box.
334
+ datetime: Single date+time, or a range ('/' separator),
358
335
formatted to RFC 3339, section 5.6. Use double dots .. for open
359
336
date ranges.
360
- include (list[str]] | None) : fields to include in the response (see [the
337
+ include: fields to include in the response (see [the
361
338
extension
362
339
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
363
340
for more on the semantics).
364
- exclude (list[str]] | None) : fields to exclude from the response (see [the
341
+ exclude: fields to exclude from the response (see [the
365
342
extension
366
343
docs](https://github.com/stac-api-extensions/fields?tab=readme-ov-file#includeexclude-semantics))
367
344
for more on the semantics).
368
- sortby (list[str] | None) : Fields by which to sort results (use `-field` to sort descending).
369
- filter (str | dict[str, Any] | none) : CQL2 filter expression. Strings
345
+ sortby: Fields by which to sort results (use `-field` to sort descending).
346
+ filter: CQL2 filter expression. Strings
370
347
will be interpreted as cql2-text, dictionaries as cql2-json.
371
- query (dict[str, Any] | None) : Additional filtering based on properties.
348
+ query: Additional filtering based on properties.
372
349
It is recommended to use filter instead, if possible.
373
- format (str | None) : The output format. If none, will be inferred from
350
+ format: The output format. If none, will be inferred from
374
351
the outfile extension, and if that fails will fall back to compact JSON.
375
- options (list[tuple[str, str]] | None) : Configuration values to pass to the object store backend.
376
- use_duckdb (bool | None) : Query with DuckDB. If None and the href has a
352
+ options: Configuration values to pass to the object store backend.
353
+ use_duckdb: Query with DuckDB. If None and the href has a
377
354
'parquet' or 'geoparquet' extension, will be set to True. Defaults
378
355
to None.
379
356
@@ -417,12 +394,12 @@ async def write(
417
394
Writes STAC to a href.
418
395
419
396
Args:
420
- href (str) : The href to write to
421
- value (dict[str, Any] | list[dict[str, Any]]) : The value to write. This
397
+ href: The href to write to
398
+ value: The value to write. This
422
399
can be a STAC dictionary or a list of items.
423
- format (str | None) : The output format to write. If not provided, will be
400
+ format: The output format to write. If not provided, will be
424
401
inferred from the href's extension.
425
- options (list[tuple[str, str]] | None) : Options for configuring an
402
+ options: Options for configuring an
426
403
object store, e.g. your AWS credentials.
427
404
428
405
Returns:
@@ -435,12 +412,18 @@ async def write(
435
412
>>> await stacrs.write("items.parquet", items)
436
413
"""
437
414
438
- def version (name : str | None = None ) -> str | None :
415
+ def version (
416
+ name : Literal ["stac" ]
417
+ | Literal ["stac-api" ]
418
+ | Literal ["stac-duckdb" ]
419
+ | Literal ["duckdb" ]
420
+ | None = None ,
421
+ ) -> str | None :
439
422
"""
440
423
Returns this package's version, or the version of a upstream.
441
424
442
425
Args:
443
- name (str | None) : The name of the upstream version to return. Valid
426
+ name: The name of the upstream version to return. Valid
444
427
values are "stac", "stac-api", "stac-duckdb", or "duckdb".
445
428
446
429
Returns:
0 commit comments