Backends — geocatalog.backends¶
The catalog implementations behind the GeoCatalog protocol, the row
they yield, and the errors they raise. geocatalog.open_catalog picks
a backend for you.
In memory¶
geocatalog.backends.InMemoryGeoCatalog
¶
A geopandas.GeoDataFrame-backed catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
The catalog rows. Required columns: |
required |
kind
|
CatalogKind
|
|
required |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
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 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 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 | |
crs
property
¶
The catalog CRS (gdf.crs) as a pyproj.CRS.
temporal_extent
cached
property
¶
Tightest interval spanning every row's time window.
Returns:
| Type | Description |
|---|---|
Interval | None
|
``pd.Interval(min(start_times), max(end_times), |
Interval | None
|
closed='both') |
Interval | None
|
( |
total_bounds
cached
property
¶
Union bbox over all rows.
Returns:
| Type | Description |
|---|---|
float
|
|
float
|
NaNs if the catalog is empty. |
__len__()
¶
get_config()
¶
JSON-serialisable summary — kind, row count, CRS.
Returns:
| Type | Description |
|---|---|
``{"kind"
|
str, "len": int, "crs": str, "engine": "memory"}`` |
dict[str, Any]
|
(plus |
The CRS is `crs_config_string`
|
|
dict[str, Any]
|
when the CRS carries an authority id, else WKT2 — the same |
dict[str, Any]
|
string |
dict[str, Any]
|
and after a GeoParquet round trip. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
intersect(other, *, spatial_only=False, join='sjoin')
¶
Cross-catalog AND — rows whose footprints and times overlap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
InMemoryGeoCatalog
|
Another catalog, possibly of another kind. The
returned catalog has |
required |
spatial_only
|
bool
|
If True, ignore the temporal axis — useful for pairing imagery with static labels. |
False
|
join
|
_JOIN_T
|
Spatial-join method. |
'sjoin'
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
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 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 | |
iter_rows(*, batch_size=1024)
¶
Yield each row as a backend-neutral CatalogRow.
Streaming-friendly: rows are constructed lazily so a caller can
short-circuit a large catalog. batch_size is accepted for
Protocol parity with DuckDBGeoCatalog and is ignored here —
in-memory iteration is row-at-a-time regardless.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
int
|
Accepted for Protocol parity, ignored. |
1024
|
Yields:
| Type | Description |
|---|---|
CatalogRow
|
|
CatalogRow
|
the |
CatalogRow
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
iter_slices(*, resolution)
¶
Yield one GeoSlice per row, at the given target resolution.
Lazy — each GeoSlice is constructed on demand so callers can
short-circuit large catalogs. The slice's bounds come from
the row's footprint polygon, its interval from the
IntervalIndex entry, and crs from self.gdf.crs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
tuple[float, float]
|
|
required |
Yields:
| Type | Description |
|---|---|
GeoSlice
|
|
GeoSlice
|
footprints with a zero-width axis get a one-pixel extent on |
GeoSlice
|
that axis, centred on the footprint; rows with a missing or |
GeoSlice
|
empty footprint are skipped with a single warning. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
query(slice_=None, *, bounds=None, crs=None, time=None)
¶
Spatial + temporal filter on the catalog.
Either pass a GeoSlice (carries bounds/time/crs together) or
pass the parts. Bounds in a non-catalog CRS are reprojected
internally — the canonical anti-footgun path (§10.1 of the
design plan).
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
union(other)
¶
Cross-catalog OR — concatenate rows.
self's CRS and kind win. If other is in a
different CRS it's reprojected into self.crs first. The
kinds are not required to match: the caller is
responsible for ensuring it makes sense to treat the merged
rows uniformly (e.g. unioning two raster catalogs is fine;
unioning raster + vector would lie about what the result
indexes, but no exception is raised — the downstream loader
will catch it via its own kind check).
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
where(query)
¶
Filter by a non-geometric predicate — escape hatch via pandas .query().
Useful when the catalog carries extra columns (sensor, cloud %,
mission ID) and you want to filter on them without writing a
boolean mask by hand. The geometry / time axes are unaffected;
for those use query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
A pandas query string, e.g. |
required |
Returns:
| Type | Description |
|---|---|
InMemoryGeoCatalog
|
A new catalog with the matching rows; same kind, |
InMemoryGeoCatalog
|
same CRS. |
Example
imagery.where("mission == 'S2A' and cloud_pct < 20")
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/memory.py
DuckDB (extras: [duckdb])¶
geocatalog.backends.DuckDBGeoCatalog
¶
Lazy, SQL-backed catalog over a GeoParquet artifact.
Holds a DuckDB relation — a query plan, not materialised rows.
query / intersect / union return new relations; nothing
executes until iter_rows / materialize / gdf is touched.
The class implements the same GeoCatalog Protocol as
InMemoryGeoCatalog. Loaders that take catalog.gdf work but
materialise the relation on access — explicit callers should prefer
iter_rows for streaming.
Connection ownership is explicit: catalogs returned by open own
their DuckDB connection and close it from close or context-manager
exit. Catalogs derived from query / intersect / union share
their parent's connection and close() is a no-op for them. Even
a no-filter query returns a non-owning wrapper so calling close
on the result cannot close the parent catalog.
Derived catalogs additionally hold a strong reference back to the
originating owning catalog via _owner. This keeps the fluent
chain DuckDBGeoCatalog.open(path).query(...) safe: the
transitively-referenced owner stays alive (and its connection
open) as long as any derived catalog in the chain is reachable.
When a derived catalog is used as a context manager
(with cat.query(...) as out:), its __exit__ closes the
owning catalog so the underlying connection is released on block
exit. Calling close() directly on a derived catalog remains a
no-op — only __exit__ (or closing the owner directly) tears
down the shared connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relation
|
DuckDBPyRelation
|
A DuckDB relation whose columns include |
required |
con
|
DuckDBPyConnection
|
The connection that owns |
required |
crs
|
Any
|
CRS of the |
required |
kind
|
CatalogKind
|
|
required |
_owns_con
|
bool
|
Whether this catalog is responsible for closing
|
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
relation |
The underlying DuckDB relation; escape hatch for SQL power users. |
|
con |
DuckDBPyConnection | None
|
The associated connection. Set to |
crs |
|
|
kind |
The kind of data indexed (loader dispatch tag). |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
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 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 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 568 569 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 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 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 | |
gdf
cached
property
¶
Materialise the relation as a gpd.GeoDataFrame.
Cached — the first access executes the query; subsequent
accesses are O(1). This is the eager bridge that lets loaders
written against the in-memory backend work unchanged. For
streaming/scale callers, prefer iter_rows.
temporal_extent
cached
property
¶
Tightest interval over the relation — one SQL aggregate.
Returns:
| Type | Description |
|---|---|
Interval | None
|
|
Interval | None
|
or |
total_bounds
cached
property
¶
Union bbox over the relation — one SQL aggregate, not a scan.
Returns:
| Type | Description |
|---|---|
float
|
|
float
|
NaNs for an empty catalog. |
__len__()
¶
close()
¶
Close this catalog's DuckDB connection if it owns it.
No-op for derived catalogs (from query / intersect / union
/ sql) — they share the owner's connection and closing them
would invalidate sibling derivations. Use the owning catalog's
close, or a context manager on the owning instance, to tear
down the connection. A derived catalog used as a context
manager closes its owner on __exit__.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
from_memory(catalog, *, con=None)
classmethod
¶
Register an InMemoryGeoCatalog as a DuckDB relation.
Useful for upgrading a small in-RAM catalog into the SQL surface (e.g. to spatial-join two in-memory catalogs in parallel) without going through a Parquet round-trip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog
|
InMemoryGeoCatalog
|
The in-memory catalog to wrap. |
required |
con
|
DuckDBPyConnection | None
|
Optional DuckDB connection to register into. A fresh in-memory connection is created if omitted; ownership of an externally supplied connection stays with the caller (close is a no-op for it). |
None
|
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A |
DuckDBGeoCatalog
|
WKB-encoded copy of the gdf, so later changes to the gdf are |
DuckDBGeoCatalog
|
not seen. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
get_config()
¶
JSON-serialisable summary — kind, row count, CRS.
Returns:
| Type | Description |
|---|---|
``{"kind"
|
str, "len": int, "crs": str, "engine": "duckdb"}`` |
dict[str, Any]
|
(plus |
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
intersect(other, *, spatial_only=False)
¶
Cross-catalog AND via SQL spatial join.
Translates to SELECT ... FROM self JOIN other ON
ST_Intersects(self.geometry, other.geometry) [AND interval-overlap].
The DuckDB planner builds an R-tree on the smaller side and
probes with the larger; cost scales as O(n log n + m log n)
versus gpd.overlay's near-quadratic blow-up at scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
DuckDBGeoCatalog | InMemoryGeoCatalog
|
Another catalog. An |
required |
spatial_only
|
bool
|
If True, drop the temporal predicate. |
False
|
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A new |
DuckDBGeoCatalog
|
are clipped to |
DuckDBGeoCatalog
|
tightest overlap of left and right (or the left interval |
DuckDBGeoCatalog
|
when |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
iter_rows(*, batch_size=1024)
¶
Stream rows as CatalogRow instances in Arrow batches.
Streams the relation through DuckDB's Arrow record-batch reader,
so time-to-first-row and peak memory are O(batch_size) —
not O(len(catalog)) as the previous .df()-materialising
implementation was. Geometry WKB is decoded one vectorised
shapely.from_wkb call per batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
int
|
Rows per Arrow record batch. Bounds both the first-row latency and the peak memory of a full iteration. |
1024
|
Yields:
| Type | Description |
|---|---|
CatalogRow
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
iter_slices(*, resolution)
¶
Yield one GeoSlice per row at the given target resolution.
Lazy in shape but materialising in practice (delegates to
iter_rows). For very large catalogs, prefer to query down
first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
tuple[float, float]
|
|
required |
Yields:
| Type | Description |
|---|---|
GeoSlice
|
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
materialize()
¶
Execute the relation and wrap the result as an InMemoryGeoCatalog.
Decodes WKB to shapely geometries and rebuilds the
IntervalIndex from start_time / end_time. Useful for
moving the result into operations that need the full pandas /
geopandas surface (custom merges, plotting, debugging) but
defeats the lazy story — call after a selective query.
Returns:
| Type | Description |
|---|---|
InMemoryGeoCatalog
|
An |
InMemoryGeoCatalog
|
CRS, same kind. |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
open(source, *, kind=None, crs=None, retries=3, storage_options=None, strict=False)
classmethod
¶
Open a GeoParquet file (or directory of shards) lazily.
Reads the source via DuckDB's read_parquet; the relation
carries the schema but no rows are materialised until queried.
Local paths are supported directly. URI sources with s3://
(s3a://, s3n://), gs://, gcs://, http://,
https://, r2:// or hf:// auto-load DuckDB's httpfs
extension; az://, azure:// and abfss:// auto-load
DuckDB's azure extension.
CRS is recovered from the GeoParquet column metadata (PROJJSON)
for local files only — the metadata reader uses
pyarrow.parquet.read_metadata over a local Path. For URI
sources (s3://, https://, hf://, …) the auto-detect
cannot reach the remote object and silently falls back to the
EPSG:4326 default; a UserWarning is emitted in that case.
Pass crs= explicitly for remote sources to avoid the
fallback. (Remote GeoParquet CRS introspection would need an
fsspec/pyarrow filesystem hookup and is tracked separately.)
The kind is recovered from the reserved _backend
column written by to_geoparquet; ad-hoc parquet files lacking
it default to "raster" unless overridden.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path
|
Path or URI. A directory or glob ( |
required |
kind
|
CatalogKind | None
|
Kind override (loader dispatch). |
None
|
crs
|
Any | None
|
CRS override. |
None
|
retries
|
int
|
Number of retries for transient remote I/O failures.
|
3
|
storage_options
|
dict[str, Any] | None
|
Not supported by this backend — DuckDB reads
URIs natively via its |
None
|
strict
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
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 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 | |
query(slice_=None, *, bounds=None, crs=None, time=None)
¶
SQL spatial + temporal filter — lazy, returns a new relation.
Builds a WHERE clause that DuckDB can push down to the
Parquet reader (bbox-column predicates skip whole row-groups).
Mirrors InMemoryGeoCatalog.query; AOI bounds in a different
CRS are reprojected internally before being interpolated into
the SQL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slice_
|
GeoSlice | None
|
A |
None
|
bounds
|
tuple[float, float, float, float] | None
|
|
None
|
crs
|
Any | None
|
CRS of |
None
|
time
|
tuple[Any, Any] | Interval | None
|
Either a |
None
|
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A new |
DuckDBGeoCatalog
|
empty; |
Raises:
| Type | Description |
|---|---|
TypeError
|
If both |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
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 | |
sql(where)
¶
Apply an arbitrary SQL WHERE clause — escape hatch.
Lets users write predicates the structured query API doesn't
cover (cloud_pct < 5 AND sensor = 'S2A'). The result is
still a DuckDBGeoCatalog, so further query / intersect /
union calls chain off it.
Warning
where is spliced into the SQL as written — it is not
parameterised or escaped. Pass trusted input only; never
build it from user-supplied strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
where
|
str
|
The body of a SQL |
required |
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A filtered |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
to_geoparquet(path, *, write_covering_bbox=True)
¶
Persist the relation as a GeoParquet file.
Materialises the relation, then routes through the existing
geopandas writer so the resulting Parquet carries proper
GeoParquet metadata (column CRS, bbox covering struct in 1.1).
DuckDB's native GeoParquet writer is newer and less battle-tested
— going through geopandas avoids that adoption caveat (§10.2 of
the design plan).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Destination path. |
required |
write_covering_bbox
|
bool
|
Emit the per-row bbox covering struct that GeoParquet 1.1 readers (DuckDB, geopandas) use for predicate pushdown. Default True. |
True
|
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
union(other)
¶
Cross-catalog OR via SQL UNION ALL.
self's CRS and kind win. other is reprojected
into self.crs if needed before the union. Schemas must be
compatible for the columns both sides share; extra columns on
one side become NULL on the other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
DuckDBGeoCatalog | InMemoryGeoCatalog
|
Catalog to concatenate. Reprojected if needed. |
required |
Returns:
| Type | Description |
|---|---|
DuckDBGeoCatalog
|
A new |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/backends/duckdb_backend.py
Rows¶
geocatalog.backends.CatalogRow
dataclass
¶
Backend-neutral view of a single catalog row.
Yielded by GeoCatalog.iter_rows; consumed by loaders and the
geopatcher bridge. The dataclass exists so streaming code
(DuckDB cursors, on-disk shards) can hand rows downstream without
callers caring whether the row came from a gpd.GeoDataFrame or a
SQL relation.
Attributes:
| Name | Type | Description |
|---|---|---|
filepath |
str
|
Path or URI of the indexed file. The loader resolves this with the configured reader class. |
geometry |
BaseGeometry
|
Footprint polygon (or multipolygon) in |
interval |
Interval
|
Time window for the row, |
crs |
CRS
|
Coordinate reference of |
extras |
dict[str, Any]
|
Backend-specific metadata ( |
Source code in packages/geotoolz-catalog/src/geocatalog/_src/base.py
state
property
¶
The row's model-state fields, typed; None for a non-state row.
A row is a state row when it has a run_time extra
(is_state_frame). Reads the reserved state columns out of
extras, with nulls as None whatever the backend returned
(NaN, NaT, a numpy array for parents).
Errors¶
Errors about a catalog's state or artifacts derive from
GeoCatalogError and from the builtin callers caught before
(ValueError / RuntimeError). Invalid arguments raise the builtin
ValueError / TypeError; see the
parameter vocabulary.
geocatalog.backends.GeoCatalogError
¶
Bases: Exception
Base class of the errors about a catalog's state or its artifacts.
A closed catalog, unreadable metadata, an unsupported schema version.
Invalid arguments (an unknown kind or engine, malformed
bounds) raise the builtin ValueError / TypeError, and an
unparsable CRS raises pyproj.exceptions.CRSError, so catch those
as well when you want every failure. Each subclass also derives from
the builtin a caller would have caught before the hierarchy existed
(ValueError, RuntimeError), so except ValueError keeps working.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/base.py
geocatalog.backends.CatalogSchemaError
¶
Bases: GeoCatalogError, ValueError
A GeoParquet artifact has a _schema_version the reader can't load.
Raised when _schema_version exceeds SCHEMA_VERSION_CURRENT (the
reader is older than the writer), or when a forward migration is
missing for an older artifact. The message identifies the artifact's
version and the reader's version so the user can decide whether to
upgrade the library or run geocatalog migrate.
Source code in packages/geotoolz-catalog/src/geocatalog/_src/base.py
geocatalog.backends.CatalogMetadataError
¶
Bases: GeoCatalogError, ValueError
A catalog artifact's metadata could not be read or is missing.
Raised by the strict=True mode of the catalog open entry points
when a GeoParquet artifact lacks the reserved _backend column,
carries unreadable/malformed geo metadata, or its CRS cannot be
parsed — instead of the default behaviour of logging a warning and
falling back (kind="raster" / crs="EPSG:4326").
Source code in packages/geotoolz-catalog/src/geocatalog/_src/base.py
geocatalog.backends.CatalogClosedError
¶
Bases: GeoCatalogError, RuntimeError
A catalog was used after its connection was closed.
Raised by DuckDBGeoCatalog (and every catalog derived from it by
query / filter) after close(). The DuckDB backend raises
a subclass that also derives from duckdb.ConnectionException,
which is what it raised before this class existed.