rasteret¶
Top-level entry points for building, loading, and extending collections.
Most users need only a few of these:
build()- build a Collection from the catalog by ID.build_from_stac()/build_from_table()- full-control builders for STAC APIs or existing Parquet.load()- reload a previously built Collection from Parquet.register()- add a custom catalog entry to the in-memory registry.register_local()- register a local Collection as a catalog entry (persists to~/.rasteret/datasets.local.json).create_backend()- create an authenticated I/O backend for multi-cloud reads.
See Getting Started for usage examples.
rasteret
¶
Functions¶
build
¶
build(
dataset: str,
*,
name: str,
bbox: tuple[float, float, float, float] | None = None,
date_range: tuple[str, str] | None = None,
workspace_dir: str | Path | None = None,
force: bool = False,
max_concurrent: int = 50,
query: dict[str, Any] | None = None,
prefer_geoparquet: bool = False,
stac_api: str | None = None,
cloud_config: Any = None,
backend: "StorageBackend | None" = None,
) -> "Collection"
Build a Collection from a registered dataset.
Looks up dataset in the :class:~rasteret.catalog.DatasetRegistry
and routes to :func:build_from_stac or :func:build_from_table
based on the descriptor's access fields.
For descriptors backed only by geoparquet_uri (for example local
collections registered with :func:register_local), bbox and
date_range are optional and ignored.
For auth-required datasets, Rasteret can auto-create a backend from a
descriptor's s3_credentials_url when no explicit backend is passed.
This requires valid credentials in the environment (or ~/.netrc)
for the relevant provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Registry ID (e.g. |
required |
name
|
str
|
Logical name for the collection. |
required |
bbox
|
tuple of float
|
|
None
|
date_range
|
tuple of str
|
|
None
|
workspace_dir
|
str or Path
|
Cache directory. Defaults to |
None
|
force
|
bool
|
Rebuild even if a cache already exists. |
False
|
max_concurrent
|
int
|
Maximum concurrent COG header fetches. |
50
|
query
|
dict
|
Additional STAC search parameters. |
None
|
prefer_geoparquet
|
bool
|
Use the GeoParquet path when available. |
False
|
stac_api
|
str
|
Override the descriptor's default STAC API endpoint. |
None
|
cloud_config
|
CloudConfig
|
Cloud configuration for URL rewriting. |
None
|
backend
|
StorageBackend
|
I/O backend for authenticated range reads. When omitted,
Rasteret auto-creates one for known auth-required datasets.
See :func: |
None
|
Returns:
| Type | Description |
|---|---|
Collection
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If dataset is not in the registry. |
ValueError
|
If the descriptor has no configured access method, or if auth is required but no backend could be created. |
Source code in src/rasteret/__init__.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
build_from_stac
¶
build_from_stac(
*,
name: str,
stac_api: str,
collection: str,
data_source: str | None = None,
band_map: dict[str, str] | None = None,
band_index_map: dict[str, int] | None = None,
bbox: tuple[float, float, float, float] | None = None,
date_range: tuple[str, str] | None = None,
workspace_dir: str | Path | None = None,
force: bool = False,
max_concurrent: int = 50,
cloud_config: Any = None,
query: dict[str, Any] | None = None,
backend: "StorageBackend | None" = None,
static_catalog: bool = False,
) -> "Collection"
Build or load a local Parquet-backed collection from a STAC API.
Searches STAC, parses COG headers for tile metadata, and stores everything in a local Parquet index. On subsequent calls with the same parameters, Rasteret reuses the cached index (no STAC query / header parsing), but pixel reads still fetch remote tiles unless assets are local.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logical name for the collection. |
required |
stac_api
|
str
|
STAC API endpoint URL. |
required |
collection
|
str
|
STAC collection ID (e.g. |
required |
data_source
|
str
|
Optional Rasteret data-source key used for band mapping and cloud config
lookup. Defaults to collection. Use this to namespace provider-specific
conventions (e.g. |
None
|
band_map
|
dict
|
Optional mapping of band code to STAC asset key. When omitted, Rasteret falls back to built-in mappings for known collections. |
None
|
band_index_map
|
dict
|
Optional mapping of band code to the 0-based band/sample index within a
multi-sample GeoTIFF asset. Required when multiple requested bands map
to the same STAC asset key (e.g. a single multi-band |
None
|
bbox
|
tuple of float
|
|
None
|
date_range
|
tuple of str
|
|
None
|
workspace_dir
|
str or Path
|
Directory for the local cache. Defaults to |
None
|
force
|
bool
|
Rebuild even if a cache already exists. |
False
|
max_concurrent
|
int
|
Maximum concurrent COG header fetch operations. |
50
|
cloud_config
|
CloudConfig
|
Cloud configuration for URL rewriting. |
None
|
query
|
dict
|
Additional STAC search query parameters. |
None
|
backend
|
StorageBackend
|
I/O backend for authenticated range reads during COG header
parsing. See :func: |
None
|
Returns:
| Type | Description |
|---|---|
Collection
|
|
Source code in src/rasteret/__init__.py
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 | |
build_from_table
¶
build_from_table(
path: "str | Path | pa.Table | pads.Dataset",
*,
name: str = "",
data_source: str = "",
workspace_dir: str | Path | None = None,
column_map: dict[str, str] | None = None,
href_column: str | None = None,
band_index_map: dict[str, int] | None = None,
url_rewrite_patterns: dict[str, str] | None = None,
filesystem: Any | None = None,
columns: list[str] | None = None,
filter_expr: Any | None = None,
enrich_cog: bool = False,
band_codes: list[str] | None = None,
cloud_config: Any = None,
max_concurrent: int = 300,
force: bool = False,
backend: "StorageBackend | None" = None,
) -> "Collection"
Build a Collection from a Parquet/GeoParquet record table.
A record table is a Parquet dataset where each row is a raster item
(satellite scene, drone image, derived product, etc.) with at minimum
id, datetime, geometry, assets, or columns that can
be normalised into them via column_map and href_column.
When enrich_cog=True, COG headers are parsed from the asset URLs
and cached as {band}_metadata struct columns in the Parquet index,
enabling fast tiled reads and TorchGeo integration.
When name is provided and workspace_dir is omitted, the collection
is persisted to ~/rasteret_workspace/{name}_records/ so that it is
discoverable via :meth:Collection.list_collections and the CLI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str, Path, or pyarrow object
|
Path/URI to a Parquet/GeoParquet file or dataset directory, or
an in-memory Arrow object ( |
required |
name
|
str
|
Optional collection name. When given without workspace_dir, the collection is cached in the default workspace. |
''
|
data_source
|
str
|
Data source identifier for band mapping and URL policy. |
''
|
workspace_dir
|
str or Path
|
Persist the collection as partitioned Parquet at this path.
Defaults to |
None
|
column_map
|
dict
|
|
None
|
href_column
|
str
|
Column containing COG URLs. When set and |
None
|
band_index_map
|
dict
|
|
None
|
url_rewrite_patterns
|
dict
|
|
None
|
filesystem
|
FileSystem
|
PyArrow filesystem for reading remote URIs (e.g.
|
None
|
columns
|
list of str
|
Scan-time column projection. |
None
|
filter_expr
|
Expression
|
Scan-time predicate pushdown. |
None
|
enrich_cog
|
bool
|
Parse COG headers and add per-band metadata columns. |
False
|
band_codes
|
list of str
|
Bands to enrich. Defaults to all bands in |
None
|
cloud_config
|
CloudConfig
|
Cloud configuration for URL rewriting. |
None
|
max_concurrent
|
int
|
Maximum concurrent HTTP connections for COG header parsing. |
300
|
force
|
bool
|
Rebuild even if a cached collection already exists at the resolved workspace path. |
False
|
backend
|
StorageBackend
|
I/O backend for authenticated range reads during COG header
parsing. See :func: |
None
|
Returns:
| Type | Description |
|---|---|
Collection
|
|
Source code in src/rasteret/__init__.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 | |
create_backend
¶
create_backend(
credential_provider: Any = None,
cloud_config: Any = None,
region: str | None = None,
default_s3_config: dict[str, str] | None = None,
) -> Any
Create an I/O backend for authenticated cloud reads.
Pass the result as backend= to
:meth:~rasteret.core.collection.Collection.get_xarray or
:meth:~rasteret.core.collection.Collection.get_gdf.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_provider
|
object
|
An obstore credential provider, e.g.
|
None
|
cloud_config
|
CloudConfig
|
Cloud configuration for S3 URL rewriting and per-bucket overrides. |
None
|
region
|
str
|
Convenience alias for |
None
|
default_s3_config
|
dict
|
Default S3Store config applied to all buckets that don't have
per-bucket overrides (e.g. |
None
|
Examples:
>>> from obstore.auth.planetary_computer import PlanetaryComputerCredentialProvider
>>> pc_asset_url = "https://naipeuwest.blob.core.windows.net/naip/v002/"
>>> backend = rasteret.create_backend(
... credential_provider=PlanetaryComputerCredentialProvider(pc_asset_url)
... )
>>> ds = collection.get_xarray(geometries=aoi, bands=["B04"], backend=backend)
Source code in src/rasteret/__init__.py
load
¶
Load an existing Rasteret Collection from Parquet.
Use this when you've previously built a collection with
:func:build_from_stac or :func:build_from_table and want
to reload it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the Parquet file or dataset directory. |
required |
name
|
str
|
Optional name override. |
''
|
Returns:
| Type | Description |
|---|---|
Collection
|
|
Source code in src/rasteret/__init__.py
register
¶
Register a dataset descriptor in the global registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
descriptor
|
DatasetDescriptor
|
The descriptor to register. See :class: |
required |
Source code in src/rasteret/__init__.py
register_local
¶
register_local(
dataset_id: str,
path: str | Path,
*,
name: str | None = None,
description: str = "",
data_source: str = "",
persist: bool = True,
registry_path: str | Path | None = None,
) -> "DatasetDescriptor"
Register a local Parquet collection as a dataset descriptor.
This is useful when you want local/shared Collection Parquet artifacts
to appear in DatasetRegistry and CLI dataset commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Descriptor id (e.g. |
required |
path
|
str or Path
|
Path to a local Collection Parquet file or directory. |
required |
name
|
str
|
Human-readable dataset name. Defaults to the loaded collection name. |
None
|
description
|
str
|
Optional one-line description. |
''
|
data_source
|
str
|
Optional data source id. If omitted, inferred from collection metadata. |
''
|
persist
|
bool
|
When |
True
|
registry_path
|
str or Path
|
Override local registry JSON path (defaults to
|
None
|
Returns:
| Type | Description |
|---|---|
DatasetDescriptor
|
|
Source code in src/rasteret/__init__.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |