rasteret.core.execution¶
Data loading pipeline: iterate collection records, fetch tiles, and merge results into NumPy, xarray, or GeoDataFrame outputs.
This module powers Collection.get_numpy(...), Collection.get_xarray(...),
Collection.get_gdf(...), and Collection.sample_points(...).
bands is required because each raster in the collection may contain dozens
of assets (bands). Specifying which bands to load avoids fetching unnecessary
data and keeps memory usage predictable.
execution
¶
Data loading pipeline for Collection reads.
This module orchestrates the read path:
- Iterate records in the Collection
- Load bands concurrently via COGReader
- Merge results into xarray.Dataset or geopandas.GeoDataFrame
Users access this via Collection.get_xarray(), Collection.get_gdf(),
and Collection.get_numpy().
Classes¶
Functions¶
get_collection_xarray
¶
get_collection_xarray(
*,
collection: "Collection",
geometries: Any,
bands: list[str],
data_source: str | None = None,
max_concurrent: int = 50,
backend: object | None = None,
target_crs: int | None = None,
geometry_crs: GeometryCrsInput = AUTO_CRS,
geometry_column: str | None = None,
all_touched: bool = False,
progress: bool = False,
xr_combine: str = "combine_first",
**filters: Any,
) -> Dataset
Load selected bands as an xarray.Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Collection
|
Source collection. |
required |
geometries
|
bbox tuple, pa.Array, Shapely, WKB bytes, or GeoJSON dict
|
Area(s) of interest. |
required |
bands
|
list of str
|
Band codes to load (e.g. |
required |
data_source
|
str
|
Override the inferred data source for band mapping and URL signing. |
None
|
max_concurrent
|
int
|
Maximum concurrent HTTP requests (default 50). |
50
|
backend
|
StorageBackend
|
Pluggable I/O backend (e.g. |
None
|
target_crs
|
int
|
Reproject all records to this EPSG code before merging. When
|
None
|
geometry_column
|
str
|
Geometry column to read when |
None
|
all_touched
|
bool
|
Passed through to polygon masking behavior. |
False
|
xr_combine
|
str
|
Strategy for merging per-record xarray Datasets.
|
'combine_first'
|
filters
|
kwargs
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Band arrays in native COG dtype (e.g. |
Examples:
>>> ds = get_collection_xarray(
... collection=col,
... geometries=(77.55, 13.01, 77.58, 13.08),
... bands=["B04", "B08"],
... )
>>> ds.B04.dtype
dtype('uint16')
Source code in src/rasteret/core/execution.py
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 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 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 | |
get_collection_gdf
¶
get_collection_gdf(
*,
collection: "Collection",
geometries: Any,
bands: list[str],
data_source: str | None = None,
max_concurrent: int = 50,
backend: object | None = None,
target_crs: int | None = None,
geometry_crs: GeometryCrsInput = AUTO_CRS,
geometry_column: str | None = None,
all_touched: bool = False,
progress: bool = False,
**filters: Any,
) -> GeoDataFrame
Load selected bands as a geopandas.GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Collection
|
Source collection. |
required |
geometries
|
bbox tuple, pa.Array, Shapely, WKB bytes, or GeoJSON dict
|
Area(s) of interest. |
required |
bands
|
list of str
|
Band codes to load. |
required |
data_source
|
str
|
Override the inferred data source. |
None
|
max_concurrent
|
int
|
Maximum concurrent HTTP requests (default 50). |
50
|
backend
|
StorageBackend
|
Pluggable I/O backend. |
None
|
target_crs
|
int
|
Reproject all records to this EPSG code before building the GeoDataFrame. |
None
|
geometry_column
|
str
|
Geometry column to read when |
None
|
all_touched
|
bool
|
Passed through to polygon masking behavior. |
False
|
filters
|
kwargs
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
Band arrays in native COG dtype. Each row is a geometry-record pair with pixel data and the read-window transform as columns. |
Source code in src/rasteret/core/execution.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 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 | |
get_collection_numpy
¶
get_collection_numpy(
*,
collection: "Collection",
geometries: Any,
bands: list[str],
data_source: str | None = None,
max_concurrent: int = 50,
progress: bool = False,
backend: object | None = None,
target_crs: int | None = None,
geometry_crs: GeometryCrsInput = AUTO_CRS,
geometry_column: str | None = None,
all_touched: bool = False,
**filters: Any,
)
Load selected bands as NumPy arrays without xarray merge overhead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Collection
|
Source collection. |
required |
geometries
|
bbox tuple, pa.Array, Shapely, WKB bytes, or GeoJSON dict
|
Area(s) of interest. |
required |
bands
|
list of str
|
Band codes to load. |
required |
data_source
|
str
|
Override the inferred data source. |
None
|
max_concurrent
|
int
|
Maximum concurrent HTTP requests. |
50
|
backend
|
StorageBackend
|
Pluggable I/O backend. |
None
|
target_crs
|
int
|
Reproject all records to this CRS before assembling arrays. |
None
|
geometry_column
|
str
|
Geometry column to read when |
None
|
all_touched
|
bool
|
Passed through to polygon masking behavior. |
False
|
filters
|
kwargs
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Single-band queries return |
Notes
All selected samples must resolve to a consistent shape per band.
A ValueError is raised for ragged outputs.
Source code in src/rasteret/core/execution.py
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 799 800 801 802 803 804 805 806 807 808 | |