Dataset Class#
At a glance#
flowchart LR
CR["<b>create / read</b><br/>read_file · create_from_array<br/>from_features · from_band_files<br/>from_zarr · from_bytes"] --> DS(("Dataset"))
DS --> PR["<b>properties</b><br/>rows · columns · band_count · band_names<br/>epsg · crs · cell_size · geotransform<br/>bbox · bounds · no_data_value · dtype"]
DS --> AC["<b>access data</b><br/>read_array — window · bbox · chunks<br/>sample · extract · get_tile · read_part"]
DS --> SP["<b>spatial</b><br/>crop · to_crs · warped_view · resample<br/>align · fill_gaps · wrap_longitude"]
DS --> AN["<b>analysis</b><br/>stats · zonal_stats · apply · overlay<br/>map_blocks · slope · aspect · hillshade<br/>proximity · cluster"]
DS --> ND["<b>no-data</b><br/>change_no_data_value · fill · get_mask"]
DS --> VE["<b>vectorize</b><br/>to_feature_collection · contour · sieve"]
DS --> VI["<b>visualize</b><br/>plot · plot_histogram · to_image<br/>color_table · create_overviews · preview"]
DS --> WR["<b>write</b><br/>to_file — .tif · .nc · .asc<br/>to_cog · to_zarr · to_terrain_rgb"]
Architecture — the engine layer#
Dataset is a thin facade: each family of operations lives in its own engine
(ds.io, ds.spatial, …) and ds.<method>(...) forwards to ds.<engine>.<method>(...).
The reference pages below are one per engine (COG's page lives in its own COG section).
flowchart TB
DS(("Dataset<br/>facade"))
DS -->|ds.io| IO["<b>IO</b> · io.md<br/>read_array · write_array · to_file<br/>to_bytes · get_tile · to_xyz<br/>to_terrain_rgb · create_overviews"]
DS -->|ds.spatial| SP["<b>Spatial</b> · spatial.md<br/>crop · to_crs · warped_view<br/>resample · align · wrap_longitude"]
DS -->|ds.analysis| AN["<b>Analysis</b> · analysis.md<br/>stats · extract · sample · overlay<br/>proximity · masks · footprint · plot"]
DS -->|ds.bands| BA["<b>Bands</b> · band_metadata.md<br/>attribute tables · colours<br/>add_band · change_no_data_value"]
DS -->|ds.cell| CE["<b>Cell</b> · cell.md<br/>get_cell_coords / _polygons / _points<br/>map ↔ array coordinates"]
DS -->|ds.georef| GE["<b>Georef</b> · georef.md<br/>GCPs · RPCs · orthorectify<br/>set_gcps · georeference"]
DS -->|ds.vectorize| VE["<b>Vectorize</b> · vectorize.md<br/>contour · to_feature_collection<br/>cluster · translate"]
DS -->|ds.cog| CG["<b>COG</b> · cog/ section<br/>to_cog · validate_cog · info<br/>read_part · preview · read_tile"]
- Detailed class diagram for the
Datasetclass and related components:
classDiagram
%% configuration class
class Config {
}
%% abstract base class for rasters
class RasterBase {
+__init__(src, access)
+__str__()
+__repr__()
+access()
+raster()
+raster(value)
+values()
+rows()
+columns()
+shape()
+geotransform()
+top_left_corner()
+epsg()
+epsg(value)
+crs()
+crs(value)
+cell_size()
+no_data_value()
+no_data_value(value)
+meta_data()
+meta_data(value)
+block_size()
+block_size(value)
+file_name()
+driver_type()
+read_file(path, read_only)
+read_array(band, window)
+_read_block(band, window)
+plot(band, exclude_value, rgb, surface_reflectance, cutoff, overview, overview_index, percentile, basemap, **kwargs)
}
%% concrete raster class
class Dataset {
+__init__(src, access)
+__str__()
+__repr__()
+access()
+raster()
+raster(value)
+values()
+rows()
+columns()
+shape()
+geotransform()
+epsg()
+epsg(value)
+crs()
+crs(value)
+cell_size()
+band_count()
+band_names()
+band_names(name_list)
+band_units()
+band_units(value)
+no_data_value()
+no_data_value(value)
+meta_data()
+meta_data(value)
+block_size()
+block_size(value)
+file_name()
+driver_type()
+scale()
+scale(value)
+offset()
+offset(value)
+read_file(path, read_only)
+create_from_array(arr, top_left_corner, cell_size, epsg)
+read_array(band, window)
+_read_block(band, window)
+_resolve_plot_band(band, rgb)
+plot(band, exclude_value, rgb, surface_reflectance, cutoff, overview, overview_index, percentile, basemap, rgb_options, **kwargs)
+to_file(path, driver, band)
+to_crs(to_epsg, method, maintain_alignment)
+resample(cell_size, method)
+align(alignment_src)
+crop(mask, touch)
+merge(src, dst, no_data_value, init, n)
+apply(ufunc)
+overlay(classes_map, exclude_value)
}
%% Driver catalog
class _utils_Catalog {
}
%% NetCDF
class NetCDF {
}
%% error classes
class _errors_ReadOnlyError
class _errors_DatasetNotFoundError
class _errors_NoDataValueError
class _errors_AlignmentError
class _errors_DriverNotExistError
class _errors_FileFormatNotSupportedError
class _errors_OptionalPackageDoesNotExist
class _errors_FailedToSaveError
class _errors_OutOfBoundsError
%% inheritance relations
RasterBase <|-- Dataset
Dataset <|-- NetCDF
%% composition/usage relations
RasterBase ..> _utils_Catalog : "uses Catalog constant"
RasterBase ..> feature_FeatureCollection : "vector ops"
Dataset ..> feature_FeatureCollection : "vector ops"
Dataset ..> _errors_ReadOnlyError : "raises"
Dataset ..> _errors_AlignmentError : "raises"
Dataset ..> _errors_NoDataValueError : "raises"
Dataset ..> _errors_FailedToSaveError : "raises"
Dataset ..> _errors_OutOfBoundsError : "raises"
NetCDF ..> _errors_OptionalPackageDoesNotExist : "raises"
Config ..> Dataset : "initialises raster settings"
classDiagram
%% Central dataset class with its main attributes
class Dataset {
+raster
+cell_size
+values
+shape
+rows
+columns
+pivot_point
+geotransform
+bounds
+bbox
+epsg
+crs
+lon
+lat
+x
+y
+band_count
+band_names
+variables
+no_data_value
+meta_data
+dtype
+gdal_dtype
+numpy_dtype
+file_name
+time_stamp
+driver_type
}
%% Group: visualisation functionality
class Visualization {
+plot()
+overview_count()
+read_overview_array()
+create_overviews()
+recreate_overviews()
+get_overview()
}
Dataset --> Visualization : «visualisation»
%% Group: data access methods
class AccessData {
+read_array()
+get_variables()
+count_domain_cells()
+get_band_names()
+extract()
+stats()
}
Dataset --> AccessData : «data access»
%% Group: mathematical operations on raster values
class MathOperations {
+apply()
+fill()
+normalize()
+cluster()
+to_polygons()
+get_tile()
+groupNeighbours()
}
Dataset --> MathOperations : «math ops»
%% Group: spatial operations and reprojection
class SpatialOperations {
+to_crs()
+resample()
+align()
+crop()
+locate_points()
+overlay()
+extract()
+footprint()
}
Dataset --> SpatialOperations : «spatial ops»
%% Group: conversion to other data types
class Conversion {
+to_feature_collection()
}
Dataset --> Conversion : «conversion»
%% Group: coordinate system handling
class OSR {
+create_sr_from_epsg()
}
Dataset --> OSR : «osr»
%% Group: bounding‐box and bounds calculations
class BBoxBounds {
+calculate_bbox()
+calculate_bounds()
}
Dataset --> BBoxBounds : «bbox/bounds»
%% Group: CRS/EPSG getters
class CrsEpsg {
+get_crs()
+get_epsg()
}
Dataset --> CrsEpsg : «crs/epsg»
%% Group: latitude/longitude getters
class LatLon {
+get_lat_lon()
}
Dataset --> LatLon : «lat/lon»
%% Group: band names management
class BandNames {
+get_band_names_internal()
+set_band_names()
}
Dataset --> BandNames : «band names»
%% Group: timestamp handling
class TimeStamp {
+get_time_variable()
+read_variable()
}
Dataset --> TimeStamp : «time»
%% Group: handling of no‐data values
class NoDataValue {
+set_no_data_value()
+set_no_data_value_backend()
+change_no_data_value_attr()
}
Dataset --> NoDataValue : «no data value»
%% Group: helpers for creating GDAL datasets
class GdalDataset {
+create_empty_driver()
+create_driver_from_scratch()
+create_mem_gtiff_dataset()
}
Dataset --> GdalDataset : «gdal creation»
%% Group: factory methods for creating Dataset objects
class CreateObject {
+from_gdal_dataset()
+read_file()
+create_from_array()
+dataset_like()
+from_bytes()
+from_band_files()
+from_archive()
}
Dataset --> CreateObject : «object factory»
Factory methods at a glance#
| Method | Use when |
|---|---|
read_file(path, vsi=…, file_i=…) |
Open a path, URL, or archive member (zip/tar/gzip). URLs auto-rewrite to /vsi*. |
from_bytes(data, suffix=".tif") |
The caller already holds the bytes (HTTP body, DB blob, S3 get_object payload). Backed by /vsimem/. |
from_band_files(paths) |
Stack N single-band rasters (one file per band) into one multi-band Dataset — the natural target for the <asset>.<band>.tif layout of GEE / Landsat / Sentinel downloads. |
from_archive(url_or_path, member_glob=…) |
Merge every matching member of a local or remote archive into one multi-band Dataset (composes from_band_files over gdal.ReadDir). For one-Dataset-per-member use DatasetCollection.from_archive. |
create_from_array(arr, …) |
Build a Dataset from a numpy array + geobox. |
dataset_like(template, arr) |
Stamp a new Dataset that inherits its grid / CRS from template. |
See the Recipes page for runnable examples of each.
pyramids.dataset.Dataset
#
Bases: RasterBase
Single-band or multi-band raster dataset (GeoTIFF, etc.).
Wraps a GDAL dataset with spatial operations (crop, reproject, align,
mosaic), band-level I/O, and no-data handling. For NetCDF files use
the :class:~pyramids.netcdf.NetCDF subclass; for temporal stacks of
rasters use :class:~pyramids.dataset.DatasetCollection.
The eight public-API families are exposed as collaborator instances
(ds.io, ds.spatial, ds.bands, ds.analysis,
ds.cell, ds.vectorize, ds.cog, ds.georef) and via thin facade
methods on the Dataset itself, so ds.crop(mask) and
ds.spatial.crop(mask) are equivalent. Each collaborator holds a
weakref proxy back to the Dataset; the proxy keeps GDAL handle
release deterministic on Windows.
Source code in src/pyramids/dataset/dataset.py
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 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 | |
is_cog
property
#
Facade — delegates to :attr:COG.is_cog <pyramids.dataset.engines.COG.is_cog>.
gcps
property
#
Facade — :attr:Georef.gcps <pyramids.dataset.engines.Georef.gcps>.
gcp_count
property
#
Facade — :attr:Georef.gcp_count <pyramids.dataset.engines.Georef.gcp_count>.
gcp_projection
property
#
Facade — :attr:Georef.gcp_projection <pyramids.dataset.engines.Georef.gcp_projection>.
has_gcps
property
#
Facade — :attr:Georef.has_gcps <pyramids.dataset.engines.Georef.has_gcps>.
rpcs
property
#
Facade — :attr:Georef.rpcs <pyramids.dataset.engines.Georef.rpcs>.
has_rpcs
property
#
Facade — :attr:Georef.has_rpcs <pyramids.dataset.engines.Georef.has_rpcs>.
overview_count
property
#
Facade — delegates to :attr:IO.overview_count <pyramids.dataset.engines.IO.overview_count>.
band_color
property
writable
#
Facade — delegates to :attr:Bands.band_color <pyramids.dataset.engines.Bands.band_color>.
color_table
property
writable
#
Facade — delegates to :attr:Bands.color_table <pyramids.dataset.engines.Bands.color_table>.
access
property
#
Access mode.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The access mode of the dataset (read_only/write). |
raster
property
#
Base GDAL Dataset (read-only).
rows
property
#
Number of rows in the raster array.
columns
property
#
Number of columns in the raster array.
shape
property
#
Shape (bands, rows, columns).
geotransform
property
#
WKT projection.
(top left corner X/lon coordinate, cell_size, 0, top left corner y/lat coordinate, 0, -cell_size).
See Also
- Dataset.top_left_corner: Coordinate of the top left corner of the dataset.
- Dataset.epsg: EPSG number of the dataset coordinate reference system.
epsg
property
writable
#
EPSG number, or None for a CRS with no EPSG code (e.g. geostationary).
crs
property
writable
#
Coordinate reference system.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
the coordinate reference system of the dataset. |
See Also
Dataset.set_crs : Set the Coordinate Reference System (CRS). Dataset.to_crs : Reproject the dataset to any projection. Dataset.epsg : epsg number of the dataset coordinate reference system.
cell_size
property
#
Cell size.
band_count
property
#
Number of bands in the raster.
band_names
property
writable
#
Band names.
band_units
property
writable
#
Band units.
no_data_value
property
writable
#
Per-band nodata markers as an immutable tuple.
Returns a tuple (not a list) to make the read-only
contract explicit — assign through the setter to change
values; mutating the returned object never propagates to
the underlying state.
meta_data
property
writable
#
Meta-data.
block_size
property
writable
#
Block Size.
The block size is the size of the block that the raster is divided into, the block size is used to read and write the raster data in blocks.
See Also
- Dataset.get_block_arrangement: Get block arrangement to read the dataset in chunks.
- Dataset.get_tile: Get tiles.
- Dataset.read_array: Read the data stored in the dataset bands.
file_name
property
#
File name.
driver_type
property
#
Driver Type.
scale
property
writable
#
Scale.
The value of the scale is used to convert the pixel values to the real-world values.
offset
property
writable
#
Offset.
The value of the offset is used to convert the pixel values to the real-world values.
top_left_corner
property
#
Top left corner coordinates.
See Also
- Dataset.geotransform: Dataset geotransform.
bounds
property
#
Bounds - the bbox as a geodataframe with a polygon geometry.
See Also
- Dataset.bbox: Dataset bounding box.
bbox
property
#
Bound box [xmin, ymin, xmax, ymax].
See Also
- Dataset.bounds: Dataset bounding polygon.
total_bounds
property
#
Bounding box [minx, miny, maxx, maxy] as a NumPy array.
introduced this property so that Dataset and
:class:pyramids.feature.FeatureCollection expose the same
shape (GeoDataFrame.total_bounds is the geopandas name
for exactly this array), letting both classes satisfy the
:class:pyramids.base.protocols.SpatialObject protocol.
lon
property
#
Longitude / x cell-centre coordinates.
Uses the geotransform's pixel width (geotransform[1]) so the axis is
correct even when cells are not square (pixel width != pixel height). Reads the
cached _geotransform (like :attr:top_left_corner) rather than the
geotransform property, so subclasses that derive geotransform from
lon/lat (e.g. :class:~pyramids.netcdf.NetCDF) do not recurse.
Examples:
- Read the column-centre longitudes of a small raster:
See Also
- Dataset.x: Dataset x coordinates.
- Dataset.lat: Dataset latitude.
lat
property
#
Latitude / y cell-centre coordinates.
Uses the geotransform's pixel height (abs(geotransform[5])) rather than
:attr:cell_size (which only tracks pixel width), so the axis is correct for
non-square cells. Reads the cached _geotransform (like
:attr:top_left_corner) rather than the geotransform property, so
subclasses that derive geotransform from lon/lat (e.g.
:class:~pyramids.netcdf.NetCDF) do not recurse.
Examples:
- Row-centre latitudes decrease from north to south:
- With non-square cells the latitude axis uses the pixel height, not the pixel width:
See Also
- Dataset.x: Dataset x coordinates.
- Dataset.y: Dataset y coordinates.
- Dataset.lon: Dataset longitude.
x
property
#
X cell-centre coordinates (alias of :attr:lon).
Examples:
- x mirrors lon for the same raster:
See Also
- Dataset.lon: the longitude axis this property aliases.
- Dataset.y: Dataset y coordinates.
y
property
#
Y cell-centre coordinates (alias of :attr:lat).
Examples:
- y mirrors lat for the same raster:
See Also
- Dataset.lat: the latitude axis this property aliases.
- Dataset.x: Dataset x coordinates.
gdal_dtype
property
#
Data Type.
numpy_dtype
property
#
List of the numpy data Type of each band, the data type is a numpy function.
dtype
property
#
List of the data Type of each band as strings.
__init__(src, access='read_only')
#
init.
Source code in src/pyramids/dataset/dataset.py
focal_mean(radius=1, *, chunks=None, band=0)
#
Thin forwarder to :func:pyramids.dataset.ops._focal.focal_mean.
focal_std(radius=1, *, chunks=None, band=0)
#
Thin forwarder to :func:pyramids.dataset.ops._focal.focal_std.
focal_apply(func, radius=1, *, chunks=None, band=0)
#
Thin forwarder to :func:pyramids.dataset.ops._focal.focal_apply.
slope(*, chunks=None, band=0, units='degrees')
#
Thin forwarder to :func:pyramids.dataset.ops._focal.slope.
hillshade(*, azimuth=315.0, altitude=45.0, chunks=None, band=0)
#
Thin forwarder to :func:pyramids.dataset.ops._focal.hillshade.
Source code in src/pyramids/dataset/dataset.py
get_cell_coords(*args, **kwargs)
#
Facade — delegates to :meth:Cell.get_cell_coords <pyramids.dataset.engines.Cell.get_cell_coords>.
get_cell_polygons(*args, **kwargs)
#
Facade — delegates to :meth:Cell.get_cell_polygons <pyramids.dataset.engines.Cell.get_cell_polygons>.
get_cell_points(*args, **kwargs)
#
Facade — delegates to :meth:Cell.get_cell_points <pyramids.dataset.engines.Cell.get_cell_points>.
map_to_array_coordinates(*args, **kwargs)
#
Facade — delegates to :meth:Cell.map_to_array_coordinates <pyramids.dataset.engines.Cell.map_to_array_coordinates>.
array_to_map_coordinates(*args, **kwargs)
#
Facade — delegates to :meth:Cell.array_to_map_coordinates <pyramids.dataset.engines.Cell.array_to_map_coordinates>.
validate_cog(*args, **kwargs)
#
Facade — delegates to :meth:COG.validate_cog <pyramids.dataset.engines.COG.validate_cog>.
to_cog_bytes(*args, **kwargs)
#
Facade — delegates to :meth:COG.to_cog_bytes <pyramids.dataset.engines.COG.to_cog_bytes>.
read_part(*args, **kwargs)
#
Facade — delegates to :meth:COG.read_part <pyramids.dataset.engines.COG.read_part>.
preview(*args, **kwargs)
#
Facade — delegates to :meth:COG.preview <pyramids.dataset.engines.COG.preview>.
read_tile(*args, **kwargs)
#
Facade — delegates to :meth:COG.read_tile <pyramids.dataset.engines.COG.read_tile>.
to_feature_collection(*args, **kwargs)
#
Facade — delegates to :meth:Vectorize.to_feature_collection <pyramids.dataset.engines.Vectorize.to_feature_collection>.
contour(*args, **kwargs)
#
Facade — delegates to :meth:Vectorize.contour <pyramids.dataset.engines.Vectorize.contour>.
translate(*args, **kwargs)
#
Facade — delegates to :meth:Vectorize.translate <pyramids.dataset.engines.Vectorize.translate>.
cluster(*args, **kwargs)
#
Facade — delegates to :meth:Vectorize.cluster <pyramids.dataset.engines.Vectorize.cluster>.
to_polygons(*args, **kwargs)
#
Facade — delegates to :meth:Vectorize.to_polygons <pyramids.dataset.engines.Vectorize.to_polygons>.
cluster2(*args, **kwargs)
#
Deprecated alias for :meth:to_polygons — delegates to
:meth:Vectorize.cluster2 <pyramids.dataset.engines.Vectorize.cluster2>.
stats(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.stats <pyramids.dataset.engines.Analysis.stats>.
count_domain_cells(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.count_domain_cells <pyramids.dataset.engines.Analysis.count_domain_cells>.
apply(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.apply <pyramids.dataset.engines.Analysis.apply>.
The collaborator returns None for inplace=True so the facade
can substitute the actual self (preserving identity); the proxy
used by the collaborator's back-reference would otherwise fail
result is ds checks.
Source code in src/pyramids/dataset/dataset.py
fill(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.fill <pyramids.dataset.engines.Analysis.fill>.
The collaborator returns None for inplace=True; see
:meth:apply for the rationale.
Source code in src/pyramids/dataset/dataset.py
extract(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.extract <pyramids.dataset.engines.Analysis.extract>.
sample(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.sample <pyramids.dataset.engines.Analysis.sample>.
sieve(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.sieve <pyramids.dataset.engines.Analysis.sieve>.
proximity(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.proximity <pyramids.dataset.engines.Analysis.proximity>.
overlay(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.overlay <pyramids.dataset.engines.Analysis.overlay>.
get_mask(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.get_mask <pyramids.dataset.engines.Analysis.get_mask>.
mask_flags(*args, **kwargs)
#
Facade — :meth:Analysis.mask_flags <pyramids.dataset.engines.Analysis.mask_flags>.
read_masks(*args, **kwargs)
#
Facade — :meth:Analysis.read_masks <pyramids.dataset.engines.Analysis.read_masks>.
create_mask_band(*args, **kwargs)
#
Facade — :meth:Analysis.create_mask_band <pyramids.dataset.engines.Analysis.create_mask_band>.
footprint(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.footprint <pyramids.dataset.engines.Analysis.footprint>.
get_histogram(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.get_histogram <pyramids.dataset.engines.Analysis.get_histogram>.
plot_histogram(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.plot_histogram <pyramids.dataset.engines.Analysis.plot_histogram>.
to_image(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.to_image <pyramids.dataset.engines.Analysis.to_image>.
plot_vector_field(*args, **kwargs)
#
Facade — delegates to :meth:Analysis.plot_vector_field <pyramids.dataset.engines.Analysis.plot_vector_field>.
plot(band=None, exclude_value=None, rgb=None, surface_reflectance=None, cutoff=None, overview=False, overview_index=0, percentile=None, basemap=None, rgb_options=None, **kwargs)
#
Plot the values/overviews of a band.
Facade for :meth:Analysis.plot <pyramids.dataset.engines.Analysis.plot>. Resolves
the band index via :meth:_resolve_plot_band (GeoTIFF/Sentinel semantics) and then
forwards the call to the generic rendering engine.
When band is None and the dataset looks like an RGB image — i.e. it has
at least 3 bands and at least one band has a GDAL ColorInterpretation set —
the red band is auto-selected (either from rgb[0] or by resolving the colour
tags). Otherwise the facade defaults to band 0. See
:meth:Analysis.plot for the full kwargs surface.
The four satellite-imagery kwargs rgb, surface_reflectance, cutoff,
and percentile may be grouped under a single rgb_options= dict
(recommended) or passed loose at the top level (deprecated; emits
:class:DeprecationWarning). When both forms are mixed, the values inside
rgb_options win.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
band
|
int
|
Band index to render. When |
None
|
exclude_value
|
Any
|
Pixel value to mask out before plotting. Default is |
None
|
rgb
|
list[int]
|
Deprecated; pass via |
None
|
surface_reflectance
|
int
|
Deprecated; pass via |
None
|
cutoff
|
list
|
Deprecated; pass via |
None
|
overview
|
bool
|
If |
False
|
overview_index
|
int
|
Index of the overview level to plot when |
0
|
percentile
|
int
|
Deprecated; pass via |
None
|
basemap
|
bool or str
|
If |
None
|
rgb_options
|
dict
|
Grouped Sentinel-imagery kwargs. Accepted keys:
|
None
|
**kwargs
|
Any
|
Additional keyword arguments forwarded verbatim to
:meth: |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ArrayGlyph |
A cleopatra
|
Examples:
- Render the first band of a single-band MEM raster. Tagged
+SKIPbecause the call requires the optional[viz]extra (cleopatra + matplotlib):
>>> import numpy as np
>>> from pyramids.dataset import Dataset
>>> arr = np.random.rand(8, 8).astype(np.float32)
>>> ds = Dataset.create_from_array(
... arr, top_left_corner=(0, 0), cell_size=0.1, epsg=4326,
... )
>>> cleo = ds.plot() # doctest: +SKIP
>>> cleo.fig # doctest: +SKIP
<Figure size 800x800 with 2 Axes>
- Override the resolved band index. The facade forwards
band=1straight to the engine without consulting the heuristic:
- Render a multi-band raster as a true-colour composite via the
recommended
rgb_options=group:
>>> arr3 = np.random.rand(3, 8, 8).astype(np.float32)
>>> rgb_ds = Dataset.create_from_array(
... arr3, top_left_corner=(0, 0), cell_size=0.1, epsg=4326,
... )
>>> cleo = rgb_ds.plot( # doctest: +SKIP
... rgb_options={"rgb": [0, 1, 2], "surface_reflectance": 255},
... )
- The deprecated loose-kwarg form still works but emits a
:class:
DeprecationWarning. New code should prefer the groupedrgb_options=form shown above:
>>> cleo = rgb_ds.plot( # doctest: +SKIP
... rgb=[0, 1, 2], surface_reflectance=255,
... )
DeprecationWarning: Passing `rgb=`, `surface_reflectance=`...
Source code in src/pyramids/dataset/dataset.py
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 | |
crop(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.crop <pyramids.dataset.engines.Spatial.crop>.
to_crs(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.to_crs <pyramids.dataset.engines.Spatial.to_crs>.
set_gcps(*args, **kwargs)
#
Facade — delegates to :meth:Georef.set_gcps <pyramids.dataset.engines.Georef.set_gcps>.
georeference(*args, **kwargs)
#
Facade — :meth:Georef.georeference <pyramids.dataset.engines.Georef.georeference>.
set_rpcs(*args, **kwargs)
#
Facade — :meth:Georef.set_rpcs <pyramids.dataset.engines.Georef.set_rpcs>.
orthorectify(*args, **kwargs)
#
Facade — :meth:Georef.orthorectify <pyramids.dataset.engines.Georef.orthorectify>.
warped_view(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.warped_view <pyramids.dataset.engines.Spatial.warped_view>.
set_crs(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.set_crs <pyramids.dataset.engines.Spatial.set_crs>.
wrap_longitude(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.wrap_longitude <pyramids.dataset.engines.Spatial.wrap_longitude>.
resample(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.resample <pyramids.dataset.engines.Spatial.resample>.
align(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.align <pyramids.dataset.engines.Spatial.align>.
fill_gaps(*args, **kwargs)
#
Facade — delegates to :meth:Spatial.fill_gaps <pyramids.dataset.engines.Spatial.fill_gaps>.
read_array(*args, **kwargs)
#
Facade — delegates to :meth:IO.read_array <pyramids.dataset.engines.IO.read_array>.
read_windows(*args, **kwargs)
#
Facade — delegates to :meth:IO.read_windows <pyramids.dataset.engines.IO.read_windows>.
write_array(*args, **kwargs)
#
Facade — delegates to :meth:IO.write_array <pyramids.dataset.engines.IO.write_array>.
to_file(*args, **kwargs)
#
Facade — delegates to :meth:IO.to_file <pyramids.dataset.engines.IO.to_file>.
to_bytes(*args, **kwargs)
#
Facade — delegates to :meth:IO.to_bytes <pyramids.dataset.engines.IO.to_bytes>.
to_raster(*args, **kwargs)
#
Facade — delegates to :meth:IO.to_raster <pyramids.dataset.engines.IO.to_raster>.
get_block_arrangement(*args, **kwargs)
#
Facade — delegates to :meth:IO.get_block_arrangement <pyramids.dataset.engines.IO.get_block_arrangement>.
get_tile(*args, **kwargs)
#
Facade — delegates to :meth:IO.get_tile <pyramids.dataset.engines.IO.get_tile>.
map_blocks(*args, **kwargs)
#
Facade — delegates to :meth:IO.map_blocks <pyramids.dataset.engines.IO.map_blocks>.
to_terrain_rgb(*args, **kwargs)
#
Facade — delegates to
:meth:IO.to_terrain_rgb <pyramids.dataset.engines.IO.to_terrain_rgb>.
create_overviews(*args, **kwargs)
#
Facade — delegates to :meth:IO.create_overviews <pyramids.dataset.engines.IO.create_overviews>.
recreate_overviews(*args, **kwargs)
#
Facade — delegates to :meth:IO.recreate_overviews <pyramids.dataset.engines.IO.recreate_overviews>.
get_overview(*args, **kwargs)
#
Facade — delegates to :meth:IO.get_overview <pyramids.dataset.engines.IO.get_overview>.
read_overview_array(*args, **kwargs)
#
Facade — delegates to :meth:IO.read_overview_array <pyramids.dataset.engines.IO.read_overview_array>.
get_attribute_table(*args, **kwargs)
#
Facade — delegates to :meth:Bands.get_attribute_table <pyramids.dataset.engines.Bands.get_attribute_table>.
set_attribute_table(*args, **kwargs)
#
Facade — delegates to :meth:Bands.set_attribute_table <pyramids.dataset.engines.Bands.set_attribute_table>.
add_band(*args, **kwargs)
#
Facade — delegates to :meth:Bands.add_band <pyramids.dataset.engines.Bands.add_band>.
get_band_by_color(*args, **kwargs)
#
Facade — delegates to :meth:Bands.get_band_by_color <pyramids.dataset.engines.Bands.get_band_by_color>.
change_no_data_value(*args, **kwargs)
#
Facade — concrete override of the abstract :meth:RasterBase.change_no_data_value.
The collaborator returns None for the inplace=True path; the
facade substitutes self for identity preservation, matching
:meth:apply and :meth:fill.
Source code in src/pyramids/dataset/dataset.py
zonal_stats(fc, *, stats=('mean',), method='rasterize', band=0)
#
Compute zonal statistics of this dataset over a polygon FeatureCollection.
Thin forwarder to
:func:pyramids.dataset.ops._zonal.zonal_stats; see that
function for the full argument contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fc
|
A :class: |
required | |
stats
|
Sequence of stat names ( |
('mean',)
|
|
method
|
str
|
|
'rasterize'
|
band
|
int
|
Zero-based band index. |
0
|
Returns:
| Type | Description |
|---|---|
|
pandas.DataFrame: Indexed by |
Source code in src/pyramids/dataset/dataset.py
to_zarr(store, *, compute=True, mode='w', chunks=None, storage_options=None, compressor='auto', overview_factors=None, overview_resampling='average')
#
Serialise this Dataset to a Zarr store (parallel writes per chunk).
Thin forwarder to
:func:pyramids.dataset.ops._zarr.write_dataset_to_zarr; see
that function for the full argument contract. Zarr is the
only raster output format where pyramids can write in true
parallel — each dask chunk becomes an independent Zarr chunk
file. Requires the [lazy] optional extra.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
Target store (path / fsspec URL / zarr.Store). |
required | |
compute
|
bool
|
|
True
|
mode
|
str
|
Zarr open mode, usually |
'w'
|
chunks
|
Chunk spec forwarded to :meth: |
None
|
|
storage_options
|
dict | None
|
fsspec options for cloud stores. |
None
|
compressor
|
Zarr codec(s) for the |
'auto'
|
|
overview_factors
|
list | None
|
Optional downsample factors (e.g. |
None
|
overview_resampling
|
str
|
GDAL resampling for the pyramid levels
( |
'average'
|
Source code in src/pyramids/dataset/dataset.py
from_zarr(store, *, chunks=None, storage_options=None, level=1, data_name=None)
classmethod
#
Load a pyramids-written Zarr store into a new :class:Dataset.
Thin forwarder to
:func:pyramids.dataset.ops._zarr.read_dataset_from_zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
Input store (path / fsspec URL / zarr.Store). |
required | |
chunks
|
If non-None, the loaded Dataset is flagged as
dask-backed so downstream |
None
|
|
storage_options
|
dict | None
|
fsspec options for cloud stores. |
None
|
level
|
int
|
Pyramid downsample factor to read ( |
1
|
data_name
|
str | None
|
Explicit name of the data array. |
None
|
Source code in src/pyramids/dataset/dataset.py
__str__()
#
str.
Source code in src/pyramids/dataset/dataset.py
convert_units(target, band=None)
#
Convert band values to target units, returning a new Dataset.
Unlike the :attr:band_units setter — which only relabels bands — this
actually transforms the stored values using a small affine conversion table
(see :func:pyramids.dataset.ops.units.convert_array) and records the new
unit on the result. No-data cells are preserved unchanged. The output is a
new in-memory float64 Dataset; the source is left untouched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
str
|
Target unit label (e.g. |
required |
band
|
int | None
|
Zero-based band index to convert. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
A new :class: |
Dataset
|
attr: |
.. deprecated::
Physical value-unit conversion (Kelvin/Celsius, m/s/knots, Pa/hPa,
m/mm) is atmospheric/geophysical domain logic, not a generic GIS
raster primitive, and will be removed from pyramids. Keep the
unit metadata on :attr:band_units and perform the value
conversion in the downstream science-domain consumer. Calling this
method emits a :class:DeprecationWarning.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
- Convert a Kelvin raster to Celsius and read the new values:
>>> import numpy as np >>> from pyramids.dataset import Dataset >>> ds = Dataset.create_from_array( ... np.array([[273.15, 283.15], [293.15, 303.15]]), ... top_left_corner=(0, 0), cell_size=1.0, epsg=4326, ... ) >>> ds.band_units = ["K"] >>> converted = ds.convert_units("celsius") >>> converted.read_array().tolist() [[0.0, 10.0], [20.0, 30.0]] >>> converted.band_units ['celsius'] - An unsupported target raises a clear error:
>>> import numpy as np >>> from pyramids.dataset import Dataset >>> ds = Dataset.create_from_array( ... np.array([[273.15]]), top_left_corner=(0, 0), cell_size=1.0, epsg=4326, ... ) >>> ds.band_units = ["K"] >>> try: ... ds.convert_units("furlongs") ... except ValueError as exc: ... print("No unit conversion" in str(exc)) True
Source code in src/pyramids/dataset/dataset.py
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 | |
to_stac_item(item_id, *, asset_href, datetime=None, start_datetime=None, end_datetime=None, asset_key='data', asset_media_type=None, with_proj=True, with_raster=True, precision=6)
#
Describe this raster as a STAC Item dict (proj + raster extensions).
Thin forwarder to :func:pyramids.dataset._stac.to_stac_item — the
inverse of :meth:DatasetCollection.from_stac. Returns a plain
STAC-JSON dict (pystac not required); the footprint is this dataset's
bounding rectangle reprojected to EPSG:4326.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_id
|
str
|
The STAC Item id. |
required |
asset_href
|
str
|
Href to record for the single data asset. |
required |
datetime
|
Item datetime ( |
None
|
|
start_datetime
|
Optional range start, written to
|
None
|
|
end_datetime
|
Optional range end, written to
|
None
|
|
asset_key
|
str
|
Key for the data asset (default |
'data'
|
asset_media_type
|
str | None
|
Optional media type for the asset. |
None
|
with_proj
|
bool
|
Populate the |
True
|
with_raster
|
bool
|
Populate |
True
|
precision
|
int
|
Decimal places for the reprojected footprint. |
6
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The STAC Item (a GeoJSON Feature). |
Source code in src/pyramids/dataset/dataset.py
read_file(path, read_only=True, file_i=0, *, vsi=None)
classmethod
#
Open a raster from a path, URL, or archive member.
Plain local paths, /vsi* paths, and URL schemes
(http(s)://, s3://, gs://, az:// / abfs://,
file://) are all accepted — URLs are transparently rewritten to
GDAL's virtual filesystem (GDAL fetches via HTTP range requests for
http(s)). Compressed archives are detected from the extension; pass
vsi= to be explicit about it (e.g. an archive with an unusual
extension, or to open a specific member by index).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path or URL of the file to open. |
required |
read_only
|
bool
|
File mode; set to |
True
|
file_i
|
int
|
Which member to open when |
0
|
vsi
|
str | None
|
Treat |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
Opened dataset instance. |
See Also
- :meth:
read_array: read the values stored in a dataset band. - :meth:
from_bytes: open a raster held in memory. - :meth:
pyramids.dataset.DatasetCollection.from_archive: open every member of an archive as a temporal stack.
Source code in src/pyramids/dataset/dataset.py
from_bytes(data, *, suffix='.tif', name=None, read_only=True)
classmethod
#
Open a raster held in memory as a byte string.
Writes data to a temporary GDAL /vsimem/ path and opens
it — no on-disk temp file needed. Useful for HTTP response
bodies (requests.get(url).content), object-store
get_object payloads, database blobs, and test fixtures.
This is not a URL helper. Reading from a URL is already
supported by :meth:read_file, which rewrites http(s)://,
s3://, gs://, az:// / abfs:// and file://
to GDAL /vsi* paths. Use from_bytes only when you
already hold the bytes.
The /vsimem/ entry is removed automatically when the
returned :class:Dataset is garbage-collected
(:func:weakref.finalize); :meth:close does not need to be
called for cleanup. Note that an in-memory dataset is not
picklable — :meth:__reduce__ raises TypeError for
/vsimem/ paths; call :meth:to_file first to anchor it to
disk before sending it to another process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes | bytearray | memoryview
|
Raw bytes of a raster (GeoTIFF, ASCII grid, ...). For
NetCDF bytes use :meth: |
required |
suffix
|
str
|
Extension hint for GDAL's driver detection. Needed
only for headerless formats (e.g. ESRI ASCII grid:
|
'.tif'
|
name
|
str | None
|
Optional label recorded as the dataset's
:attr: |
None
|
read_only
|
bool
|
Open the dataset read-only. Defaults to |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The opened in-memory dataset. |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
GDAL could not open the bytes (corrupt /
truncated payload, or a headerless format without a
|
Examples:
- Open the bytes of a downloaded GeoTIFF and inspect it (the
bytes here come from a file, but they could just as well be
requests.get(url).content): - The bytes path yields the same data as opening the file directly:
>>> from pathlib import Path >>> from pyramids.dataset import Dataset >>> data = Path("tests/data/acc4000.tif").read_bytes() >>> from_bytes = Dataset.from_bytes(data) >>> from_file = Dataset.read_file("tests/data/acc4000.tif") >>> from_bytes.shape == from_file.shape True >>> from_bytes.epsg == from_file.epsg True - An in-memory dataset cannot be pickled — anchor it to disk first:
See Also
- :meth:
read_file: open a raster from a path or URL. - :meth:
to_file: write an in-memory dataset to disk. - :meth:
pyramids.netcdf.NetCDF.from_bytes: the NetCDF variant.
Source code in src/pyramids/dataset/dataset.py
2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 | |
from_wcs(endpoint, *, coverage, bbox, crs=_DEFAULT_CRS, output_crs=None, resolution=None, version=None, coverage_crs=None, wcs_format=None, output=None, resample='nearest', auth=None, timeout=60.0, extra_params=None, direct=False, subset_axes=None)
classmethod
#
Read a coverage subset from an OGC Web Coverage Service (WCS).
Fetches a windowed subset of a coverage from a WCS server and returns it
as a :class:Dataset. The transport is GDAL's native WCS driver, so the
WCS 1.0.0 vs 2.0.x dialect fork — bbox + resx/resy versus
named-axis subsets + scaling — is handled inside GDAL; the caller
always supplies a single lon/lat bbox (plus optional resolution
and output_crs).
Two things GDAL does not do for every server, which this method adds:
- CRS shim. Some servers advertise a coverage CRS under an authority
code absent from the local PROJ database (notably ISRIC SoilGrids'
EPSG:152160, a custom Interrupted Goode Homolosine). GDAL then opens the coverage without a spatial reference and cannot place the request window. Passcoverage_crswith the coverage's real CRS and it is attached client-side. - bbox reprojection.
bboxis given incrs(lon/lat by default) and transformed into the coverage's native CRS withpyprojbefore the request, so subsetting lands on the correct pixels even when the server only honours its native CRS.
For a GetCoverage-only endpoint — a "WCS shim" that returns
502/400 for GetCapabilities/DescribeCoverage but serves
GetCoverage (e.g. Copernicus EDO/GDO) — pass direct=True. That skips
both discovery steps and issues a KVP GetCoverage built straight from
coverage / crs / bbox / wcs_format / extra_params, so the
caller owns correctness (no capabilities check). For WCS 2.0.x the
SUBSET axis labels default to ("Long", "Lat") for a geographic
crs — override with subset_axes if the server names its axes
differently.
A non-conformant shim may also reject the spec KVP spellings themselves: the
Copernicus EDO/GDO MapServer 500s on the uppercase COVERAGEID key and
on SUBSETTINGCRS= (it wants a lowercase coverageID and the WCS-1.x
CRS=). In direct mode extra_params can override a built-in KVP by key,
so pass extra_params={"coverageID": <id>, "CRS": <crs>} to hand such a
server its exact spelling — the override replaces the built-in rather than
duplicating it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The WCS service URL, including any server-specific query
prefix (e.g. |
required |
coverage
|
str
|
The coverage identifier as advertised by
|
required |
bbox
|
tuple[float, float, float, float]
|
|
required |
crs
|
str
|
CRS of |
_DEFAULT_CRS
|
output_crs
|
str | None
|
Optional CRS to reproject the result into (any form
:meth: |
None
|
resolution
|
float | tuple[float, float] | None
|
Output pixel size in the units of |
None
|
version
|
str | None
|
Force a WCS protocol version ( |
None
|
coverage_crs
|
str | None
|
The coverage's CRS, used only when the server's
advertised CRS does not resolve in PROJ (see the CRS-shim note).
Any proj4 / WKT / authority string |
None
|
wcs_format
|
str | None
|
Optional GDAL |
None
|
output
|
str | Path | None
|
Optional path to also write the result to as a GeoTIFF. The
method still returns the :class: |
None
|
resample
|
str
|
Resampling method for the |
'nearest'
|
auth
|
tuple[str, str] | None
|
Optional |
None
|
timeout
|
float
|
HTTP timeout in seconds for the metadata / coverage
requests. Defaults to |
60.0
|
extra_params
|
dict[str, str] | None
|
Optional extra |
None
|
direct
|
bool
|
When |
False
|
subset_axes
|
tuple[str, str] | None
|
Direct mode, WCS |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The fetched coverage subset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
WCSError
|
The server could not be reached or returned
an error / a non-raster ( |
Examples:
Read a Netherlands subset of SoilGrids nitrogen (its native CRS needs
the coverage_crs shim):
>>> ds = Dataset.from_wcs( # doctest: +SKIP
... "https://maps.isric.org/mapserv?map=/map/nitrogen.map",
... coverage="nitrogen_0-5cm_mean",
... bbox=(5.0, 51.0, 6.0, 52.0),
... coverage_crs="+proj=igh +lat_0=0 +lon_0=0 +datum=WGS84 +units=m +no_defs",
... )
Direct mode for a GetCoverage-only endpoint (Copernicus EDO/GDO),
whose GetCapabilities/DescribeCoverage return 502/400.
EDO also rejects the spec KVP spellings, so override the coverage key and
CRS token via extra_params to send the lowercase coverageID and
the WCS-1.x CRS= it accepts:
>>> ds = Dataset.from_wcs( # doctest: +SKIP
... "https://drought.emergency.copernicus.eu/api/wcs?map=DO_WCS",
... coverage="spaST",
... bbox=(10.0, 45.0, 15.0, 48.0),
... crs="EPSG:4326",
... version="2.0.0",
... wcs_format="GEOTIFF",
... direct=True,
... extra_params={
... "coverageID": "spaST",
... "CRS": "EPSG:4326",
... "TIME": "2023-06-01",
... "SELECTED_TIMESCALE": "01",
... },
... )
See Also
- :meth:
read_file: open a raster from a path or URL. - :meth:
from_bytes: open a raster already held in memory.
Source code in src/pyramids/dataset/dataset.py
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 | |
from_wms(endpoint, *, layers, bbox, crs=_DEFAULT_CRS, size=None, resolution=None, image_format='image/png', version='1.3.0', bands=3, output_crs=None, output=None, resample='nearest', auth=None, timeout=60.0)
classmethod
#
Render a WMS GetMap window into a :class:Dataset.
Fetches a server-rendered map image for bbox from an OGC Web Map
Service via GDAL's native WMS driver, and returns it as a georeferenced
raster. Because WMS renders in the requested crs, the bbox is the
request window directly — no client-side reprojection is needed.
The result is rendered imagery (RGB / RGBA pixels), not data values: a
WMS styles the data server-side. Use :meth:from_wcs /
:meth:from_ogc_coverages when you need the underlying coverage values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The WMS base URL, ending with |
required |
layers
|
str | list[str] | tuple[str, ...]
|
One layer name, or several to composite, as advertised by the
service |
required |
bbox
|
tuple[float, float, float, float]
|
|
required |
crs
|
str
|
CRS of |
_DEFAULT_CRS
|
size
|
tuple[int, int] | None
|
Output image size |
None
|
resolution
|
float | tuple[float, float] | None
|
Output pixel size in |
None
|
image_format
|
str
|
WMS |
'image/png'
|
version
|
str
|
WMS protocol version. Defaults to |
'1.3.0'
|
bands
|
int
|
Number of bands to request ( |
3
|
output_crs
|
str | None
|
Optional CRS to reproject the result into (any form
:meth: |
None
|
output
|
str | Path | None
|
Optional path to also write the result to as a GeoTIFF. |
None
|
resample
|
str
|
Resampling method for the |
'nearest'
|
auth
|
tuple[str, str] | None
|
Optional |
None
|
timeout
|
float
|
HTTP timeout in seconds. Defaults to |
60.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The rendered map window. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
WMSError
|
The server could not be reached or returned a non-raster body. |
Examples:
Render a small OSM window as a 512-px-wide PNG raster:
>>> ds = Dataset.from_wms( # doctest: +SKIP
... "https://ows.terrestris.de/osm/service?",
... layers="OSM-WMS",
... bbox=(5.0, 51.0, 6.0, 52.0),
... size=(512, 512),
... )
See Also
- :meth:
from_wmts: the tiled (WMTS) sibling. - :meth:
from_wcs: read coverage data values instead of imagery.
Source code in src/pyramids/dataset/dataset.py
2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 | |
from_wmts(endpoint, *, layer, bbox, crs=_DEFAULT_CRS, tile_matrix_set=None, resolution=None, layer_crs=None, output_crs=None, output=None, resample='nearest', auth=None, timeout=60.0)
classmethod
#
Crop a WMTS tile-pyramid layer to bbox into a :class:Dataset.
Opens a Web Map Tile Service layer as a full georeferenced tile pyramid
via GDAL's native WMTS driver, then crops bbox out of it (reprojecting
the bbox into the layer's native CRS with pyproj, mirroring
:meth:from_wcs). The result is rendered imagery (RGB / RGBA), not data
values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The WMTS |
required |
layer
|
str
|
The layer identifier as advertised by the capabilities document.
A value the service does not advertise raises :class: |
required |
bbox
|
tuple[float, float, float, float]
|
|
required |
crs
|
str
|
CRS of |
_DEFAULT_CRS
|
tile_matrix_set
|
str | None
|
Optional tile-matrix-set id to pin. |
None
|
resolution
|
float | tuple[float, float] | None
|
Output pixel size in the layer's native CRS units — GDAL
reads from the matching overview level. |
None
|
layer_crs
|
str | None
|
The layer's CRS, used only when the WMTS layer opens without a resolvable spatial reference (any proj4 / WKT / authority string). |
None
|
output_crs
|
str | None
|
Optional CRS to reproject the result into. |
None
|
output
|
str | Path | None
|
Optional path to also write the result to as a GeoTIFF. |
None
|
resample
|
str
|
Resampling method for the crop / warp. Defaults to
|
'nearest'
|
auth
|
tuple[str, str] | None
|
Optional |
None
|
timeout
|
float
|
HTTP timeout in seconds. Defaults to |
60.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The cropped WMTS window. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
WMSError
|
The server could not be reached or the tile read failed. |
Examples:
Crop a NASA GIBS true-colour window (coarsened to ~0.01° pixels):
>>> ds = Dataset.from_wmts( # doctest: +SKIP
... "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/1.0.0/WMTSCapabilities.xml",
... layer="MODIS_Terra_CorrectedReflectance_TrueColor",
... bbox=(5.0, 51.0, 6.0, 52.0),
... resolution=0.01,
... )
See Also
- :meth:
from_wms: the untiled (WMSGetMap) sibling. - :meth:
from_wcs: read coverage data values instead of imagery.
Source code in src/pyramids/dataset/dataset.py
2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 | |
from_ogc_coverages(endpoint, *, coverage, bbox, output_crs=None, resolution=None, coverage_crs=None, output=None, resample='nearest', auth=None, timeout=60.0)
classmethod
#
Read a coverage subset from an OGC API – Coverages service.
Fetches a windowed subset of a coverage from an OGC API – Coverages
service and returns it as a :class:Dataset. OGC API – Coverages is the
modern REST/JSON successor to WCS: a landing page links to
/collections and each coverage exposes /collections/{id}/coverage
with format negotiation. The transport is GDAL's native OGCAPI driver,
so discovery, GeoTIFF negotiation and the windowed read happen inside GDAL;
the caller supplies a single lon/lat bbox (plus optional resolution
and output_crs). The driver exposes the coverage as an unbounded virtual
raster, so the bbox is applied at read time as a native-CRS projWin
window (not passed through as a service-side bbox subset). This is the
OGC-API-era sibling of :meth:from_wcs.
A bbox is required. The driver exposes the coverage as an unbounded
virtual raster, so a windowless read is impossible; pyramids projects the
lon/lat bbox into the coverage's native CRS and reads it with an
explicit output-size cap so the fetch always stays bounded.
The coverage is validated against a (cached) /collections document
so an unadvertised coverage fails fast with a clear :class:ValueError
rather than an opaque driver error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The OGC API landing-page / base URL (e.g.
|
required |
coverage
|
str
|
The coverage identifier as advertised by |
required |
bbox
|
tuple[float, float, float, float]
|
Required |
required |
output_crs
|
str | None
|
Optional CRS to reproject the result into (any form
:meth: |
None
|
resolution
|
float | tuple[float, float] | None
|
Approximate pixel size of the read window, in the units of
the coverage's native CRS (CRS84 degrees by default). A scalar
gives square pixels; an |
None
|
coverage_crs
|
str | None
|
The coverage's CRS, used only when the service's
advertised CRS does not resolve in PROJ so GDAL opens the coverage
with no spatial reference. Any proj4 / WKT / authority string
|
None
|
output
|
str | Path | None
|
Optional path to also write the result to as a GeoTIFF. The
method still returns the :class: |
None
|
resample
|
str
|
Resampling method for the |
'nearest'
|
auth
|
tuple[str, str] | None
|
Optional |
None
|
timeout
|
float
|
HTTP timeout in seconds for the metadata / coverage requests
(whole seconds; a value below 1 is clamped to 1). Defaults to
|
60.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The fetched coverage subset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
OGCAPIError
|
The service could not be reached or returned an error / a non-raster body. |
Examples:
Read a small bbox subset of a public coverage (network call — skipped in doctests):
>>> ds = Dataset.from_ogc_coverages( # doctest: +SKIP
... "https://maps.gnosis.earth/ogcapi",
... coverage="SRTM_ViewFinderPanorama",
... bbox=(5.0, 51.0, 6.0, 52.0),
... )
See Also
- :meth:
from_wcs: the classic WCS sibling. - :meth:
pyramids.feature.FeatureCollection.from_ogc_features: the OGC API – Features (vector) sibling. - :meth:
read_file: open a raster from a path or URL.
Source code in src/pyramids/dataset/dataset.py
2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 | |
copy(path=None)
#
Deep copy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Destination path to save the copied dataset. If None is passed, the copied dataset is created in memory. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
An independent copy. Access mode of the returned |
Dataset |
Dataset
|
|
Dataset
|
|
|
Dataset
|
|
Source code in src/pyramids/dataset/dataset.py
close()
#
Close the dataset.
Safe to call multiple times — subsequent calls after the first are no-ops.
Also releases the per-thread file manager created by
read_array(threadsafe=True): the calling thread's handle is
closed eagerly and the manager reference is dropped, so handles
held by other (finished) threads are released with it. Without
this, lingering read-only handles would keep the file locked on
Windows after close().
Source code in src/pyramids/dataset/dataset.py
create(cell_size, rows, columns, dtype, bands, top_left_corner, epsg, no_data_value=None, path=None)
classmethod
#
Create a new dataset and fill it with the no_data_value.
The new dataset will have an array filled with the no_data_value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cell_size
|
int | float
|
Cell size. |
required |
rows
|
int
|
Number of rows. |
required |
columns
|
int
|
Number of columns. |
required |
dtype
|
str
|
Data type. |
required |
bands
|
int | None
|
Number of bands to create in the output raster. |
required |
top_left_corner
|
Tuple
|
Coordinates of the top left corner point. |
required |
epsg
|
int
|
EPSG number to identify the projection of the coordinates in the created raster. |
required |
no_data_value
|
float | None
|
No data value. |
None
|
path
|
str
|
Path on disk; if None, the dataset is created in memory. Default is None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
A new dataset |
Source code in src/pyramids/dataset/dataset.py
create_empty(rows, cols, *, bands=1, dtype='float32', geo=None, epsg=4326, no_data_value=DEFAULT_NO_DATA_VALUE, driver_type='GTiff', path=None, options=None)
classmethod
#
Allocate an empty, header-only raster without materialising a full array.
Out-of-core algorithms allocate the output once and scatter result
windows into it with
write_array(array, window=Window(col_off, row_off, cols, rows))
(see :class:~pyramids.dataset.window.Window).
For the default driver_type="GTiff" the file is tiled, sparse,
and BigTIFF (see :data:OUT_OF_CORE_CREATION_OPTIONS), so a
50 000 x 50 000 float32 raster is created in O(1) RAM, never-written
blocks cost no disk, and writes past the 4 GB classic-TIFF ceiling
succeed. A never-written cell reads back as no_data_value (not 0) —
on GTiff because SPARSE_OK + the band no-data sentinel returns no-data
for unwritten blocks, and on MEM because the band is filled with the
no-data value at allocation — so downstream code must treat unwritten
tiles as no-data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
int
|
Number of rows of the output raster. |
required |
cols
|
int
|
Number of columns of the output raster. |
required |
bands
|
int
|
Number of bands. Default 1. |
1
|
dtype
|
str
|
NumPy dtype name for the bands (e.g. |
'float32'
|
geo
|
tuple[float, float, float, float, float, float] | None
|
Geotransform
|
None
|
epsg
|
int
|
EPSG code for the projection. Default 4326. |
4326
|
no_data_value
|
Any
|
No-data sentinel stamped on every band at
creation. Default :data: |
DEFAULT_NO_DATA_VALUE
|
driver_type
|
str
|
GDAL driver. |
'GTiff'
|
path
|
str | Path | None
|
Output path ( |
None
|
options
|
list[str] | None
|
GDAL creation options. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
An empty raster whose bands read back as |
Dataset
|
before any write. On GTiff this is sparse — SPARSE_OK keeps |
|
Dataset
|
never-written blocks unallocated and GDAL returns the no-data |
|
Dataset
|
sentinel for them; on MEM every band is filled with |
|
Dataset
|
at allocation, so unwritten MEM cells read back as no-data too. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
- Allocate an in-memory empty raster and read its no-data metadata:
- Allocate, then scatter a window into it and read it back:
>>> import numpy as np >>> from pyramids.dataset import Dataset >>> from pyramids.dataset import Window >>> ds = Dataset.create_empty(4, 4, dtype="float32", driver_type="MEM") >>> block = np.arange(4, dtype="float32").reshape(2, 2) >>> ds.write_array(block, window=Window(1, 1, 2, 2)) >>> ds.read_array(window=[1, 1, 2, 2]).tolist() [[0.0, 1.0], [2.0, 3.0]]
See Also
- :meth:
empty_like: Allocate an empty raster shaped like an existing template instead of from explicit dimensions. - :meth:
create: Allocate a raster and eagerly fill every cell with the no-data value (no sparse / BigTIFF defaults). - :meth:
write_array: Scatter a window into the allocated raster (window=(row_off, col_off, n_rows, n_cols)).
Source code in src/pyramids/dataset/dataset.py
2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 | |
empty_like(template, *, dtype=None, bands=None, no_data_value=_INHERIT_NO_DATA, path=None, options=None)
classmethod
#
Allocate an empty raster aligned to a template's geo / epsg / shape / nodata.
The header-only sibling of :meth:dataset_like — same spatial
footprint as template (geotransform, CRS, rows, columns, no-data),
but no array is written, so it can allocate an out-of-core output
the size of an input DEM without materialising it. Backed by GTiff
when path is given (tiled / sparse / BigTIFF via
:data:OUT_OF_CORE_CREATION_OPTIONS), otherwise MEM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
Dataset
|
Source raster whose geotransform, CRS, shape, and no-data value the output copies. |
required |
dtype
|
str | None
|
NumPy dtype name for the output bands. |
None
|
bands
|
int | None
|
Number of output bands. |
None
|
no_data_value
|
Any
|
No-data sentinel for the output. Default inherits
from the template: when the band count is unchanged and every
template band has a sentinel, the per-band no-data values
are preserved; otherwise (a |
_INHERIT_NO_DATA
|
path
|
str | Path | None
|
Output path ( |
None
|
options
|
list[str] | None
|
GDAL creation options for the GTiff driver. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
An empty raster matching the template's footprint. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
- Allocate an empty raster shaped like an existing one, with a
different dtype:
>>> import numpy as np >>> from pyramids.dataset import Dataset >>> template = Dataset.create_from_array( ... np.ones((3, 4, 5), dtype="float32"), ... top_left_corner=(0.0, 10.0), cell_size=0.5, epsg=4326, ... no_data_value=-9999.0, ... ) >>> out = Dataset.empty_like(template, dtype="int16") >>> (out.rows, out.columns, out.band_count, out.epsg) (4, 5, 3, 4326) >>> out.geotransform == template.geotransform True - Reduce the band count and inherit the template's no-data value,
then confirm the empty output reads back as no-data:
>>> import numpy as np >>> from pyramids.dataset import Dataset >>> template = Dataset.create_from_array( ... np.ones((3, 4, 4), dtype="float32"), ... top_left_corner=(0.0, 10.0), cell_size=1.0, epsg=4326, ... no_data_value=-9999.0, ... ) >>> out = Dataset.empty_like(template, bands=1) >>> out.band_count 1 >>> float(out.no_data_value[0]) -9999.0
See Also
- :meth:
create_empty: Allocate an empty raster from explicit dimensions / CRS instead of copying a template. - :meth:
dataset_like: The array-writing sibling — copies the template footprint and writes a supplied array. - :meth:
write_array: Scatter a window into the allocated raster.
Source code in src/pyramids/dataset/dataset.py
3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 | |
from_features(features, *, cell_size=None, template=None, column_name=None)
classmethod
#
Rasterize a :class:FeatureCollection into a new :class:Dataset.
Burns the values from column_name (or every attribute
column if None) into a single-band or multi-band raster.
When a template Dataset is given, the output adopts its
geotransform, cell size, row/column count, and no-data value.
Otherwise cell_size controls the resolution and the extent
is derived from :attr:FeatureCollection.total_bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
FeatureCollection
|
The vector to rasterize. |
required |
cell_size
|
int | float | None
|
Cell size for the new raster. Required unless
|
None
|
template
|
Dataset | None
|
Optional template raster. When supplied, the output inherits its geotransform and no-data value. |
None
|
column_name
|
str | list[str] | None
|
Attribute column(s) to burn as band values. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
The burned raster. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
TypeError
|
|
CRSError
|
|
Source code in src/pyramids/dataset/dataset.py
from_points(points, value_column, *, algorithm='invdist:power=2.0:smoothing=0.0', cell_size=None, width=None, height=None, bbox=None, epsg=None)
classmethod
#
Interpolate scattered point samples onto a regular grid (gdal.Grid).
The GDAL-native equivalent of gdal_grid — turns an irregular point
layer (gauge readings, soundings, station observations) into a
continuous single-band raster. The output extent defaults to the points'
bounding box and the resolution is set by cell_size (or an explicit
width/height).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
FeatureCollection
|
A point :class: |
required |
value_column
|
str
|
Numeric attribute column to interpolate (the Z field). |
required |
algorithm
|
str
|
A |
'invdist:power=2.0:smoothing=0.0'
|
cell_size
|
float | None
|
Output pixel size in the points' CRS units. Required unless both
|
None
|
width
|
int | None
|
Output width in pixels. Overrides |
None
|
height
|
int | None
|
Output height in pixels. Overrides |
None
|
bbox
|
tuple[float, float, float, float] | None
|
|
None
|
epsg
|
int | None
|
Output EPSG code. Defaults to the points' CRS. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
A single-band raster of the interpolated surface. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
FailedToSaveError
|
|
Examples:
- Inverse-distance interpolate four corner readings onto a 1-degree
grid and read back the surface shape:
>>> from shapely.geometry import Point >>> from geopandas import GeoDataFrame >>> from pyramids.feature import FeatureCollection >>> from pyramids.dataset import Dataset >>> gdf = GeoDataFrame( ... {"rain": [10.0, 20.0, 30.0, 40.0]}, ... geometry=[Point(0, 0), Point(10, 0), Point(0, 10), Point(10, 10)], ... crs="EPSG:4326", ... ) >>> ds = Dataset.from_points(FeatureCollection(gdf), "rain", cell_size=1.0) >>> (ds.rows, ds.columns, ds.band_count) (10, 10, 1) - Use nearest-neighbour with an explicit output size:
>>> from shapely.geometry import Point >>> from geopandas import GeoDataFrame >>> from pyramids.feature import FeatureCollection >>> from pyramids.dataset import Dataset >>> gdf = GeoDataFrame( ... {"z": [1.0, 2.0, 3.0, 4.0]}, ... geometry=[Point(0, 0), Point(5, 0), Point(0, 5), Point(5, 5)], ... crs="EPSG:4326", ... ) >>> ds = Dataset.from_points( ... FeatureCollection(gdf), "z", algorithm="nearest", width=5, height=5 ... ) >>> ds.columns 5
Source code in src/pyramids/dataset/dataset.py
3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 | |
create_from_array(arr, top_left_corner=None, cell_size=None, geo=None, epsg=4326, no_data_value=DEFAULT_NO_DATA_VALUE, driver_type='MEM', path=None)
classmethod
#
Create a new dataset from an array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
ndarray
|
Numpy array. |
required |
top_left_corner
|
Tuple[float, float]
|
The coordinates of the top left corner of the dataset. |
None
|
cell_size
|
int | float
|
Cell size in the same units of the coordinate reference system defined by the |
None
|
geo
|
Tuple[float, float, float, float, float, float]
|
Geotransform tuple (minimum lon/x, pixel-size, rotation, maximum lat/y, rotation, pixel-size). |
None
|
epsg
|
int
|
Integer reference number to the projection (https://epsg.io/). |
4326
|
no_data_value
|
Any
|
No data value to mask the cells out of the domain. The default is -9999. |
DEFAULT_NO_DATA_VALUE
|
driver_type
|
str
|
Driver type ["GTiff", "MEM", "netcdf"]. Default is "MEM". |
'MEM'
|
path
|
str
|
Path to save the driver. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
Dataset object will be returned. |
Source code in src/pyramids/dataset/dataset.py
3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 | |
dataset_like(src, array, path=None)
classmethod
#
Create a new dataset like another dataset.
dataset_like method creates a Dataset from an array like another source dataset. The new dataset
will have the same projection, coordinates or the top left corner of the original dataset,
cell size, no_data_velue, and number of rows and columns.
the array and the source dataset should have the same number of columns and rows
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
Dataset
|
source raster to get the spatial information |
required |
array
|
ndarray
|
data to store in the new dataset. |
required |
path
|
str
|
path to save the new dataset, if not given, the method will return in-memory dataset. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
if the |
Source code in src/pyramids/dataset/dataset.py
from_band_files(files, *, band_names=None, align=False, no_data_value=_INHERIT_NO_DATA, path=None)
classmethod
#
Stack N single-band rasters into one multi-band :class:Dataset.
Each input file becomes one band, in order, with its name preserved.
This is the natural target for an Earth Engine default download
(<assetSlug>.<bandName>.tif — one file per band), a Landsat
Collection-2 scene (per-band .TIF), or a Sentinel-2 SAFE
(per-band JP2s).
By default all inputs must already share the same grid and CRS;
pass align=True to resample mismatched rasters onto the first
file's grid (nearest-neighbour, via :meth:align). When the inputs
have different numpy dtypes the output dtype is the smallest type
that holds every input without a lossy cast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
Sequence[str | Path]
|
Paths (or URLs / |
required |
band_names
|
list[str] | None
|
Explicit band names, one per file. When |
None
|
align
|
bool
|
When |
False
|
no_data_value
|
Any
|
No-data value stamped on the output bands. When
omitted, it is inherited from the source rasters (a warning
is issued if they disagree, and the first file's value
wins; if no source declares one, the output has none). Pass
an explicit value (including |
_INHERIT_NO_DATA
|
path
|
str | Path | None
|
Output |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
A multi-band dataset with |
Dataset
|
and |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
AlignmentError
|
|
CRSError
|
An input raster has no CRS. |
Examples:
- Stack three per-band GeoTIFFs into one 3-band dataset; band
names come from the file names:
>>> import numpy as np >>> import tempfile, os >>> from pyramids.dataset import Dataset >>> d = tempfile.mkdtemp() >>> paths = [] >>> for name, val in [("scene.B2.tif", 2), ("scene.B3.tif", 3), ("scene.B4.tif", 4)]: ... p = os.path.join(d, name) ... _ = Dataset.create_from_array( ... np.full((4, 5), val, dtype="int16"), ... top_left_corner=(0, 0), cell_size=1.0, epsg=4326, path=p, ... ).close() ... paths.append(p) >>> ds = Dataset.from_band_files(paths) >>> ds.band_count 3 >>> ds.band_names ['B2', 'B3', 'B4'] >>> [int(ds.read_array(band=i).flat[0]) for i in range(3)] [2, 3, 4] - Override the band names explicitly:
- Mismatched grids are rejected unless
align=True:>>> odd = os.path.join(d, "odd.tif") >>> _ = Dataset.create_from_array( ... np.zeros((8, 9), dtype="int16"), ... top_left_corner=(0, 0), cell_size=0.5, epsg=4326, path=odd, ... ).close() >>> try: ... Dataset.from_band_files([paths[0], odd]) ... except AlignmentError as exc: ... print("align=True" in str(exc)) True >>> aligned = Dataset.from_band_files([paths[0], odd], align=True) >>> aligned.band_count 2 >>> (aligned.rows, aligned.columns) == ( ... Dataset.read_file(paths[0]).rows, ... Dataset.read_file(paths[0]).columns, ... ) True
See Also
- :meth:
align: resample one dataset onto another's grid. - :meth:
create_from_array: build a dataset from a numpy array. - :meth:
pyramids.dataset.DatasetCollection.from_files: stack rasters along time instead of along bands.
Source code in src/pyramids/dataset/dataset.py
3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 | |
from_archive(url_or_path, *, kind='auto', member_glob='*', band_names=None, align=False, no_data_value=_INHERIT_NO_DATA, path=None)
classmethod
#
Open every raster in an archive and merge them into one multi-band Dataset.
Lists the archive's members (locally or over the network — a remote ZIP
is read via the chained /vsizip//vsicurl/… path) and hands them to
:meth:from_band_files. For "one Dataset per member" (a temporal stack)
use :meth:pyramids.dataset.DatasetCollection.from_archive instead.
The archive's file name must carry a recognised extension (.zip /
.tar / .tar.gz / .gz) — GDAL's archive handlers key off the
extension. An extension-less download URL (e.g. an Earth Engine
getDownloadURL ending in :getPixels) must first be fetched and
saved with a .zip name (or written to /vsimem/<name>.zip via
:func:osgeo.gdal.FileFromMemBuffer) before calling this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_or_path
|
str | Path
|
Path or URL of the archive ( |
required |
kind
|
str
|
Archive kind — |
'auto'
|
member_glob
|
str
|
:mod: |
'*'
|
band_names
|
list[str] | None
|
Explicit per-band names; |
None
|
align
|
bool
|
When |
False
|
no_data_value
|
Any
|
No-data value for the output bands; omitted means "inherit from the members". |
_INHERIT_NO_DATA
|
path
|
str | Path | None
|
Output |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Dataset
|
A multi-band dataset, one band per matching archive member. |
Raises:
| Type | Description |
|---|---|
FileFormatNotSupportedError
|
|
FileNotFoundError
|
No member matched |
ValueError / AlignmentError / CRSError
|
As for :meth: |
Examples:
- Stack the raster members of a local ZIP into one multi-band dataset
(band names come from the member names):
>>> import os, tempfile, zipfile >>> import numpy as np >>> from pyramids.dataset import Dataset >>> d = tempfile.mkdtemp() >>> members = [] >>> for name, val in [("scene.B2.tif", 2), ("scene.B3.tif", 3)]: ... p = os.path.join(d, name) ... _ = Dataset.create_from_array( ... np.full((4, 5), val, dtype="int16"), ... top_left_corner=(0, 0), cell_size=1.0, epsg=4326, path=p, ... ).close() ... members.append(p) >>> zip_path = os.path.join(d, "download.zip") >>> with zipfile.ZipFile(zip_path, "w") as zf: ... for m in members: ... zf.write(m, arcname=os.path.basename(m)) >>> ds = Dataset.from_archive(zip_path, member_glob="*.tif") >>> ds.band_count 2 >>> ds.band_names ['B2', 'B3'] >>> [int(ds.read_array(band=i).flat[0]) for i in range(2)] [2, 3]
See Also
- :meth:
from_band_files: stack a known list of single-band rasters. - :meth:
pyramids.dataset.DatasetCollection.from_archive: open each member as a separate timestep instead of merging them into bands.
Source code in src/pyramids/dataset/dataset.py
3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 | |