1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 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 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959
|
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
from sys import version_info as _swig_python_version_info
if _swig_python_version_info < (2, 7, 0):
raise RuntimeError("Python 2.7 or later required")
# Import the low-level C/C++ module
if __package__ or "." in __name__:
from . import _gdal
else:
import _gdal
try:
import builtins as __builtin__
except ImportError:
import __builtin__
def _swig_repr(self):
try:
strthis = "proxy of " + self.this.__repr__()
except __builtin__.Exception:
strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
def _swig_setattr_nondynamic_instance_variable(set):
def set_instance_attr(self, name, value):
if name == "thisown":
self.this.own(value)
elif name == "this":
set(self, name, value)
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
set(self, name, value)
else:
raise AttributeError("You cannot add instance attributes to %s" % self)
return set_instance_attr
def _swig_setattr_nondynamic_class_variable(set):
def set_class_attr(cls, name, value):
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
set(cls, name, value)
else:
raise AttributeError("You cannot add class attributes to %s" % cls)
return set_class_attr
def _swig_add_metaclass(metaclass):
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
def wrapper(cls):
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
return wrapper
class _SwigNonDynamicMeta(type):
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
have_warned = 0
def deprecation_warn(module, sub_package=None, new_module=None):
global have_warned
if have_warned == 1:
return
have_warned = 1
if sub_package is None or sub_package == 'utils':
sub_package = 'osgeo_utils'
if new_module is None:
new_module = module
new_module = '{}.{}'.format(sub_package, new_module)
from warnings import warn
warn('{}.py was placed in a namespace, it is now available as {}' .format(module, new_module),
DeprecationWarning)
from osgeo.gdalconst import *
from osgeo import gdalconst
import sys
byteorders = {"little": "<",
"big": ">"}
array_modes = { gdalconst.GDT_Int16: ("%si2" % byteorders[sys.byteorder]),
gdalconst.GDT_UInt16: ("%su2" % byteorders[sys.byteorder]),
gdalconst.GDT_Int32: ("%si4" % byteorders[sys.byteorder]),
gdalconst.GDT_UInt32: ("%su4" % byteorders[sys.byteorder]),
gdalconst.GDT_Float32: ("%sf4" % byteorders[sys.byteorder]),
gdalconst.GDT_Float64: ("%sf8" % byteorders[sys.byteorder]),
gdalconst.GDT_CFloat32: ("%sf4" % byteorders[sys.byteorder]),
gdalconst.GDT_CFloat64: ("%sf8" % byteorders[sys.byteorder]),
gdalconst.GDT_Byte: ("%st8" % byteorders[sys.byteorder]),
}
def RGBFile2PCTFile( src_filename, dst_filename ):
src_ds = Open(src_filename)
if src_ds is None or src_ds == 'NULL':
return 1
ct = ColorTable()
err = ComputeMedianCutPCT(src_ds.GetRasterBand(1),
src_ds.GetRasterBand(2),
src_ds.GetRasterBand(3),
256, ct)
if err != 0:
return err
gtiff_driver = GetDriverByName('GTiff')
if gtiff_driver is None:
return 1
dst_ds = gtiff_driver.Create(dst_filename,
src_ds.RasterXSize, src_ds.RasterYSize)
dst_ds.GetRasterBand(1).SetRasterColorTable(ct)
err = DitherRGB2PCT(src_ds.GetRasterBand(1),
src_ds.GetRasterBand(2),
src_ds.GetRasterBand(3),
dst_ds.GetRasterBand(1),
ct)
dst_ds = None
src_ds = None
return 0
def listdir(path, recursionLevel = -1, options = []):
""" Iterate over a directory.
recursionLevel = -1 means unlimited level of recursion.
"""
dir = OpenDir(path, recursionLevel, options)
if not dir:
raise OSError(path + ' does not exist')
try:
while True:
entry = GetNextDirEntry(dir)
if not entry:
break
yield entry
finally:
CloseDir(dir)
def GetUseExceptions(*args) -> "int":
r"""GetUseExceptions() -> int"""
return _gdal.GetUseExceptions(*args)
def UseExceptions(*args) -> "void":
r"""UseExceptions()"""
return _gdal.UseExceptions(*args)
def DontUseExceptions(*args) -> "void":
r"""DontUseExceptions()"""
return _gdal.DontUseExceptions(*args)
def VSIFReadL(*args) -> "void **":
r"""VSIFReadL(unsigned int nMembSize, unsigned int nMembCount, VSILFILE fp) -> unsigned int"""
return _gdal.VSIFReadL(*args)
def VSIGetMemFileBuffer_unsafe(*args) -> "vsi_l_offset *":
r"""VSIGetMemFileBuffer_unsafe(char const * utf8_path)"""
return _gdal.VSIGetMemFileBuffer_unsafe(*args)
def InfoOptions(options=None, format='text', deserialize=True,
computeMinMax=False, reportHistograms=False, reportProj4=False,
stats=False, approxStats=False, computeChecksum=False,
showGCPs=True, showMetadata=True, showRAT=True, showColorTable=True,
listMDD=False, showFileList=True, allMetadata=False,
extraMDDomains=None, wktFormat=None):
""" Create a InfoOptions() object that can be passed to gdal.Info()
options can be be an array of strings, a string or let empty and filled from other keywords."""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
format = 'text'
if '-json' in new_options:
format = 'json'
else:
new_options = options
if format == 'json':
new_options += ['-json']
if '-json' in new_options:
format = 'json'
if computeMinMax:
new_options += ['-mm']
if reportHistograms:
new_options += ['-hist']
if reportProj4:
new_options += ['-proj4']
if stats:
new_options += ['-stats']
if approxStats:
new_options += ['-approx_stats']
if computeChecksum:
new_options += ['-checksum']
if not showGCPs:
new_options += ['-nogcp']
if not showMetadata:
new_options += ['-nomd']
if not showRAT:
new_options += ['-norat']
if not showColorTable:
new_options += ['-noct']
if listMDD:
new_options += ['-listmdd']
if not showFileList:
new_options += ['-nofl']
if allMetadata:
new_options += ['-mdd', 'all']
if wktFormat:
new_options += ['-wkt_format', wktFormat]
if extraMDDomains is not None:
for mdd in extraMDDomains:
new_options += ['-mdd', mdd]
return (GDALInfoOptions(new_options), format, deserialize)
def Info(ds, **kwargs):
"""Return information on a dataset.
Parameters
----------
ds:
a Dataset object or a filename
kwargs:
options: return of gdal.InfoOptions(), string or array of strings
other keywords arguments of gdal.InfoOptions().
If options is provided as a gdal.InfoOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, format, deserialize) = InfoOptions(**kwargs)
else:
(opts, format, deserialize) = kwargs['options']
if isinstance(ds, str):
ds = Open(ds)
ret = InfoInternal(ds, opts)
if format == 'json' and deserialize:
import json
ret = json.loads(ret)
return ret
def MultiDimInfoOptions(options=None, detailed=False, array=None, arrayoptions=None, limit=None, as_text=False):
""" Create a MultiDimInfoOptions() object that can be passed to gdal.MultiDimInfo()
options can be be an array of strings, a string or let empty and filled from other keywords."""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if detailed:
new_options += ['-detailed']
if array:
new_options += ['-array', array]
if limit:
new_options += ['-limit', str(limit)]
if arrayoptions:
for option in arrayoptions:
new_options += ['-arrayoption', option]
return GDALMultiDimInfoOptions(new_options), as_text
def MultiDimInfo(ds, **kwargs):
"""Return information on a dataset.
Parameters
----------
ds:
a Dataset object or a filename
kwargs:
options: return of gdal.MultiDimInfoOptions(), string or array of strings
other keywords arguments of gdal.MultiDimInfoOptions().
If options is provided as a gdal.MultiDimInfoOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
opts, as_text = MultiDimInfoOptions(**kwargs)
else:
opts = kwargs['options']
as_text = True
if isinstance(ds, str):
ds = OpenEx(ds, OF_VERBOSE_ERROR | OF_MULTIDIM_RASTER)
ret = MultiDimInfoInternal(ds, opts)
if not as_text:
import json
ret = json.loads(ret)
return ret
def _strHighPrec(x):
return ('%.18g' % x) if isinstance(x, float) else str(x)
mapGRIORAMethodToString = {
gdalconst.GRIORA_NearestNeighbour: 'near',
gdalconst.GRIORA_Bilinear: 'bilinear',
gdalconst.GRIORA_Cubic: 'cubic',
gdalconst.GRIORA_CubicSpline: 'cubicspline',
gdalconst.GRIORA_Lanczos: 'lanczos',
gdalconst.GRIORA_Average: 'average',
gdalconst.GRIORA_RMS: 'rms',
gdalconst.GRIORA_Mode: 'mode',
gdalconst.GRIORA_Gauss: 'gauss',
}
def TranslateOptions(options=None, format=None,
outputType = gdalconst.GDT_Unknown, bandList=None, maskBand=None,
width = 0, height = 0, widthPct = 0.0, heightPct = 0.0,
xRes = 0.0, yRes = 0.0,
creationOptions=None, srcWin=None, projWin=None, projWinSRS=None, strict = False,
unscale = False, scaleParams=None, exponents=None,
outputBounds=None, metadataOptions=None,
outputSRS=None, nogcp=False, GCPs=None,
noData=None, rgbExpand=None,
stats = False, rat = True, xmp = True, resampleAlg=None,
overviewLevel = 'AUTO',
callback=None, callback_data=None):
"""Create a TranslateOptions() object that can be passed to gdal.Translate()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
outputType:
output type (gdalconst.GDT_Byte, etc...)
bandList:
array of band numbers (index start at 1)
maskBand:
mask band to generate or not ("none", "auto", "mask", 1, ...)
width:
width of the output raster in pixel
height:
height of the output raster in pixel
widthPct:
width of the output raster in percentage (100 = original width)
heightPct:
height of the output raster in percentage (100 = original height)
xRes:
output horizontal resolution
yRes:
output vertical resolution
creationOptions:
list of creation options
srcWin:
subwindow in pixels to extract: [left_x, top_y, width, height]
projWin:
subwindow in projected coordinates to extract: [ulx, uly, lrx, lry]
projWinSRS:
SRS in which projWin is expressed
strict:
strict mode
unscale:
unscale values with scale and offset metadata
scaleParams:
list of scale parameters, each of the form [src_min,src_max] or [src_min,src_max,dst_min,dst_max]
exponents:
list of exponentiation parameters
outputBounds:
assigned output bounds: [ulx, uly, lrx, lry]
metadataOptions:
list of metadata options
outputSRS:
assigned output SRS
nogcp:
ignore GCP in the raster
GCPs:
list of GCPs
noData:
nodata value (or "none" to unset it)
rgbExpand:
Color palette expansion mode: "gray", "rgb", "rgba"
stats:
whether to calculate statistics
rat:
whether to write source RAT
xmp:
whether to copy XMP metadata
resampleAlg:
resampling mode
overviewLevel:
To specify which overview level of source files must be used
callback:
callback method
callback_data:
user data for callback
"""
# Only used for tests
return_option_list = options == '__RETURN_OPTION_LIST__'
if return_option_list:
options = []
else:
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
new_options += ['-ot', GetDataTypeName(outputType)]
if maskBand != None:
new_options += ['-mask', str(maskBand)]
if bandList != None:
for b in bandList:
new_options += ['-b', str(b)]
if width != 0 or height != 0:
new_options += ['-outsize', str(width), str(height)]
elif widthPct != 0 and heightPct != 0:
new_options += ['-outsize', str(widthPct) + '%%', str(heightPct) + '%%']
if creationOptions is not None:
if isinstance(creationOptions, str):
new_options += ['-co', creationOptions]
else:
for opt in creationOptions:
new_options += ['-co', opt]
if srcWin is not None:
new_options += ['-srcwin', _strHighPrec(srcWin[0]), _strHighPrec(srcWin[1]), _strHighPrec(srcWin[2]), _strHighPrec(srcWin[3])]
if strict:
new_options += ['-strict']
if unscale:
new_options += ['-unscale']
if scaleParams:
for scaleParam in scaleParams:
new_options += ['-scale']
for v in scaleParam:
new_options += [str(v)]
if exponents:
for exponent in exponents:
new_options += ['-exponent', _strHighPrec(exponent)]
if outputBounds is not None:
new_options += ['-a_ullr', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
if metadataOptions is not None:
if isinstance(metadataOptions, str):
new_options += ['-mo', metadataOptions]
else:
for opt in metadataOptions:
new_options += ['-mo', opt]
if outputSRS is not None:
new_options += ['-a_srs', str(outputSRS)]
if nogcp:
new_options += ['-nogcp']
if GCPs is not None:
for gcp in GCPs:
new_options += ['-gcp', _strHighPrec(gcp.GCPPixel), _strHighPrec(gcp.GCPLine), _strHighPrec(gcp.GCPX), str(gcp.GCPY), _strHighPrec(gcp.GCPZ)]
if projWin is not None:
new_options += ['-projwin', _strHighPrec(projWin[0]), _strHighPrec(projWin[1]), _strHighPrec(projWin[2]), _strHighPrec(projWin[3])]
if projWinSRS is not None:
new_options += ['-projwin_srs', str(projWinSRS)]
if noData is not None:
new_options += ['-a_nodata', _strHighPrec(noData)]
if rgbExpand is not None:
new_options += ['-expand', str(rgbExpand)]
if stats:
new_options += ['-stats']
if not rat:
new_options += ['-norat']
if not xmp:
new_options += ['-noxmp']
if resampleAlg is not None:
if resampleAlg in mapGRIORAMethodToString:
new_options += ['-r', mapGRIORAMethodToString[resampleAlg]]
else:
new_options += ['-r', str(resampleAlg)]
if xRes != 0 and yRes != 0:
new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
if overviewLevel is None or isinstance(overviewLevel, str):
pass
elif isinstance(overviewLevel, int):
if overviewLevel < 0:
overviewLevel = 'AUTO' + str(overviewLevel)
else:
overviewLevel = str(overviewLevel)
else:
overviewLevel = None
if overviewLevel is not None and overviewLevel != 'AUTO':
new_options += ['-ovr', overviewLevel]
if return_option_list:
return new_options
return (GDALTranslateOptions(new_options), callback, callback_data)
def Translate(destName, srcDS, **kwargs):
"""Convert a dataset.
Parameters
----------
destName:
Output dataset name
srcDS:
a Dataset object or a filename
kwargs:
options: return of gdal.TranslateOptions(), string or array of strings
other keywords arguments of gdal.TranslateOptions().
If options is provided as a gdal.TranslateOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = TranslateOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = Open(srcDS)
return TranslateInternal(destName, srcDS, opts, callback, callback_data)
def WarpOptions(options=None, format=None,
outputBounds=None,
outputBoundsSRS=None,
xRes=None, yRes=None, targetAlignedPixels = False,
width = 0, height = 0,
srcSRS=None, dstSRS=None,
coordinateOperation=None,
srcAlpha = False, dstAlpha = False,
warpOptions=None, errorThreshold=None,
warpMemoryLimit=None, creationOptions=None, outputType = gdalconst.GDT_Unknown,
workingType = gdalconst.GDT_Unknown, resampleAlg=None,
srcNodata=None, dstNodata=None, multithread = False,
tps = False, rpc = False, geoloc = False, polynomialOrder=None,
transformerOptions=None, cutlineDSName=None,
cutlineLayer=None, cutlineWhere=None, cutlineSQL=None, cutlineBlend=None, cropToCutline = False,
copyMetadata = True, metadataConflictValue=None,
setColorInterpretation = False,
overviewLevel = 'AUTO',
callback=None, callback_data=None):
"""Create a WarpOptions() object that can be passed to gdal.Warp()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
outputBounds:
output bounds as (minX, minY, maxX, maxY) in target SRS
outputBoundsSRS:
SRS in which output bounds are expressed, in the case they are not expressed in dstSRS
xRes:
output resolution in target SRS
yRes:
output resolution in target SRS
targetAlignedPixels:
whether to force output bounds to be multiple of output resolution
width:
width of the output raster in pixel
height:
height of the output raster in pixel
srcSRS:
source SRS
dstSRS:
output SRS
coordinateOperation:
coordinate operation as a PROJ string or WKT string
srcAlpha:
whether to force the last band of the input dataset to be considered as an alpha band
dstAlpha:
whether to force the creation of an output alpha band
outputType:
output type (gdalconst.GDT_Byte, etc...)
workingType:
working type (gdalconst.GDT_Byte, etc...)
warpOptions:
list of warping options
errorThreshold:
error threshold for approximation transformer (in pixels)
warpMemoryLimit:
size of working buffer in MB
resampleAlg:
resampling mode
creationOptions:
list of creation options
srcNodata:
source nodata value(s)
dstNodata:
output nodata value(s)
multithread:
whether to multithread computation and I/O operations
tps:
whether to use Thin Plate Spline GCP transformer
rpc:
whether to use RPC transformer
geoloc:
whether to use GeoLocation array transformer
polynomialOrder:
order of polynomial GCP interpolation
transformerOptions:
list of transformer options
cutlineDSName:
cutline dataset name
cutlineLayer:
cutline layer name
cutlineWhere:
cutline WHERE clause
cutlineSQL:
cutline SQL statement
cutlineBlend:
cutline blend distance in pixels
cropToCutline:
whether to use cutline extent for output bounds
copyMetadata:
whether to copy source metadata
metadataConflictValue:
metadata data conflict value
setColorInterpretation:
whether to force color interpretation of input bands to output bands
overviewLevel:
To specify which overview level of source files must be used
callback:
callback method
callback_data:
user data for callback
"""
# Only used for tests
return_option_list = options == '__RETURN_OPTION_LIST__'
if return_option_list:
options = []
else:
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
new_options += ['-ot', GetDataTypeName(outputType)]
if workingType != gdalconst.GDT_Unknown:
new_options += ['-wt', GetDataTypeName(workingType)]
if outputBounds is not None:
new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
if outputBoundsSRS is not None:
new_options += ['-te_srs', str(outputBoundsSRS)]
if xRes is not None and yRes is not None:
new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
if width != 0 or height != 0:
new_options += ['-ts', str(width), str(height)]
if srcSRS is not None:
new_options += ['-s_srs', str(srcSRS)]
if dstSRS is not None:
new_options += ['-t_srs', str(dstSRS)]
if coordinateOperation is not None:
new_options += ['-ct', coordinateOperation]
if targetAlignedPixels:
new_options += ['-tap']
if srcAlpha:
new_options += ['-srcalpha']
if dstAlpha:
new_options += ['-dstalpha']
if warpOptions is not None:
for opt in warpOptions:
new_options += ['-wo', str(opt)]
if errorThreshold is not None:
new_options += ['-et', _strHighPrec(errorThreshold)]
if resampleAlg is not None:
mapMethodToString = {
gdalconst.GRA_NearestNeighbour: 'near',
gdalconst.GRA_Bilinear: 'bilinear',
gdalconst.GRA_Cubic: 'cubic',
gdalconst.GRA_CubicSpline: 'cubicspline',
gdalconst.GRA_Lanczos: 'lanczos',
gdalconst.GRA_Average: 'average',
gdalconst.GRA_RMS: 'rms',
gdalconst.GRA_Mode: 'mode',
gdalconst.GRA_Max: 'max',
gdalconst.GRA_Min: 'min',
gdalconst.GRA_Med: 'med',
gdalconst.GRA_Q1: 'q1',
gdalconst.GRA_Q3: 'q3',
gdalconst.GRA_Sum: 'sum',
}
if resampleAlg in mapMethodToString:
new_options += ['-r', mapMethodToString[resampleAlg]]
else:
new_options += ['-r', str(resampleAlg)]
if warpMemoryLimit is not None:
new_options += ['-wm', str(warpMemoryLimit)]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if srcNodata is not None:
new_options += ['-srcnodata', str(srcNodata)]
if dstNodata is not None:
new_options += ['-dstnodata', str(dstNodata)]
if multithread:
new_options += ['-multi']
if tps:
new_options += ['-tps']
if rpc:
new_options += ['-rpc']
if geoloc:
new_options += ['-geoloc']
if polynomialOrder is not None:
new_options += ['-order', str(polynomialOrder)]
if transformerOptions is not None:
for opt in transformerOptions:
new_options += ['-to', opt]
if cutlineDSName is not None:
new_options += ['-cutline', str(cutlineDSName)]
if cutlineLayer is not None:
new_options += ['-cl', str(cutlineLayer)]
if cutlineWhere is not None:
new_options += ['-cwhere', str(cutlineWhere)]
if cutlineSQL is not None:
new_options += ['-csql', str(cutlineSQL)]
if cutlineBlend is not None:
new_options += ['-cblend', str(cutlineBlend)]
if cropToCutline:
new_options += ['-crop_to_cutline']
if not copyMetadata:
new_options += ['-nomd']
if metadataConflictValue:
new_options += ['-cvmd', str(metadataConflictValue)]
if setColorInterpretation:
new_options += ['-setci']
if overviewLevel is None or isinstance(overviewLevel, str):
pass
elif isinstance(overviewLevel, int):
if overviewLevel < 0:
overviewLevel = 'AUTO' + str(overviewLevel)
else:
overviewLevel = str(overviewLevel)
else:
overviewLevel = None
if overviewLevel is not None and overviewLevel != 'AUTO':
new_options += ['-ovr', overviewLevel]
if return_option_list:
return new_options
return (GDALWarpAppOptions(new_options), callback, callback_data)
def Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs):
"""Warp one or several datasets.
Parameters
----------
destNameOrDestDS:
Output dataset name or object
srcDSOrSrcDSTab:
an array of Dataset objects or filenames, or a Dataset object or a filename
kwargs:
options: return of gdal.WarpOptions(), string or array of strings,
other keywords arguments of gdal.WarpOptions().
If options is provided as a gdal.WarpOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = WarpOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDSOrSrcDSTab, str):
srcDSTab = [Open(srcDSOrSrcDSTab)]
elif isinstance(srcDSOrSrcDSTab, list):
srcDSTab = []
for elt in srcDSOrSrcDSTab:
if isinstance(elt, str):
srcDSTab.append(Open(elt))
else:
srcDSTab.append(elt)
else:
srcDSTab = [srcDSOrSrcDSTab]
if isinstance(destNameOrDestDS, str):
return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
else:
return wrapper_GDALWarpDestDS(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
def VectorTranslateOptions(options=None, format=None,
accessMode=None,
srcSRS=None, dstSRS=None, reproject=True,
coordinateOperation=None,
SQLStatement=None, SQLDialect=None, where=None, selectFields=None,
addFields=False,
forceNullable=False,
emptyStrAsNull=False,
spatFilter=None, spatSRS=None,
datasetCreationOptions=None,
layerCreationOptions=None,
layers=None,
layerName=None,
geometryType=None,
dim=None,
segmentizeMaxDist= None,
makeValid=False,
zField=None,
resolveDomains=False,
skipFailures=False,
limit=None,
callback=None, callback_data=None):
"""Create a VectorTranslateOptions() object that can be passed to gdal.VectorTranslate()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
format ("ESRI Shapefile", etc...)
accessMode:
None for creation, 'update', 'append', 'upsert', 'overwrite'
srcSRS:
source SRS
dstSRS:
output SRS (with reprojection if reproject = True)
coordinateOperation:
coordinate operation as a PROJ string or WKT string
reproject:
whether to do reprojection
SQLStatement:
SQL statement to apply to the source dataset
SQLDialect:
SQL dialect ('OGRSQL', 'SQLITE', ...)
where:
WHERE clause to apply to source layer(s)
selectFields:
list of fields to select
addFields:
whether to add new fields found in source layers (to be used with accessMode == 'append' or 'upsert')
forceNullable:
whether to drop NOT NULL constraints on newly created fields
emptyStrAsNull:
whether to treat empty string values as NULL
spatFilter:
spatial filter as (minX, minY, maxX, maxY) bounding box
spatSRS:
SRS in which the spatFilter is expressed. If not specified, it is assumed to be the one of the layer(s)
datasetCreationOptions:
list of dataset creation options
layerCreationOptions:
list of layer creation options
layers:
list of layers to convert
layerName:
output layer name
geometryType:
output layer geometry type ('POINT', ....)
dim:
output dimension ('XY', 'XYZ', 'XYM', 'XYZM', 'layer_dim')
segmentizeMaxDist:
maximum distance between consecutive nodes of a line geometry
makeValid:
run MakeValid() on geometries
zField:
name of field to use to set the Z component of geometries
resolveDomains:
whether to create an additional field for each field associated with a coded field domain.
skipFailures:
whether to skip failures
limit:
maximum number of features to read per layer
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-f', format]
if srcSRS is not None:
new_options += ['-s_srs', str(srcSRS)]
if dstSRS is not None:
if reproject:
new_options += ['-t_srs', str(dstSRS)]
else:
new_options += ['-a_srs', str(dstSRS)]
if coordinateOperation is not None:
new_options += ['-ct', coordinateOperation]
if SQLStatement is not None:
new_options += ['-sql', str(SQLStatement)]
if SQLDialect is not None:
new_options += ['-dialect', str(SQLDialect)]
if where is not None:
new_options += ['-where', str(where)]
if accessMode is not None:
if accessMode == 'update':
new_options += ['-update']
elif accessMode == 'append':
new_options += ['-append']
elif accessMode == 'overwrite':
new_options += ['-overwrite']
elif accessMode == 'upsert':
new_options += ['-upsert']
else:
raise Exception('unhandled accessMode')
if addFields:
new_options += ['-addfields']
if forceNullable:
new_options += ['-forceNullable']
if emptyStrAsNull:
new_options += ['-emptyStrAsNull']
if selectFields is not None:
val = ''
for item in selectFields:
if val:
val += ','
val += item
new_options += ['-select', val]
if datasetCreationOptions is not None:
for opt in datasetCreationOptions:
new_options += ['-dsco', opt]
if layerCreationOptions is not None:
for opt in layerCreationOptions:
new_options += ['-lco', opt]
if layers is not None:
if isinstance(layers, str):
new_options += [layers]
else:
for lyr in layers:
new_options += [lyr]
if segmentizeMaxDist is not None:
new_options += ['-segmentize', str(segmentizeMaxDist)]
if makeValid:
new_options += ['-makevalid']
if spatFilter is not None:
new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
if spatSRS is not None:
new_options += ['-spat_srs', str(spatSRS)]
if layerName is not None:
new_options += ['-nln', layerName]
if geometryType is not None:
if isinstance(geometryType, str):
new_options += ['-nlt', geometryType]
else:
for opt in geometryType:
new_options += ['-nlt', opt]
if dim is not None:
new_options += ['-dim', dim]
if zField is not None:
new_options += ['-zfield', zField]
if resolveDomains:
new_options += ['-resolveDomains']
if skipFailures:
new_options += ['-skip']
if limit is not None:
new_options += ['-limit', str(limit)]
if callback is not None:
new_options += ['-progress']
return (GDALVectorTranslateOptions(new_options), callback, callback_data)
def VectorTranslate(destNameOrDestDS, srcDS, **kwargs):
"""Convert one vector dataset
Parameters
----------
destNameOrDestDS:
Output dataset name or object
srcDS:
a Dataset object or a filename
kwargs:
options: return of gdal.VectorTranslateOptions(), string or array of strings,
other keywords arguments of gdal.VectorTranslateOptions().
If options is provided as a gdal.VectorTranslateOptions() object,
other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = VectorTranslateOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
if isinstance(destNameOrDestDS, str):
return wrapper_GDALVectorTranslateDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
else:
return wrapper_GDALVectorTranslateDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
def DEMProcessingOptions(options=None, colorFilename=None, format=None,
creationOptions=None, computeEdges=False, alg=None, band=1,
zFactor=None, scale=None, azimuth=None, altitude=None,
combined=False, multiDirectional=False, igor=False,
slopeFormat=None, trigonometric=False, zeroForFlat=False,
addAlpha=None, colorSelection=None,
callback=None, callback_data=None):
"""Create a DEMProcessingOptions() object that can be passed to gdal.DEMProcessing()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
colorFilename:
(mandatory for "color-relief") name of file that contains palette definition for the "color-relief" processing.
format:
output format ("GTiff", etc...)
creationOptions:
list of creation options
computeEdges:
whether to compute values at raster edges.
alg:
'Horn' (default) or 'ZevenbergenThorne' for hillshade, slope or aspect. 'Wilson' (default) or 'Riley' for TRI
band:
source band number to use
zFactor:
(hillshade only) vertical exaggeration used to pre-multiply the elevations.
scale:
ratio of vertical units to horizontal.
azimuth:
(hillshade only) azimuth of the light, in degrees. 0 if it comes from the top of the raster, 90 from the east, ... The default value, 315, should rarely be changed as it is the value generally used to generate shaded maps.
altitude:
(hillshade only) altitude of the light, in degrees. 90 if the light comes from above the DEM, 0 if it is raking light.
combined:
(hillshade only) whether to compute combined shading, a combination of slope and oblique shading. Only one of combined, multiDirectional and igor can be specified.
multiDirectional:
(hillshade only) whether to compute multi-directional shading. Only one of combined, multiDirectional and igor can be specified.
igor:
(hillshade only) whether to use Igor's hillshading from Maperitive. Only one of combined, multiDirectional and igor can be specified.
slopeformat:
(slope only) "degree" or "percent".
trigonometric:
(aspect only) whether to return trigonometric angle instead of azimuth. Thus 0deg means East, 90deg North, 180deg West, 270deg South.
zeroForFlat:
(aspect only) whether to return 0 for flat areas with slope=0, instead of -9999.
addAlpha:
adds an alpha band to the output file (only for processing = 'color-relief')
colorSelection:
(color-relief only) Determines how color entries are selected from an input value. Can be "nearest_color_entry", "exact_color_entry" or "linear_interpolation". Defaults to "linear_interpolation"
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if computeEdges:
new_options += ['-compute_edges']
if alg:
new_options += ['-alg', alg]
new_options += ['-b', str(band)]
if zFactor is not None:
new_options += ['-z', str(zFactor)]
if scale is not None:
new_options += ['-s', str(scale)]
if azimuth is not None:
new_options += ['-az', str(azimuth)]
if altitude is not None:
new_options += ['-alt', str(altitude)]
if combined:
new_options += ['-combined']
if multiDirectional:
new_options += ['-multidirectional']
if igor:
new_options += ['-igor']
if slopeFormat == 'percent':
new_options += ['-p']
if trigonometric:
new_options += ['-trigonometric']
if zeroForFlat:
new_options += ['-zero_for_flat']
if colorSelection is not None:
if colorSelection == 'nearest_color_entry':
new_options += ['-nearest_color_entry']
elif colorSelection == 'exact_color_entry':
new_options += ['-exact_color_entry']
elif colorSelection == 'linear_interpolation':
pass
else:
raise ValueError("Unsupported value for colorSelection")
if addAlpha:
new_options += ['-alpha']
return (GDALDEMProcessingOptions(new_options), colorFilename, callback, callback_data)
def DEMProcessing(destName, srcDS, processing, **kwargs):
"""Apply a DEM processing.
Parameters
----------
destName:
Output dataset name
srcDS:
a Dataset object or a filename
processing:
one of "hillshade", "slope", "aspect", "color-relief", "TRI", "TPI", "Roughness"
kwargs:
options: return of gdal.DEMProcessingOptions(), string or array of strings,
other keywords arguments of gdal.DEMProcessingOptions().
If options is provided as a gdal.DEMProcessingOptions() object,
other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, colorFilename, callback, callback_data) = DEMProcessingOptions(**kwargs)
else:
(opts, colorFilename, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = Open(srcDS)
return DEMProcessingInternal(destName, srcDS, processing, colorFilename, opts, callback, callback_data)
def NearblackOptions(options=None, format=None,
creationOptions=None, white = False, colors=None,
maxNonBlack=None, nearDist=None, setAlpha = False, setMask = False,
callback=None, callback_data=None):
"""Create a NearblackOptions() object that can be passed to gdal.Nearblack()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
creationOptions:
list of creation options
white:
whether to search for nearly white (255) pixels instead of nearly black pixels.
colors:
list of colors to search for, e.g. ((0,0,0),(255,255,255)). The pixels that are considered as the collar are set to 0
maxNonBlack:
number of non-black (or other searched colors specified with white / colors) pixels that can be encountered before the giving up search inwards. Defaults to 2.
nearDist:
select how far from black, white or custom colors the pixel values can be and still considered near black, white or custom color. Defaults to 15.
setAlpha:
adds an alpha band to the output file.
setMask:
adds a mask band to the output file.
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if white:
new_options += ['-white']
if colors is not None:
for color in colors:
color_str = ''
for cpt in color:
if color_str != '':
color_str += ','
color_str += str(cpt)
new_options += ['-color', color_str]
if maxNonBlack is not None:
new_options += ['-nb', str(maxNonBlack)]
if nearDist is not None:
new_options += ['-near', str(nearDist)]
if setAlpha:
new_options += ['-setalpha']
if setMask:
new_options += ['-setmask']
return (GDALNearblackOptions(new_options), callback, callback_data)
def Nearblack(destNameOrDestDS, srcDS, **kwargs):
"""Convert nearly black/white borders to exact value.
Parameters
----------
destNameOrDestDS:
Output dataset name or object
srcDS:
a Dataset object or a filename
kwargs:
options: return of gdal.NearblackOptions(), string or array of strings,
other keywords arguments of gdal.NearblackOptions().
If options is provided as a gdal.NearblackOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = NearblackOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = OpenEx(srcDS)
if isinstance(destNameOrDestDS, str):
return wrapper_GDALNearblackDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
else:
return wrapper_GDALNearblackDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
def GridOptions(options=None, format=None,
outputType=gdalconst.GDT_Unknown,
width=0, height=0,
creationOptions=None,
outputBounds=None,
outputSRS=None,
noData=None,
algorithm=None,
layers=None,
SQLStatement=None,
where=None,
spatFilter=None,
zfield=None,
z_increase=None,
z_multiply=None,
callback=None, callback_data=None):
""" Create a GridOptions() object that can be passed to gdal.Grid()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
outputType:
output type (gdalconst.GDT_Byte, etc...)
width:
width of the output raster in pixel
height:
height of the output raster in pixel
creationOptions:
list of creation options
outputBounds:
assigned output bounds:
[ulx, uly, lrx, lry]
outputSRS:
assigned output SRS
noData:
nodata value
algorithm:
e.g "invdist:power=2.0:smoothing=0.0:radius1=0.0:radius2=0.0:angle=0.0:max_points=0:min_points=0:nodata=0.0"
layers:
list of layers to convert
SQLStatement:
SQL statement to apply to the source dataset
where:
WHERE clause to apply to source layer(s)
spatFilter:
spatial filter as (minX, minY, maxX, maxY) bounding box
zfield:
Identifies an attribute field on the features to be used to get a Z value from.
This value overrides Z value read from feature geometry record.
z_increase:
Addition to the attribute field on the features to be used to get a Z value from.
The addition should be the same unit as Z value. The result value will be
Z value + Z increase value. The default value is 0.
z_multiply:
Multiplication ratio for Z field. This can be used for shift from e.g. foot to meters
or from elevation to deep. The result value will be
(Z value + Z increase value) * Z multiply value. The default value is 1.
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
new_options += ['-ot', GetDataTypeName(outputType)]
if width != 0 or height != 0:
new_options += ['-outsize', str(width), str(height)]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if outputBounds is not None:
new_options += ['-txe', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[2]), '-tye', _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[3])]
if outputSRS is not None:
new_options += ['-a_srs', str(outputSRS)]
if algorithm is not None:
new_options += ['-a', algorithm]
if layers is not None:
if isinstance(layers, (tuple, list)):
for layer in layers:
new_options += ['-l', layer]
else:
new_options += ['-l', layers]
if SQLStatement is not None:
new_options += ['-sql', str(SQLStatement)]
if where is not None:
new_options += ['-where', str(where)]
if zfield is not None:
new_options += ['-zfield', zfield]
if z_increase is not None:
new_options += ['-z_increase', str(z_increase)]
if z_multiply is not None:
new_options += ['-z_multiply', str(z_multiply)]
if spatFilter is not None:
new_options += ['-spat', str(spatFilter[0]), str(spatFilter[1]), str(spatFilter[2]), str(spatFilter[3])]
return (GDALGridOptions(new_options), callback, callback_data)
def Grid(destName, srcDS, **kwargs):
""" Create raster from the scattered data.
Parameters
----------
destName:
Output dataset name
srcDS:
a Dataset object or a filename
kwargs:
options: return of gdal.GridOptions(), string or array of strings,
other keywords arguments of gdal.GridOptions()
If options is provided as a gdal.GridOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = GridOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
return GridInternal(destName, srcDS, opts, callback, callback_data)
def RasterizeOptions(options=None, format=None,
outputType=gdalconst.GDT_Unknown,
creationOptions=None, noData=None, initValues=None,
outputBounds=None, outputSRS=None,
transformerOptions=None,
width=None, height=None,
xRes=None, yRes=None, targetAlignedPixels=False,
bands=None, inverse=False, allTouched=False,
burnValues=None, attribute=None, useZ=False, layers=None,
SQLStatement=None, SQLDialect=None, where=None, optim=None,
add=None,
callback=None, callback_data=None):
"""Create a RasterizeOptions() object that can be passed to gdal.Rasterize()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
outputType:
output type (gdalconst.GDT_Byte, etc...)
creationOptions:
list of creation options
outputBounds:
assigned output bounds:
[minx, miny, maxx, maxy]
outputSRS:
assigned output SRS
transformerOptions:
list of transformer options
width:
width of the output raster in pixel
height:
height of the output raster in pixel
xRes, yRes:
output resolution in target SRS
targetAlignedPixels:
whether to force output bounds to be multiple of output resolution
noData:
nodata value
initValues:
Value or list of values to pre-initialize the output image bands with.
However, it is not marked as the nodata value in the output file.
If only one value is given, the same value is used in all the bands.
bands:
list of output bands to burn values into
inverse:
whether to invert rasterization, i.e. burn the fixed burn value, or the
burn value associated with the first feature into all parts of the image
not inside the provided a polygon.
allTouched:
whether to enable the ALL_TOUCHED rasterization option so that all pixels
touched by lines or polygons will be updated, not just those on the line
render path, or whose center point is within the polygon.
burnValues:
list of fixed values to burn into each band for all objects.
Excusive with attribute.
attribute:
identifies an attribute field on the features to be used for a burn-in value.
The value will be burned into all output bands. Excusive with burnValues.
useZ:
whether to indicate that a burn value should be extracted from the "Z" values
of the feature. These values are added to the burn value given by burnValues
or attribute if provided. As of now, only points and lines are drawn in 3D.
layers:
list of layers from the datasource that will be used for input features.
SQLStatement:
SQL statement to apply to the source dataset
SQLDialect:
SQL dialect ('OGRSQL', 'SQLITE', ...)
where:
WHERE clause to apply to source layer(s)
optim:
optimization mode ('RASTER', 'VECTOR')
add:
set to True to use additive mode instead of replace when burning values
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if outputType != gdalconst.GDT_Unknown:
new_options += ['-ot', GetDataTypeName(outputType)]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if bands is not None:
for b in bands:
new_options += ['-b', str(b)]
if noData is not None:
new_options += ['-a_nodata', str(noData)]
if initValues is not None:
if isinstance(initValues, (tuple, list)):
for val in initValues:
new_options += ['-init', str(val)]
else:
new_options += ['-init', str(initValues)]
if outputBounds is not None:
new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
if outputSRS is not None:
new_options += ['-a_srs', str(outputSRS)]
if transformerOptions is not None:
for opt in transformerOptions:
new_options += ['-to', opt]
if width is not None and height is not None:
new_options += ['-ts', str(width), str(height)]
if xRes is not None and yRes is not None:
new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
if targetAlignedPixels:
new_options += ['-tap']
if inverse:
new_options += ['-i']
if allTouched:
new_options += ['-at']
if burnValues is not None:
if attribute is not None:
raise Exception('burnValues and attribute option are exclusive.')
if isinstance(burnValues, (tuple, list)):
for val in burnValues:
new_options += ['-burn', str(val)]
else:
new_options += ['-burn', str(burnValues)]
if attribute is not None:
new_options += ['-a', attribute]
if useZ:
new_options += ['-3d']
if layers is not None:
if isinstance(layers, ((tuple, list))):
for layer in layers:
new_options += ['-l', layer]
else:
new_options += ['-l', layers]
if SQLStatement is not None:
new_options += ['-sql', str(SQLStatement)]
if SQLDialect is not None:
new_options += ['-dialect', str(SQLDialect)]
if where is not None:
new_options += ['-where', str(where)]
if optim is not None:
new_options += ['-optim', str(optim)]
if add:
new_options += ['-add']
return (GDALRasterizeOptions(new_options), callback, callback_data)
def Rasterize(destNameOrDestDS, srcDS, **kwargs):
"""Burns vector geometries into a raster
Parameters
----------
destNameOrDestDS:
Output dataset name or object
srcDS:
a Dataset object or a filename
kwargs:
options: return of gdal.RasterizeOptions(), string or array of strings,
other keywords arguments of gdal.RasterizeOptions()
If options is provided as a gdal.RasterizeOptions() object, other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = RasterizeOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDS, str):
srcDS = OpenEx(srcDS, gdalconst.OF_VECTOR)
if isinstance(destNameOrDestDS, str):
return wrapper_GDALRasterizeDestName(destNameOrDestDS, srcDS, opts, callback, callback_data)
else:
return wrapper_GDALRasterizeDestDS(destNameOrDestDS, srcDS, opts, callback, callback_data)
def BuildVRTOptions(options=None,
resolution=None,
outputBounds=None,
xRes=None,
yRes=None,
targetAlignedPixels=None,
separate=None,
bandList=None,
addAlpha=None,
resampleAlg=None,
outputSRS=None,
allowProjectionDifference=None,
srcNodata=None,
VRTNodata=None,
hideNodata=None,
strict=False,
callback=None, callback_data=None):
"""Create a BuildVRTOptions() object that can be passed to gdal.BuildVRT()
Parameters
----------
options:l
can be be an array of strings, a string or let empty and filled from other keywords.
resolution:
'highest', 'lowest', 'average', 'user'.
outputBounds:l
output bounds as (minX, minY, maxX, maxY) in target SRS.
xRes:
output resolution in target SRS.
yRes:
output resolution in target SRS.
targetAlignedPixels:
whether to force output bounds to be multiple of output resolution.
separate:
whether each source file goes into a separate stacked band in the VRT band.
bandList:
array of band numbers (index start at 1).
addAlpha:
whether to add an alpha mask band to the VRT when the source raster have none.
resampleAlg:
resampling mode.
outputSRS:
assigned output SRS.
allowProjectionDifference:
whether to accept input datasets have not the same projection.
Note: they will *not* be reprojected.
srcNodata:
source nodata value(s).
VRTNodata:
nodata values at the VRT band level.
hideNodata:
whether to make the VRT band not report the NoData value.
strict:
set to True if warnings should be failures
callback:
callback method.
callback_data:
user data for callback.
"""
# Only used for tests
return_option_list = options == '__RETURN_OPTION_LIST__'
if return_option_list:
options = []
else:
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if resolution is not None:
new_options += ['-resolution', str(resolution)]
if outputBounds is not None:
new_options += ['-te', _strHighPrec(outputBounds[0]), _strHighPrec(outputBounds[1]), _strHighPrec(outputBounds[2]), _strHighPrec(outputBounds[3])]
if xRes is not None and yRes is not None:
new_options += ['-tr', _strHighPrec(xRes), _strHighPrec(yRes)]
if targetAlignedPixels:
new_options += ['-tap']
if separate:
new_options += ['-separate']
if bandList != None:
for b in bandList:
new_options += ['-b', str(b)]
if addAlpha:
new_options += ['-addalpha']
if resampleAlg is not None:
if resampleAlg in mapGRIORAMethodToString:
new_options += ['-r', mapGRIORAMethodToString[resampleAlg]]
else:
new_options += ['-r', str(resampleAlg)]
if outputSRS is not None:
new_options += ['-a_srs', str(outputSRS)]
if allowProjectionDifference:
new_options += ['-allow_projection_difference']
if srcNodata is not None:
new_options += ['-srcnodata', str(srcNodata)]
if VRTNodata is not None:
new_options += ['-vrtnodata', str(VRTNodata)]
if hideNodata:
new_options += ['-hidenodata']
if strict:
new_options += ['-strict']
if return_option_list:
return new_options
return (GDALBuildVRTOptions(new_options), callback, callback_data)
def BuildVRT(destName, srcDSOrSrcDSTab, **kwargs):
"""Build a VRT from a list of datasets.
Parameters
----------
destName:
Output dataset name.
srcDSOrSrcDSTab:
An array of Dataset objects or filenames, or a Dataset object or a filename.
kwargs:
options: return of gdal.BuildVRTOptions(), string or array of strings,
other keywords arguments of gdal.BuildVRTOptions().
If options is provided as a gdal.BuildVRTOptions() object,
other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = BuildVRTOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
srcDSTab = []
srcDSNamesTab = []
if isinstance(srcDSOrSrcDSTab, str):
srcDSNamesTab = [srcDSOrSrcDSTab]
elif isinstance(srcDSOrSrcDSTab, list):
for elt in srcDSOrSrcDSTab:
if isinstance(elt, str):
srcDSNamesTab.append(elt)
else:
srcDSTab.append(elt)
if srcDSTab and srcDSNamesTab:
raise Exception('Mix of names and dataset objects not supported')
else:
srcDSTab = [srcDSOrSrcDSTab]
if srcDSTab:
return BuildVRTInternalObjects(destName, srcDSTab, opts, callback, callback_data)
else:
return BuildVRTInternalNames(destName, srcDSNamesTab, opts, callback, callback_data)
def MultiDimTranslateOptions(options=None, format=None, creationOptions=None,
arraySpecs=None, groupSpecs=None, subsetSpecs=None, scaleAxesSpecs=None,
callback=None, callback_data=None):
"""Create a MultiDimTranslateOptions() object that can be passed to gdal.MultiDimTranslate()
Parameters
----------
options:
can be be an array of strings, a string or let empty and filled from other keywords.
format:
output format ("GTiff", etc...)
creationOptions:
list of creation options
arraySpecs:
list of array specifications, each of them being an array name or
"name={src_array_name},dstname={dst_name},transpose=[1,0],view=[:,::-1]"
groupSpecs:
list of group specifications, each of them being a group name or
"name={src_array_name},dstname={dst_name},recursive=no"
subsetSpecs:
list of subset specifications, each of them being like
"{dim_name}({min_val},{max_val})" or "{dim_name}({slice_va})"
scaleAxesSpecs:
list of dimension scaling specifications, each of them being like
"{dim_name}({scale_factor})"
callback:
callback method
callback_data:
user data for callback
"""
options = [] if options is None else options
if isinstance(options, str):
new_options = ParseCommandLine(options)
else:
new_options = options
if format is not None:
new_options += ['-of', format]
if creationOptions is not None:
for opt in creationOptions:
new_options += ['-co', opt]
if arraySpecs is not None:
for s in arraySpecs:
new_options += ['-array', s]
if groupSpecs is not None:
for s in groupSpecs:
new_options += ['-group', s]
if subsetSpecs is not None:
for s in subsetSpecs:
new_options += ['-subset', s]
if scaleAxesSpecs is not None:
for s in scaleAxesSpecs:
new_options += ['-scaleaxes', s]
return (GDALMultiDimTranslateOptions(new_options), callback, callback_data)
def MultiDimTranslate(destName, srcDSOrSrcDSTab, **kwargs):
"""MultiDimTranslate one or several datasets.
Parameters
----------
destName:
Output dataset name
srcDSOrSrcDSTab:
an array of Dataset objects or filenames, or a Dataset object or a filename
kwargs:
options: return of gdal.MultiDimTranslateOptions(), string or array of strings
other keywords arguments of gdal.MultiDimTranslateOptions().
If options is provided as a gdal.MultiDimTranslateOptions() object,
other keywords are ignored.
"""
if 'options' not in kwargs or isinstance(kwargs['options'], (list, str)):
(opts, callback, callback_data) = MultiDimTranslateOptions(**kwargs)
else:
(opts, callback, callback_data) = kwargs['options']
if isinstance(srcDSOrSrcDSTab, str):
srcDSTab = [OpenEx(srcDSOrSrcDSTab, OF_VERBOSE_ERROR | OF_RASTER | OF_MULTIDIM_RASTER)]
elif isinstance(srcDSOrSrcDSTab, list):
srcDSTab = []
for elt in srcDSOrSrcDSTab:
if isinstance(elt, str):
srcDSTab.append(OpenEx(elt, OF_VERBOSE_ERROR | OF_RASTER | OF_MULTIDIM_RASTER))
else:
srcDSTab.append(elt)
else:
srcDSTab = [srcDSOrSrcDSTab]
return wrapper_GDALMultiDimTranslateDestName(destName, srcDSTab, opts, callback, callback_data)
# Logging Helpers
def _pylog_handler(err_level, err_no, err_msg):
if err_no != gdalconst.CPLE_None:
typ = _pylog_handler.errcode_map.get(err_no, str(err_no))
message = "%s: %s" % (typ, err_msg)
else:
message = err_msg
level = _pylog_handler.level_map.get(err_level, 20) # default level is INFO
_pylog_handler.logger.log(level, message)
def ConfigurePythonLogging(logger_name='gdal', enable_debug=False):
""" Configure GDAL to use Python's logging framework """
import logging
_pylog_handler.logger = logging.getLogger(logger_name)
# map CPLE_* constants to names
_pylog_handler.errcode_map = {_num: _name[5:] for _name, _num in gdalconst.__dict__.items() if _name.startswith('CPLE_')}
# Map GDAL log levels to Python's
_pylog_handler.level_map = {
CE_None: logging.INFO,
CE_Debug: logging.DEBUG,
CE_Warning: logging.WARN,
CE_Failure: logging.ERROR,
CE_Fatal: logging.CRITICAL,
}
# Set CPL_DEBUG so debug messages are passed through the logger
if enable_debug:
SetConfigOption("CPL_DEBUG", "ON")
# Install as the default GDAL log handler
SetErrorHandler(_pylog_handler)
def EscapeString(*args, **kwargs):
"""EscapeString(string_or_bytes, scheme = gdal.CPLES_SQL)"""
if isinstance(args[0], bytes):
return _gdal.EscapeBinary(*args, **kwargs)
else:
return _gdal.wrapper_EscapeString(*args, **kwargs)
def ApplyVerticalShiftGrid(*args, **kwargs):
"""ApplyVerticalShiftGrid(Dataset src_ds, Dataset grid_ds, bool inverse=False, double srcUnitToMeter=1.0, double dstUnitToMeter=1.0, char ** options=None) -> Dataset"""
from warnings import warn
warn('ApplyVerticalShiftGrid() will be removed in GDAL 4.0', DeprecationWarning)
return _ApplyVerticalShiftGrid(*args, **kwargs)
def Debug(*args) -> "void":
r"""Debug(char const * msg_class, char const * message)"""
return _gdal.Debug(*args)
def SetErrorHandler(*args) -> "CPLErr":
r"""SetErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
return _gdal.SetErrorHandler(*args)
def SetCurrentErrorHandlerCatchDebug(*args) -> "void":
r"""SetCurrentErrorHandlerCatchDebug(int bCatchDebug)"""
return _gdal.SetCurrentErrorHandlerCatchDebug(*args)
def PushErrorHandler(*args) -> "CPLErr":
r"""PushErrorHandler(CPLErrorHandler pfnErrorHandler=0) -> CPLErr"""
return _gdal.PushErrorHandler(*args)
def PopErrorHandler(*args) -> "void":
r"""PopErrorHandler()"""
return _gdal.PopErrorHandler(*args)
def Error(*args) -> "void":
r"""Error(CPLErr msg_class=CE_Failure, int err_code=0, char const * msg="error")"""
return _gdal.Error(*args)
def GOA2GetAuthorizationURL(*args) -> "retStringAndCPLFree *":
r"""GOA2GetAuthorizationURL(char const * pszScope) -> retStringAndCPLFree *"""
return _gdal.GOA2GetAuthorizationURL(*args)
def GOA2GetRefreshToken(*args) -> "retStringAndCPLFree *":
r"""GOA2GetRefreshToken(char const * pszAuthToken, char const * pszScope) -> retStringAndCPLFree *"""
return _gdal.GOA2GetRefreshToken(*args)
def GOA2GetAccessToken(*args) -> "retStringAndCPLFree *":
r"""GOA2GetAccessToken(char const * pszRefreshToken, char const * pszScope) -> retStringAndCPLFree *"""
return _gdal.GOA2GetAccessToken(*args)
def ErrorReset(*args) -> "void":
r"""ErrorReset()"""
return _gdal.ErrorReset(*args)
def wrapper_EscapeString(*args, **kwargs) -> "retStringAndCPLFree *":
r"""wrapper_EscapeString(int len, int scheme=CPLES_SQL) -> retStringAndCPLFree *"""
return _gdal.wrapper_EscapeString(*args, **kwargs)
def EscapeBinary(*args, **kwargs) -> "char **":
r"""EscapeBinary(int len, int scheme=CPLES_SQL)"""
return _gdal.EscapeBinary(*args, **kwargs)
def GetLastErrorNo(*args) -> "int":
r"""GetLastErrorNo() -> int"""
return _gdal.GetLastErrorNo(*args)
def GetLastErrorType(*args) -> "int":
r"""GetLastErrorType() -> int"""
return _gdal.GetLastErrorType(*args)
def GetLastErrorMsg(*args) -> "char const *":
r"""GetLastErrorMsg() -> char const *"""
return _gdal.GetLastErrorMsg(*args)
def GetErrorCounter(*args) -> "unsigned int":
r"""GetErrorCounter() -> unsigned int"""
return _gdal.GetErrorCounter(*args)
def VSIGetLastErrorNo(*args) -> "int":
r"""VSIGetLastErrorNo() -> int"""
return _gdal.VSIGetLastErrorNo(*args)
def VSIGetLastErrorMsg(*args) -> "char const *":
r"""VSIGetLastErrorMsg() -> char const *"""
return _gdal.VSIGetLastErrorMsg(*args)
def VSIErrorReset(*args) -> "void":
r"""VSIErrorReset()"""
return _gdal.VSIErrorReset(*args)
def PushFinderLocation(*args) -> "void":
r"""PushFinderLocation(char const * utf8_path)"""
return _gdal.PushFinderLocation(*args)
def PopFinderLocation(*args) -> "void":
r"""PopFinderLocation()"""
return _gdal.PopFinderLocation(*args)
def FinderClean(*args) -> "void":
r"""FinderClean()"""
return _gdal.FinderClean(*args)
def FindFile(*args) -> "char const *":
r"""FindFile(char const * pszClass, char const * utf8_path) -> char const *"""
return _gdal.FindFile(*args)
def ReadDir(*args) -> "char **":
r"""ReadDir(char const * utf8_path, int nMaxFiles=0) -> char **"""
return _gdal.ReadDir(*args)
def ReadDirRecursive(*args) -> "char **":
r"""ReadDirRecursive(char const * utf8_path) -> char **"""
return _gdal.ReadDirRecursive(*args)
def OpenDir(*args) -> "VSIDIR *":
r"""OpenDir(char const * utf8_path, int nRecurseDepth=-1, char ** options=None) -> VSIDIR *"""
return _gdal.OpenDir(*args)
class DirEntry(object):
r"""Proxy of C++ DirEntry class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
name = property(_gdal.DirEntry_name_get, doc=r"""name : p.char""")
mode = property(_gdal.DirEntry_mode_get, doc=r"""mode : int""")
size = property(_gdal.DirEntry_size_get, doc=r"""size : GIntBig""")
mtime = property(_gdal.DirEntry_mtime_get, doc=r"""mtime : GIntBig""")
modeKnown = property(_gdal.DirEntry_modeKnown_get, doc=r"""modeKnown : bool""")
sizeKnown = property(_gdal.DirEntry_sizeKnown_get, doc=r"""sizeKnown : bool""")
mtimeKnown = property(_gdal.DirEntry_mtimeKnown_get, doc=r"""mtimeKnown : bool""")
extra = property(_gdal.DirEntry_extra_get, doc=r"""extra : p.p.char""")
def __init__(self, *args):
r"""__init__(DirEntry self, DirEntry entryIn) -> DirEntry"""
_gdal.DirEntry_swiginit(self, _gdal.new_DirEntry(*args))
__swig_destroy__ = _gdal.delete_DirEntry
def IsDirectory(self, *args) -> "bool":
r"""IsDirectory(DirEntry self) -> bool"""
return _gdal.DirEntry_IsDirectory(self, *args)
# Register DirEntry in _gdal:
_gdal.DirEntry_swigregister(DirEntry)
def GetNextDirEntry(*args) -> "DirEntry *":
r"""GetNextDirEntry(VSIDIR * dir) -> DirEntry"""
return _gdal.GetNextDirEntry(*args)
def CloseDir(*args) -> "void":
r"""CloseDir(VSIDIR * dir)"""
return _gdal.CloseDir(*args)
def SetConfigOption(*args) -> "void":
r"""SetConfigOption(char const * pszKey, char const * pszValue)"""
return _gdal.SetConfigOption(*args)
def SetThreadLocalConfigOption(*args) -> "void":
r"""SetThreadLocalConfigOption(char const * pszKey, char const * pszValue)"""
return _gdal.SetThreadLocalConfigOption(*args)
def GetConfigOption(*args) -> "char const *":
r"""GetConfigOption(char const * pszKey, char const * pszDefault=None) -> char const *"""
return _gdal.GetConfigOption(*args)
def GetThreadLocalConfigOption(*args) -> "char const *":
r"""GetThreadLocalConfigOption(char const * pszKey, char const * pszDefault=None) -> char const *"""
return _gdal.GetThreadLocalConfigOption(*args)
def SetPathSpecificOption(*args) -> "void":
r"""SetPathSpecificOption(char const * pszPathPrefix, char const * pszKey, char const * pszValue)"""
return _gdal.SetPathSpecificOption(*args)
def SetCredential(*args) -> "void":
r"""SetCredential(char const * pszPathPrefix, char const * pszKey, char const * pszValue)"""
return _gdal.SetCredential(*args)
def GetCredential(*args) -> "char const *":
r"""GetCredential(char const * pszPathPrefix, char const * pszKey, char const * pszDefault=None) -> char const *"""
return _gdal.GetCredential(*args)
def GetPathSpecificOption(*args) -> "char const *":
r"""GetPathSpecificOption(char const * pszPathPrefix, char const * pszKey, char const * pszDefault=None) -> char const *"""
return _gdal.GetPathSpecificOption(*args)
def ClearCredentials(*args) -> "void":
r"""ClearCredentials(char const * pszPathPrefix=None)"""
return _gdal.ClearCredentials(*args)
def ClearPathSpecificOptions(*args) -> "void":
r"""ClearPathSpecificOptions(char const * pszPathPrefix=None)"""
return _gdal.ClearPathSpecificOptions(*args)
def CPLBinaryToHex(*args) -> "retStringAndCPLFree *":
r"""CPLBinaryToHex(int nBytes) -> retStringAndCPLFree *"""
return _gdal.CPLBinaryToHex(*args)
def CPLHexToBinary(*args) -> "GByte *":
r"""CPLHexToBinary(char const * pszHex, int * pnBytes) -> GByte *"""
return _gdal.CPLHexToBinary(*args)
def FileFromMemBuffer(*args) -> "void":
r"""FileFromMemBuffer(char const * utf8_path, GIntBig nBytes)"""
return _gdal.FileFromMemBuffer(*args)
def Unlink(*args) -> "VSI_RETVAL":
r"""Unlink(char const * utf8_path) -> VSI_RETVAL"""
return _gdal.Unlink(*args)
def UnlinkBatch(*args) -> "bool":
r"""UnlinkBatch(char ** files) -> bool"""
return _gdal.UnlinkBatch(*args)
def HasThreadSupport(*args) -> "int":
r"""HasThreadSupport() -> int"""
return _gdal.HasThreadSupport(*args)
def Mkdir(*args) -> "VSI_RETVAL":
r"""Mkdir(char const * utf8_path, int mode) -> VSI_RETVAL"""
return _gdal.Mkdir(*args)
def Rmdir(*args) -> "VSI_RETVAL":
r"""Rmdir(char const * utf8_path) -> VSI_RETVAL"""
return _gdal.Rmdir(*args)
def MkdirRecursive(*args) -> "VSI_RETVAL":
r"""MkdirRecursive(char const * utf8_path, int mode) -> VSI_RETVAL"""
return _gdal.MkdirRecursive(*args)
def RmdirRecursive(*args) -> "VSI_RETVAL":
r"""RmdirRecursive(char const * utf8_path) -> VSI_RETVAL"""
return _gdal.RmdirRecursive(*args)
def Rename(*args) -> "VSI_RETVAL":
r"""Rename(char const * pszOld, char const * pszNew) -> VSI_RETVAL"""
return _gdal.Rename(*args)
def Sync(*args, **kwargs) -> "bool":
r"""Sync(char const * pszSource, char const * pszTarget, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> bool"""
return _gdal.Sync(*args, **kwargs)
def AbortPendingUploads(*args) -> "bool":
r"""AbortPendingUploads(char const * utf8_path) -> bool"""
return _gdal.AbortPendingUploads(*args)
def GetActualURL(*args) -> "char const *":
r"""GetActualURL(char const * utf8_path) -> char const *"""
return _gdal.GetActualURL(*args)
def GetSignedURL(*args) -> "retStringAndCPLFree *":
r"""GetSignedURL(char const * utf8_path, char ** options=None) -> retStringAndCPLFree *"""
return _gdal.GetSignedURL(*args)
def GetFileSystemsPrefixes(*args) -> "char **":
r"""GetFileSystemsPrefixes() -> char **"""
return _gdal.GetFileSystemsPrefixes(*args)
def GetFileSystemOptions(*args) -> "char const *":
r"""GetFileSystemOptions(char const * utf8_path) -> char const *"""
return _gdal.GetFileSystemOptions(*args)
class VSILFILE(object):
r"""Proxy of C++ VSILFILE class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
# Register VSILFILE in _gdal:
_gdal.VSILFILE_swigregister(VSILFILE)
VSI_STAT_EXISTS_FLAG = _gdal.VSI_STAT_EXISTS_FLAG
VSI_STAT_NATURE_FLAG = _gdal.VSI_STAT_NATURE_FLAG
VSI_STAT_SIZE_FLAG = _gdal.VSI_STAT_SIZE_FLAG
VSI_STAT_SET_ERROR_FLAG = _gdal.VSI_STAT_SET_ERROR_FLAG
VSI_STAT_CACHE_ONLY = _gdal.VSI_STAT_CACHE_ONLY
class StatBuf(object):
r"""Proxy of C++ StatBuf class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
mode = property(_gdal.StatBuf_mode_get, doc=r"""mode : int""")
size = property(_gdal.StatBuf_size_get, doc=r"""size : GIntBig""")
mtime = property(_gdal.StatBuf_mtime_get, doc=r"""mtime : GIntBig""")
def __init__(self, *args):
r"""__init__(StatBuf self, StatBuf psStatBuf) -> StatBuf"""
_gdal.StatBuf_swiginit(self, _gdal.new_StatBuf(*args))
__swig_destroy__ = _gdal.delete_StatBuf
def IsDirectory(self, *args) -> "int":
r"""IsDirectory(StatBuf self) -> int"""
return _gdal.StatBuf_IsDirectory(self, *args)
# Register StatBuf in _gdal:
_gdal.StatBuf_swigregister(StatBuf)
def VSIStatL(*args) -> "StatBuf *":
r"""VSIStatL(char const * utf8_path, int nFlags=0) -> int"""
return _gdal.VSIStatL(*args)
def GetFileMetadata(*args) -> "char **":
r"""GetFileMetadata(char const * utf8_path, char const * domain, char ** options=None) -> char **"""
return _gdal.GetFileMetadata(*args)
def SetFileMetadata(*args) -> "bool":
r"""SetFileMetadata(char const * utf8_path, char ** metadata, char const * domain, char ** options=None) -> bool"""
return _gdal.SetFileMetadata(*args)
def VSIFOpenL(*args) -> "VSILFILE *":
r"""VSIFOpenL(char const * utf8_path, char const * pszMode) -> VSILFILE"""
return _gdal.VSIFOpenL(*args)
def VSIFOpenExL(*args) -> "VSILFILE *":
r"""VSIFOpenExL(char const * utf8_path, char const * pszMode, int bSetError=FALSE, char ** options=None) -> VSILFILE"""
return _gdal.VSIFOpenExL(*args)
def VSIFEofL(*args) -> "int":
r"""VSIFEofL(VSILFILE fp) -> int"""
return _gdal.VSIFEofL(*args)
def VSIFFlushL(*args) -> "int":
r"""VSIFFlushL(VSILFILE fp) -> int"""
return _gdal.VSIFFlushL(*args)
def VSIFCloseL(*args) -> "VSI_RETVAL":
r"""VSIFCloseL(VSILFILE fp) -> VSI_RETVAL"""
return _gdal.VSIFCloseL(*args)
def VSIFSeekL(*args) -> "int":
r"""VSIFSeekL(VSILFILE fp, GIntBig offset, int whence) -> int"""
return _gdal.VSIFSeekL(*args)
def VSIFTellL(*args) -> "GIntBig":
r"""VSIFTellL(VSILFILE fp) -> GIntBig"""
return _gdal.VSIFTellL(*args)
def VSIFTruncateL(*args) -> "int":
r"""VSIFTruncateL(VSILFILE fp, GIntBig length) -> int"""
return _gdal.VSIFTruncateL(*args)
def VSISupportsSparseFiles(*args) -> "int":
r"""VSISupportsSparseFiles(char const * utf8_path) -> int"""
return _gdal.VSISupportsSparseFiles(*args)
VSI_RANGE_STATUS_UNKNOWN = _gdal.VSI_RANGE_STATUS_UNKNOWN
VSI_RANGE_STATUS_DATA = _gdal.VSI_RANGE_STATUS_DATA
VSI_RANGE_STATUS_HOLE = _gdal.VSI_RANGE_STATUS_HOLE
def VSIFGetRangeStatusL(*args) -> "int":
r"""VSIFGetRangeStatusL(VSILFILE fp, GIntBig offset, GIntBig length) -> int"""
return _gdal.VSIFGetRangeStatusL(*args)
def VSIFWriteL(*args) -> "int":
r"""VSIFWriteL(int nLen, int size, int memb, VSILFILE fp) -> int"""
return _gdal.VSIFWriteL(*args)
def VSICurlClearCache(*args) -> "void":
r"""VSICurlClearCache()"""
return _gdal.VSICurlClearCache(*args)
def VSICurlPartialClearCache(*args) -> "void":
r"""VSICurlPartialClearCache(char const * utf8_path)"""
return _gdal.VSICurlPartialClearCache(*args)
def NetworkStatsReset(*args) -> "void":
r"""NetworkStatsReset()"""
return _gdal.NetworkStatsReset(*args)
def NetworkStatsGetAsSerializedJSON(*args) -> "retStringAndCPLFree *":
r"""NetworkStatsGetAsSerializedJSON(char ** options=None) -> retStringAndCPLFree *"""
return _gdal.NetworkStatsGetAsSerializedJSON(*args)
def ParseCommandLine(*args) -> "char **":
r"""ParseCommandLine(char const * utf8_path) -> char **"""
return _gdal.ParseCommandLine(*args)
def GetNumCPUs(*args) -> "int":
r"""GetNumCPUs() -> int"""
return _gdal.GetNumCPUs(*args)
def GetUsablePhysicalRAM(*args) -> "GIntBig":
r"""GetUsablePhysicalRAM() -> GIntBig"""
return _gdal.GetUsablePhysicalRAM(*args)
class MajorObject(object):
r"""Proxy of C++ GDALMajorObjectShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
def GetDescription(self, *args) -> "char const *":
r"""GetDescription(MajorObject self) -> char const *"""
return _gdal.MajorObject_GetDescription(self, *args)
def SetDescription(self, *args) -> "void":
r"""SetDescription(MajorObject self, char const * pszNewDesc)"""
return _gdal.MajorObject_SetDescription(self, *args)
def GetMetadataDomainList(self, *args) -> "char **":
r"""GetMetadataDomainList(MajorObject self) -> char **"""
return _gdal.MajorObject_GetMetadataDomainList(self, *args)
def GetMetadata_Dict(self, *args) -> "char **":
r"""GetMetadata_Dict(MajorObject self, char const * pszDomain="") -> char **"""
return _gdal.MajorObject_GetMetadata_Dict(self, *args)
def GetMetadata_List(self, *args) -> "char **":
r"""GetMetadata_List(MajorObject self, char const * pszDomain="") -> char **"""
return _gdal.MajorObject_GetMetadata_List(self, *args)
def SetMetadata(self, *args) -> "CPLErr":
r"""
SetMetadata(MajorObject self, char ** papszMetadata, char const * pszDomain="") -> CPLErr
SetMetadata(MajorObject self, char * pszMetadataString, char const * pszDomain="") -> CPLErr
"""
return _gdal.MajorObject_SetMetadata(self, *args)
def GetMetadataItem(self, *args) -> "char const *":
r"""GetMetadataItem(MajorObject self, char const * pszName, char const * pszDomain="") -> char const *"""
return _gdal.MajorObject_GetMetadataItem(self, *args)
def SetMetadataItem(self, *args) -> "CPLErr":
r"""SetMetadataItem(MajorObject self, char const * pszName, char const * pszValue, char const * pszDomain="") -> CPLErr"""
return _gdal.MajorObject_SetMetadataItem(self, *args)
def GetMetadata(self, domain=''):
if domain and domain[:4] == 'xml:':
return self.GetMetadata_List(domain)
return self.GetMetadata_Dict(domain)
# Register MajorObject in _gdal:
_gdal.MajorObject_swigregister(MajorObject)
class Driver(MajorObject):
r"""Proxy of C++ GDALDriverShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
ShortName = property(_gdal.Driver_ShortName_get, doc=r"""ShortName : p.q(const).char""")
LongName = property(_gdal.Driver_LongName_get, doc=r"""LongName : p.q(const).char""")
HelpTopic = property(_gdal.Driver_HelpTopic_get, doc=r"""HelpTopic : p.q(const).char""")
def Create(self, *args, **kwargs) -> "GDALDatasetShadow *":
r"""Create(Driver self, char const * utf8_path, int xsize, int ysize, int bands=1, GDALDataType eType=GDT_Byte, char ** options=None) -> Dataset"""
return _gdal.Driver_Create(self, *args, **kwargs)
def CreateMultiDimensional(self, *args, **kwargs) -> "GDALDatasetShadow *":
r"""CreateMultiDimensional(Driver self, char const * utf8_path, char ** root_group_options=None, char ** options=None) -> Dataset"""
return _gdal.Driver_CreateMultiDimensional(self, *args, **kwargs)
def CreateCopy(self, *args, **kwargs) -> "GDALDatasetShadow *":
r"""CreateCopy(Driver self, char const * utf8_path, Dataset src, int strict=1, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.Driver_CreateCopy(self, *args, **kwargs)
def Delete(self, *args) -> "CPLErr":
r"""Delete(Driver self, char const * utf8_path) -> CPLErr"""
return _gdal.Driver_Delete(self, *args)
def Rename(self, *args) -> "CPLErr":
r"""Rename(Driver self, char const * newName, char const * oldName) -> CPLErr"""
return _gdal.Driver_Rename(self, *args)
def CopyFiles(self, *args) -> "CPLErr":
r"""CopyFiles(Driver self, char const * newName, char const * oldName) -> CPLErr"""
return _gdal.Driver_CopyFiles(self, *args)
def Register(self, *args) -> "int":
r"""Register(Driver self) -> int"""
return _gdal.Driver_Register(self, *args)
def Deregister(self, *args) -> "void":
r"""Deregister(Driver self)"""
return _gdal.Driver_Deregister(self, *args)
# Register Driver in _gdal:
_gdal.Driver_swigregister(Driver)
from . import ogr
from . import osr
class ColorEntry(object):
r"""Proxy of C++ GDALColorEntry class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
c1 = property(_gdal.ColorEntry_c1_get, _gdal.ColorEntry_c1_set, doc=r"""c1 : short""")
c2 = property(_gdal.ColorEntry_c2_get, _gdal.ColorEntry_c2_set, doc=r"""c2 : short""")
c3 = property(_gdal.ColorEntry_c3_get, _gdal.ColorEntry_c3_set, doc=r"""c3 : short""")
c4 = property(_gdal.ColorEntry_c4_get, _gdal.ColorEntry_c4_set, doc=r"""c4 : short""")
# Register ColorEntry in _gdal:
_gdal.ColorEntry_swigregister(ColorEntry)
class GCP(object):
r"""Proxy of C++ GDAL_GCP class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
GCPX = property(_gdal.GCP_GCPX_get, _gdal.GCP_GCPX_set, doc=r"""GCPX : double""")
GCPY = property(_gdal.GCP_GCPY_get, _gdal.GCP_GCPY_set, doc=r"""GCPY : double""")
GCPZ = property(_gdal.GCP_GCPZ_get, _gdal.GCP_GCPZ_set, doc=r"""GCPZ : double""")
GCPPixel = property(_gdal.GCP_GCPPixel_get, _gdal.GCP_GCPPixel_set, doc=r"""GCPPixel : double""")
GCPLine = property(_gdal.GCP_GCPLine_get, _gdal.GCP_GCPLine_set, doc=r"""GCPLine : double""")
Info = property(_gdal.GCP_Info_get, _gdal.GCP_Info_set, doc=r"""Info : p.char""")
Id = property(_gdal.GCP_Id_get, _gdal.GCP_Id_set, doc=r"""Id : p.char""")
def __init__(self, *args):
r"""__init__(GCP self, double x=0.0, double y=0.0, double z=0.0, double pixel=0.0, double line=0.0, char const * info="", char const * id="") -> GCP"""
_gdal.GCP_swiginit(self, _gdal.new_GCP(*args))
__swig_destroy__ = _gdal.delete_GCP
def __str__(self):
str = '%s (%.2fP,%.2fL) -> (%.7fE,%.7fN,%.2f) %s '\
% (self.Id, self.GCPPixel, self.GCPLine,
self.GCPX, self.GCPY, self.GCPZ, self.Info )
return str
def serialize(self, with_Z=0):
base = [gdalconst.CXT_Element, 'GCP']
base.append([gdalconst.CXT_Attribute, 'Id', [gdalconst.CXT_Text, self.Id]])
pixval = '%0.15E' % self.GCPPixel
lineval = '%0.15E' % self.GCPLine
xval = '%0.15E' % self.GCPX
yval = '%0.15E' % self.GCPY
zval = '%0.15E' % self.GCPZ
base.append([gdalconst.CXT_Attribute, 'Pixel', [gdalconst.CXT_Text, pixval]])
base.append([gdalconst.CXT_Attribute, 'Line', [gdalconst.CXT_Text, lineval]])
base.append([gdalconst.CXT_Attribute, 'X', [gdalconst.CXT_Text, xval]])
base.append([gdalconst.CXT_Attribute, 'Y', [gdalconst.CXT_Text, yval]])
if with_Z:
base.append([gdalconst.CXT_Attribute, 'Z', [gdalconst.CXT_Text, zval]])
return base
# Register GCP in _gdal:
_gdal.GCP_swigregister(GCP)
def GDAL_GCP_GCPX_get(*args) -> "double":
r"""GDAL_GCP_GCPX_get(GCP gcp) -> double"""
return _gdal.GDAL_GCP_GCPX_get(*args)
def GDAL_GCP_GCPX_set(*args) -> "void":
r"""GDAL_GCP_GCPX_set(GCP gcp, double dfGCPX)"""
return _gdal.GDAL_GCP_GCPX_set(*args)
def GDAL_GCP_GCPY_get(*args) -> "double":
r"""GDAL_GCP_GCPY_get(GCP gcp) -> double"""
return _gdal.GDAL_GCP_GCPY_get(*args)
def GDAL_GCP_GCPY_set(*args) -> "void":
r"""GDAL_GCP_GCPY_set(GCP gcp, double dfGCPY)"""
return _gdal.GDAL_GCP_GCPY_set(*args)
def GDAL_GCP_GCPZ_get(*args) -> "double":
r"""GDAL_GCP_GCPZ_get(GCP gcp) -> double"""
return _gdal.GDAL_GCP_GCPZ_get(*args)
def GDAL_GCP_GCPZ_set(*args) -> "void":
r"""GDAL_GCP_GCPZ_set(GCP gcp, double dfGCPZ)"""
return _gdal.GDAL_GCP_GCPZ_set(*args)
def GDAL_GCP_GCPPixel_get(*args) -> "double":
r"""GDAL_GCP_GCPPixel_get(GCP gcp) -> double"""
return _gdal.GDAL_GCP_GCPPixel_get(*args)
def GDAL_GCP_GCPPixel_set(*args) -> "void":
r"""GDAL_GCP_GCPPixel_set(GCP gcp, double dfGCPPixel)"""
return _gdal.GDAL_GCP_GCPPixel_set(*args)
def GDAL_GCP_GCPLine_get(*args) -> "double":
r"""GDAL_GCP_GCPLine_get(GCP gcp) -> double"""
return _gdal.GDAL_GCP_GCPLine_get(*args)
def GDAL_GCP_GCPLine_set(*args) -> "void":
r"""GDAL_GCP_GCPLine_set(GCP gcp, double dfGCPLine)"""
return _gdal.GDAL_GCP_GCPLine_set(*args)
def GDAL_GCP_Info_get(*args) -> "char const *":
r"""GDAL_GCP_Info_get(GCP gcp) -> char const *"""
return _gdal.GDAL_GCP_Info_get(*args)
def GDAL_GCP_Info_set(*args) -> "void":
r"""GDAL_GCP_Info_set(GCP gcp, char const * pszInfo)"""
return _gdal.GDAL_GCP_Info_set(*args)
def GDAL_GCP_Id_get(*args) -> "char const *":
r"""GDAL_GCP_Id_get(GCP gcp) -> char const *"""
return _gdal.GDAL_GCP_Id_get(*args)
def GDAL_GCP_Id_set(*args) -> "void":
r"""GDAL_GCP_Id_set(GCP gcp, char const * pszId)"""
return _gdal.GDAL_GCP_Id_set(*args)
def GCPsToGeoTransform(*args) -> "double [ANY]":
r"""GCPsToGeoTransform(int nGCPs, int bApproxOK=1) -> RETURN_NONE"""
return _gdal.GCPsToGeoTransform(*args)
class VirtualMem(object):
r"""Proxy of C++ CPLVirtualMemShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_VirtualMem
def GetAddr(self, *args) -> "void":
r"""GetAddr(VirtualMem self)"""
return _gdal.VirtualMem_GetAddr(self, *args)
def Pin(self, *args) -> "void":
r"""Pin(VirtualMem self, size_t start_offset=0, size_t nsize=0, int bWriteOp=0)"""
return _gdal.VirtualMem_Pin(self, *args)
# Register VirtualMem in _gdal:
_gdal.VirtualMem_swigregister(VirtualMem)
class AsyncReader(object):
r"""Proxy of C++ GDALAsyncReaderShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_AsyncReader
def GetNextUpdatedRegion(self, *args) -> "GDALAsyncStatusType":
r"""GetNextUpdatedRegion(AsyncReader self, double timeout) -> GDALAsyncStatusType"""
return _gdal.AsyncReader_GetNextUpdatedRegion(self, *args)
def GetBuffer(self, *args) -> "void":
r"""GetBuffer(AsyncReader self)"""
return _gdal.AsyncReader_GetBuffer(self, *args)
def LockBuffer(self, *args) -> "int":
r"""LockBuffer(AsyncReader self, double timeout) -> int"""
return _gdal.AsyncReader_LockBuffer(self, *args)
def UnlockBuffer(self, *args) -> "void":
r"""UnlockBuffer(AsyncReader self)"""
return _gdal.AsyncReader_UnlockBuffer(self, *args)
# Register AsyncReader in _gdal:
_gdal.AsyncReader_swigregister(AsyncReader)
class Dataset(MajorObject):
r"""Proxy of C++ GDALDatasetShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
RasterXSize = property(_gdal.Dataset_RasterXSize_get, doc=r"""RasterXSize : int""")
RasterYSize = property(_gdal.Dataset_RasterYSize_get, doc=r"""RasterYSize : int""")
RasterCount = property(_gdal.Dataset_RasterCount_get, doc=r"""RasterCount : int""")
__swig_destroy__ = _gdal.delete_Dataset
def GetDriver(self, *args) -> "GDALDriverShadow *":
r"""GetDriver(Dataset self) -> Driver"""
return _gdal.Dataset_GetDriver(self, *args)
def GetRasterBand(self, *args) -> "GDALRasterBandShadow *":
r"""GetRasterBand(Dataset self, int nBand) -> Band"""
return _gdal.Dataset_GetRasterBand(self, *args)
def GetRootGroup(self, *args) -> "GDALGroupHS *":
r"""GetRootGroup(Dataset self) -> Group"""
return _gdal.Dataset_GetRootGroup(self, *args)
def GetProjection(self, *args) -> "char const *":
r"""GetProjection(Dataset self) -> char const *"""
return _gdal.Dataset_GetProjection(self, *args)
def GetProjectionRef(self, *args) -> "char const *":
r"""GetProjectionRef(Dataset self) -> char const *"""
return _gdal.Dataset_GetProjectionRef(self, *args)
def GetSpatialRef(self, *args) -> "OSRSpatialReferenceShadow *":
r"""GetSpatialRef(Dataset self) -> SpatialReference"""
return _gdal.Dataset_GetSpatialRef(self, *args)
def SetProjection(self, *args) -> "CPLErr":
r"""SetProjection(Dataset self, char const * prj) -> CPLErr"""
return _gdal.Dataset_SetProjection(self, *args)
def SetSpatialRef(self, *args) -> "CPLErr":
r"""SetSpatialRef(Dataset self, SpatialReference srs) -> CPLErr"""
return _gdal.Dataset_SetSpatialRef(self, *args)
def GetGeoTransform(self, *args, **kwargs) -> "void":
r"""GetGeoTransform(Dataset self, int * can_return_null=None)"""
return _gdal.Dataset_GetGeoTransform(self, *args, **kwargs)
def SetGeoTransform(self, *args) -> "CPLErr":
r"""SetGeoTransform(Dataset self, double [6] argin) -> CPLErr"""
return _gdal.Dataset_SetGeoTransform(self, *args)
def BuildOverviews(self, *args, **kwargs) -> "int":
r"""BuildOverviews(Dataset self, char const * resampling="NEAREST", int overviewlist=0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> int"""
return _gdal.Dataset_BuildOverviews(self, *args, **kwargs)
def GetGCPCount(self, *args) -> "int":
r"""GetGCPCount(Dataset self) -> int"""
return _gdal.Dataset_GetGCPCount(self, *args)
def GetGCPProjection(self, *args) -> "char const *":
r"""GetGCPProjection(Dataset self) -> char const *"""
return _gdal.Dataset_GetGCPProjection(self, *args)
def GetGCPSpatialRef(self, *args) -> "OSRSpatialReferenceShadow *":
r"""GetGCPSpatialRef(Dataset self) -> SpatialReference"""
return _gdal.Dataset_GetGCPSpatialRef(self, *args)
def GetGCPs(self, *args) -> "void":
r"""GetGCPs(Dataset self)"""
return _gdal.Dataset_GetGCPs(self, *args)
def _SetGCPs(self, *args) -> "CPLErr":
r"""_SetGCPs(Dataset self, int nGCPs, char const * pszGCPProjection) -> CPLErr"""
return _gdal.Dataset__SetGCPs(self, *args)
def _SetGCPs2(self, *args) -> "CPLErr":
r"""_SetGCPs2(Dataset self, int nGCPs, SpatialReference hSRS) -> CPLErr"""
return _gdal.Dataset__SetGCPs2(self, *args)
def FlushCache(self, *args) -> "void":
r"""FlushCache(Dataset self)"""
return _gdal.Dataset_FlushCache(self, *args)
def AddBand(self, *args, **kwargs) -> "CPLErr":
r"""AddBand(Dataset self, GDALDataType datatype=GDT_Byte, char ** options=None) -> CPLErr"""
return _gdal.Dataset_AddBand(self, *args, **kwargs)
def CreateMaskBand(self, *args) -> "CPLErr":
r"""CreateMaskBand(Dataset self, int nFlags) -> CPLErr"""
return _gdal.Dataset_CreateMaskBand(self, *args)
def GetFileList(self, *args) -> "char **":
r"""GetFileList(Dataset self) -> char **"""
return _gdal.Dataset_GetFileList(self, *args)
def WriteRaster(self, *args, **kwargs) -> "CPLErr":
r"""WriteRaster(Dataset self, int xoff, int yoff, int xsize, int ysize, GIntBig buf_len, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None) -> CPLErr"""
return _gdal.Dataset_WriteRaster(self, *args, **kwargs)
def AdviseRead(self, *args) -> "CPLErr":
r"""AdviseRead(Dataset self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, char ** options=None) -> CPLErr"""
return _gdal.Dataset_AdviseRead(self, *args)
def BeginAsyncReader(self, *args, **kwargs) -> "GDALAsyncReaderShadow *":
r"""BeginAsyncReader(Dataset self, int xOff, int yOff, int xSize, int ySize, int buf_len, int buf_xsize, int buf_ysize, GDALDataType bufType=(GDALDataType) 0, int band_list=0, int nPixelSpace=0, int nLineSpace=0, int nBandSpace=0, char ** options=None) -> AsyncReader"""
return _gdal.Dataset_BeginAsyncReader(self, *args, **kwargs)
def EndAsyncReader(self, *args) -> "void":
r"""EndAsyncReader(Dataset self, AsyncReader ario)"""
return _gdal.Dataset_EndAsyncReader(self, *args)
def GetVirtualMem(self, *args, **kwargs) -> "CPLVirtualMemShadow *":
r"""GetVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, int band_list, int bIsBandSequential, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) -> VirtualMem"""
return _gdal.Dataset_GetVirtualMem(self, *args, **kwargs)
def GetTiledVirtualMem(self, *args, **kwargs) -> "CPLVirtualMemShadow *":
r"""GetTiledVirtualMem(Dataset self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, int band_list, GDALTileOrganization eTileOrganization, size_t nCacheSize, char ** options=None) -> VirtualMem"""
return _gdal.Dataset_GetTiledVirtualMem(self, *args, **kwargs)
def CreateLayer(self, *args, **kwargs) -> "OGRLayerShadow *":
r"""CreateLayer(Dataset self, char const * name, SpatialReference srs=None, OGRwkbGeometryType geom_type=wkbUnknown, char ** options=None) -> Layer"""
return _gdal.Dataset_CreateLayer(self, *args, **kwargs)
def CopyLayer(self, *args, **kwargs) -> "OGRLayerShadow *":
r"""CopyLayer(Dataset self, Layer src_layer, char const * new_name, char ** options=None) -> Layer"""
return _gdal.Dataset_CopyLayer(self, *args, **kwargs)
def DeleteLayer(self, *args) -> "OGRErr":
r"""DeleteLayer(Dataset self, int index) -> OGRErr"""
return _gdal.Dataset_DeleteLayer(self, *args)
def GetLayerCount(self, *args) -> "int":
r"""GetLayerCount(Dataset self) -> int"""
return _gdal.Dataset_GetLayerCount(self, *args)
def IsLayerPrivate(self, *args) -> "bool":
r"""IsLayerPrivate(Dataset self, int index) -> bool"""
return _gdal.Dataset_IsLayerPrivate(self, *args)
def GetLayerByIndex(self, *args) -> "OGRLayerShadow *":
r"""GetLayerByIndex(Dataset self, int index=0) -> Layer"""
return _gdal.Dataset_GetLayerByIndex(self, *args)
def GetLayerByName(self, *args) -> "OGRLayerShadow *":
r"""GetLayerByName(Dataset self, char const * layer_name) -> Layer"""
return _gdal.Dataset_GetLayerByName(self, *args)
def ResetReading(self, *args) -> "void":
r"""ResetReading(Dataset self)"""
return _gdal.Dataset_ResetReading(self, *args)
def GetNextFeature(self, *args, **kwargs) -> "OGRFeatureShadow *":
r"""GetNextFeature(Dataset self, bool include_layer=True, bool include_pct=False, GDALProgressFunc callback=0, void * callback_data=None) -> Feature"""
return _gdal.Dataset_GetNextFeature(self, *args, **kwargs)
def TestCapability(self, *args) -> "bool":
r"""TestCapability(Dataset self, char const * cap) -> bool"""
return _gdal.Dataset_TestCapability(self, *args)
def ExecuteSQL(self, *args, **kwargs) -> "OGRLayerShadow *":
r"""ExecuteSQL(Dataset self, char const * statement, Geometry spatialFilter=None, char const * dialect="") -> Layer"""
return _gdal.Dataset_ExecuteSQL(self, *args, **kwargs)
def ReleaseResultSet(self, *args) -> "void":
r"""ReleaseResultSet(Dataset self, Layer layer)"""
return _gdal.Dataset_ReleaseResultSet(self, *args)
def GetStyleTable(self, *args) -> "OGRStyleTableShadow *":
r"""GetStyleTable(Dataset self) -> StyleTable"""
return _gdal.Dataset_GetStyleTable(self, *args)
def SetStyleTable(self, *args) -> "void":
r"""SetStyleTable(Dataset self, StyleTable table)"""
return _gdal.Dataset_SetStyleTable(self, *args)
def AbortSQL(self, *args) -> "OGRErr":
r"""AbortSQL(Dataset self) -> OGRErr"""
return _gdal.Dataset_AbortSQL(self, *args)
def StartTransaction(self, *args, **kwargs) -> "OGRErr":
r"""StartTransaction(Dataset self, int force=FALSE) -> OGRErr"""
return _gdal.Dataset_StartTransaction(self, *args, **kwargs)
def CommitTransaction(self, *args) -> "OGRErr":
r"""CommitTransaction(Dataset self) -> OGRErr"""
return _gdal.Dataset_CommitTransaction(self, *args)
def RollbackTransaction(self, *args) -> "OGRErr":
r"""RollbackTransaction(Dataset self) -> OGRErr"""
return _gdal.Dataset_RollbackTransaction(self, *args)
def ClearStatistics(self, *args) -> "void":
r"""ClearStatistics(Dataset self)"""
return _gdal.Dataset_ClearStatistics(self, *args)
def GetFieldDomainNames(self, *args) -> "char **":
r"""GetFieldDomainNames(Dataset self, char ** options=None) -> char **"""
return _gdal.Dataset_GetFieldDomainNames(self, *args)
def GetFieldDomain(self, *args) -> "OGRFieldDomainShadow *":
r"""GetFieldDomain(Dataset self, char const * name) -> FieldDomain"""
return _gdal.Dataset_GetFieldDomain(self, *args)
def AddFieldDomain(self, *args) -> "bool":
r"""AddFieldDomain(Dataset self, FieldDomain fieldDomain) -> bool"""
return _gdal.Dataset_AddFieldDomain(self, *args)
def DeleteFieldDomain(self, *args) -> "bool":
r"""DeleteFieldDomain(Dataset self, char const * name) -> bool"""
return _gdal.Dataset_DeleteFieldDomain(self, *args)
def UpdateFieldDomain(self, *args) -> "bool":
r"""UpdateFieldDomain(Dataset self, FieldDomain fieldDomain) -> bool"""
return _gdal.Dataset_UpdateFieldDomain(self, *args)
def GetRelationshipNames(self, *args) -> "char **":
r"""GetRelationshipNames(Dataset self, char ** options=None) -> char **"""
return _gdal.Dataset_GetRelationshipNames(self, *args)
def GetRelationship(self, *args) -> "GDALRelationshipShadow *":
r"""GetRelationship(Dataset self, char const * name) -> Relationship"""
return _gdal.Dataset_GetRelationship(self, *args)
def AddRelationship(self, *args) -> "bool":
r"""AddRelationship(Dataset self, Relationship relationship) -> bool"""
return _gdal.Dataset_AddRelationship(self, *args)
def DeleteRelationship(self, *args) -> "bool":
r"""DeleteRelationship(Dataset self, char const * name) -> bool"""
return _gdal.Dataset_DeleteRelationship(self, *args)
def UpdateRelationship(self, *args) -> "bool":
r"""UpdateRelationship(Dataset self, Relationship relationship) -> bool"""
return _gdal.Dataset_UpdateRelationship(self, *args)
def ReadRaster1(self, *args, **kwargs) -> "CPLErr":
r"""ReadRaster1(Dataset self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, int band_list=0, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GIntBig * buf_band_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) -> CPLErr"""
return _gdal.Dataset_ReadRaster1(self, *args, **kwargs)
def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None, buf_obj=None,
buf_xsize=None, buf_ysize=None, buf_type=None,
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None,
interleave='band',
band_list=None):
""" Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
parameters should generally not be specified if buf_obj is specified. The array is returned"""
from osgeo import gdal_array
return gdal_array.DatasetReadAsArray(self, xoff, yoff, xsize, ysize, buf_obj,
buf_xsize, buf_ysize, buf_type,
resample_alg=resample_alg,
callback=callback,
callback_data=callback_data,
interleave=interleave,
band_list=band_list)
def WriteArray(self, array, xoff=0, yoff=0,
band_list=None,
interleave='band',
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None):
from osgeo import gdal_array
return gdal_array.DatasetWriteArray(self, array, xoff, yoff,
band_list=band_list,
interleave=interleave,
resample_alg=resample_alg,
callback=callback,
callback_data=callback_data)
def WriteRaster(self, xoff, yoff, xsize, ysize,
buf_string,
buf_xsize=None, buf_ysize=None, buf_type=None,
band_list=None,
buf_pixel_space=None, buf_line_space=None, buf_band_space=None ):
if buf_xsize is None:
buf_xsize = xsize
if buf_ysize is None:
buf_ysize = ysize
if band_list is None:
band_list = list(range(1, self.RasterCount + 1))
# Redirect to numpy-friendly WriteArray() if buf_string is a numpy array
# and other arguments are compatible
if type(buf_string).__name__ == 'ndarray' and \
buf_xsize == xsize and buf_ysize == ysize and buf_type is None and \
buf_pixel_space is None and buf_line_space is None and buf_band_space is None:
return self.WriteArray(buf_string, xoff=xoff, yoff=yoff,
band_list=band_list)
if buf_type is None:
buf_type = self.GetRasterBand(1).DataType
return _gdal.Dataset_WriteRaster(self,
xoff, yoff, xsize, ysize,
buf_string, buf_xsize, buf_ysize, buf_type, band_list,
buf_pixel_space, buf_line_space, buf_band_space )
def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
buf_xsize=None, buf_ysize=None, buf_type=None,
band_list=None,
buf_pixel_space=None, buf_line_space=None, buf_band_space=None,
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None,
buf_obj=None):
if xsize is None:
xsize = self.RasterXSize
if ysize is None:
ysize = self.RasterYSize
if band_list is None:
band_list = list(range(1, self.RasterCount + 1))
if buf_xsize is None:
buf_xsize = xsize
if buf_ysize is None:
buf_ysize = ysize
if buf_type is None:
buf_type = self.GetRasterBand(1).DataType;
return _gdal.Dataset_ReadRaster1(self, xoff, yoff, xsize, ysize,
buf_xsize, buf_ysize, buf_type,
band_list, buf_pixel_space, buf_line_space, buf_band_space,
resample_alg, callback, callback_data, buf_obj )
def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
xsize=None, ysize=None, bufxsize=None, bufysize=None,
datatype=None, band_list=None, band_sequential = True,
cache_size = 10 * 1024 * 1024, page_size_hint = 0,
options=None):
"""Return a NumPy array for the dataset, seen as a virtual memory mapping.
If there are several bands and band_sequential = True, an element is
accessed with array[band][y][x].
If there are several bands and band_sequential = False, an element is
accessed with array[y][x][band].
If there is only one band, an element is accessed with array[y][x].
Any reference to the array must be dropped before the last reference to the
related dataset is also dropped.
"""
from osgeo import gdal_array
if xsize is None:
xsize = self.RasterXSize
if ysize is None:
ysize = self.RasterYSize
if bufxsize is None:
bufxsize = self.RasterXSize
if bufysize is None:
bufysize = self.RasterYSize
if datatype is None:
datatype = self.GetRasterBand(1).DataType
if band_list is None:
band_list = list(range(1, self.RasterCount + 1))
if options is None:
virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint)
else:
virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, band_list, band_sequential, cache_size, page_size_hint, options)
return gdal_array.VirtualMemGetArray( virtualmem )
def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
xsize=None, ysize=None, tilexsize=256, tileysize=256,
datatype=None, band_list=None, tile_organization=gdalconst.GTO_BSQ,
cache_size = 10 * 1024 * 1024, options=None):
"""Return a NumPy array for the dataset, seen as a virtual memory mapping with
a tile organization.
If there are several bands and tile_organization = gdal.GTO_TIP, an element is
accessed with array[tiley][tilex][y][x][band].
If there are several bands and tile_organization = gdal.GTO_BIT, an element is
accessed with array[tiley][tilex][band][y][x].
If there are several bands and tile_organization = gdal.GTO_BSQ, an element is
accessed with array[band][tiley][tilex][y][x].
If there is only one band, an element is accessed with array[tiley][tilex][y][x].
Any reference to the array must be dropped before the last reference to the
related dataset is also dropped.
"""
from osgeo import gdal_array
if xsize is None:
xsize = self.RasterXSize
if ysize is None:
ysize = self.RasterYSize
if datatype is None:
datatype = self.GetRasterBand(1).DataType
if band_list is None:
band_list = list(range(1, self.RasterCount + 1))
if options is None:
virtualmem = self.GetTiledVirtualMem(eAccess, xoff, yoff, xsize, ysize, tilexsize, tileysize, datatype, band_list, tile_organization, cache_size)
else:
virtualmem = self.GetTiledVirtualMem(eAccess, xoff, yoff, xsize, ysize, tilexsize, tileysize, datatype, band_list, tile_organization, cache_size, options)
return gdal_array.VirtualMemGetArray( virtualmem )
def GetSubDatasets(self):
sd_list = []
sd = self.GetMetadata('SUBDATASETS')
if sd is None:
return sd_list
i = 1
while 'SUBDATASET_'+str(i)+'_NAME' in sd:
sd_list.append((sd['SUBDATASET_'+str(i)+'_NAME'],
sd['SUBDATASET_'+str(i)+'_DESC']))
i = i + 1
return sd_list
def BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj=None, buf_xsize=None, buf_ysize=None, buf_type=None, band_list=None, options=None):
if band_list is None:
band_list = list(range(1, self.RasterCount + 1))
if buf_xsize is None:
buf_xsize = 0;
if buf_ysize is None:
buf_ysize = 0;
if buf_type is None:
buf_type = gdalconst.GDT_Byte
if buf_xsize <= 0:
buf_xsize = xsize
if buf_ysize <= 0:
buf_ysize = ysize
options = [] if options is None else options
if buf_obj is None:
from sys import version_info
nRequiredSize = int(buf_xsize * buf_ysize * len(band_list) * (_gdal.GetDataTypeSize(buf_type) / 8))
if version_info >= (3, 0, 0):
buf_obj_ar = [None]
exec("buf_obj_ar[0] = b' ' * nRequiredSize")
buf_obj = buf_obj_ar[0]
else:
buf_obj = ' ' * nRequiredSize
return _gdal.Dataset_BeginAsyncReader(self, xoff, yoff, xsize, ysize, buf_obj, buf_xsize, buf_ysize, buf_type, band_list, 0, 0, 0, options)
def GetLayer(self, iLayer=0):
"""Return the layer given an index or a name"""
if isinstance(iLayer, str):
return self.GetLayerByName(str(iLayer))
elif isinstance(iLayer, int):
return self.GetLayerByIndex(iLayer)
else:
raise TypeError("Input %s is not of String or Int type" % type(iLayer))
def DeleteLayer(self, value):
"""Deletes the layer given an index or layer name"""
if isinstance(value, str):
for i in range(self.GetLayerCount()):
name = self.GetLayer(i).GetName()
if name == value:
return _gdal.Dataset_DeleteLayer(self, i)
raise ValueError("Layer %s not found to delete" % value)
elif isinstance(value, int):
return _gdal.Dataset_DeleteLayer(self, value)
else:
raise TypeError("Input %s is not of String or Int type" % type(value))
def SetGCPs(self, gcps, wkt_or_spatial_ref):
if isinstance(wkt_or_spatial_ref, str):
return self._SetGCPs(gcps, wkt_or_spatial_ref)
else:
return self._SetGCPs2(gcps, wkt_or_spatial_ref)
# Register Dataset in _gdal:
_gdal.Dataset_swigregister(Dataset)
GEDTST_NONE = _gdal.GEDTST_NONE
GEDTST_JSON = _gdal.GEDTST_JSON
class Group(object):
r"""Proxy of C++ GDALGroupHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_Group
def GetName(self, *args) -> "char const *":
r"""GetName(Group self) -> char const *"""
return _gdal.Group_GetName(self, *args)
def GetFullName(self, *args) -> "char const *":
r"""GetFullName(Group self) -> char const *"""
return _gdal.Group_GetFullName(self, *args)
def GetMDArrayNames(self, *args) -> "char **":
r"""GetMDArrayNames(Group self, char ** options=None) -> char **"""
return _gdal.Group_GetMDArrayNames(self, *args)
def OpenMDArray(self, *args) -> "GDALMDArrayHS *":
r"""OpenMDArray(Group self, char const * name, char ** options=None) -> MDArray"""
return _gdal.Group_OpenMDArray(self, *args)
def OpenMDArrayFromFullname(self, *args) -> "GDALMDArrayHS *":
r"""OpenMDArrayFromFullname(Group self, char const * name, char ** options=None) -> MDArray"""
return _gdal.Group_OpenMDArrayFromFullname(self, *args)
def ResolveMDArray(self, *args) -> "GDALMDArrayHS *":
r"""ResolveMDArray(Group self, char const * name, char const * starting_point, char ** options=None) -> MDArray"""
return _gdal.Group_ResolveMDArray(self, *args)
def GetGroupNames(self, *args) -> "char **":
r"""GetGroupNames(Group self, char ** options=None) -> char **"""
return _gdal.Group_GetGroupNames(self, *args)
def OpenGroup(self, *args) -> "GDALGroupHS *":
r"""OpenGroup(Group self, char const * name, char ** options=None) -> Group"""
return _gdal.Group_OpenGroup(self, *args)
def OpenGroupFromFullname(self, *args) -> "GDALGroupHS *":
r"""OpenGroupFromFullname(Group self, char const * name, char ** options=None) -> Group"""
return _gdal.Group_OpenGroupFromFullname(self, *args)
def GetVectorLayerNames(self, *args) -> "char **":
r"""GetVectorLayerNames(Group self, char ** options=None) -> char **"""
return _gdal.Group_GetVectorLayerNames(self, *args)
def OpenVectorLayer(self, *args) -> "OGRLayerShadow *":
r"""OpenVectorLayer(Group self, char const * name, char ** options=None) -> Layer"""
return _gdal.Group_OpenVectorLayer(self, *args)
def GetDimensions(self, *args) -> "void":
r"""GetDimensions(Group self, char ** options=None)"""
return _gdal.Group_GetDimensions(self, *args)
def GetAttribute(self, *args) -> "GDALAttributeHS *":
r"""GetAttribute(Group self, char const * name) -> Attribute"""
return _gdal.Group_GetAttribute(self, *args)
def GetAttributes(self, *args) -> "void":
r"""GetAttributes(Group self, char ** options=None)"""
return _gdal.Group_GetAttributes(self, *args)
def GetStructuralInfo(self, *args) -> "char **":
r"""GetStructuralInfo(Group self) -> char **"""
return _gdal.Group_GetStructuralInfo(self, *args)
def CreateGroup(self, *args) -> "GDALGroupHS *":
r"""CreateGroup(Group self, char const * name, char ** options=None) -> Group"""
return _gdal.Group_CreateGroup(self, *args)
def CreateDimension(self, *args) -> "GDALDimensionHS *":
r"""CreateDimension(Group self, char const * name, char const * type, char const * direction, unsigned long long size, char ** options=None) -> Dimension"""
return _gdal.Group_CreateDimension(self, *args)
def CreateMDArray(self, *args) -> "GDALMDArrayHS *":
r"""CreateMDArray(Group self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> MDArray"""
return _gdal.Group_CreateMDArray(self, *args)
def CreateAttribute(self, *args) -> "GDALAttributeHS *":
r"""CreateAttribute(Group self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> Attribute"""
return _gdal.Group_CreateAttribute(self, *args)
# Register Group in _gdal:
_gdal.Group_swigregister(Group)
class Statistics(object):
r"""Proxy of C++ Statistics class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
min = property(_gdal.Statistics_min_get, doc=r"""min : double""")
max = property(_gdal.Statistics_max_get, doc=r"""max : double""")
mean = property(_gdal.Statistics_mean_get, doc=r"""mean : double""")
std_dev = property(_gdal.Statistics_std_dev_get, doc=r"""std_dev : double""")
valid_count = property(_gdal.Statistics_valid_count_get, doc=r"""valid_count : GIntBig""")
__swig_destroy__ = _gdal.delete_Statistics
def __init__(self, *args):
r"""__init__(Statistics self) -> Statistics"""
_gdal.Statistics_swiginit(self, _gdal.new_Statistics(*args))
# Register Statistics in _gdal:
_gdal.Statistics_swigregister(Statistics)
class MDArray(object):
r"""Proxy of C++ GDALMDArrayHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_MDArray
def GetName(self, *args) -> "char const *":
r"""GetName(MDArray self) -> char const *"""
return _gdal.MDArray_GetName(self, *args)
def GetFullName(self, *args) -> "char const *":
r"""GetFullName(MDArray self) -> char const *"""
return _gdal.MDArray_GetFullName(self, *args)
def GetTotalElementsCount(self, *args) -> "unsigned long long":
r"""GetTotalElementsCount(MDArray self) -> unsigned long long"""
return _gdal.MDArray_GetTotalElementsCount(self, *args)
def GetDimensionCount(self, *args) -> "size_t":
r"""GetDimensionCount(MDArray self) -> size_t"""
return _gdal.MDArray_GetDimensionCount(self, *args)
def GetDimensions(self, *args) -> "void":
r"""GetDimensions(MDArray self)"""
return _gdal.MDArray_GetDimensions(self, *args)
def GetCoordinateVariables(self, *args) -> "void":
r"""GetCoordinateVariables(MDArray self)"""
return _gdal.MDArray_GetCoordinateVariables(self, *args)
def GetBlockSize(self, *args) -> "void":
r"""GetBlockSize(MDArray self)"""
return _gdal.MDArray_GetBlockSize(self, *args)
def GetProcessingChunkSize(self, *args) -> "void":
r"""GetProcessingChunkSize(MDArray self, size_t nMaxChunkMemory)"""
return _gdal.MDArray_GetProcessingChunkSize(self, *args)
def GetDataType(self, *args) -> "GDALExtendedDataTypeHS *":
r"""GetDataType(MDArray self) -> ExtendedDataType"""
return _gdal.MDArray_GetDataType(self, *args)
def GetStructuralInfo(self, *args) -> "char **":
r"""GetStructuralInfo(MDArray self) -> char **"""
return _gdal.MDArray_GetStructuralInfo(self, *args)
def Read(self, *args) -> "CPLErr":
r"""Read(MDArray self, int nDims1, int nDims2, int nDims3, int nDims4, ExtendedDataType buffer_datatype) -> CPLErr"""
return _gdal.MDArray_Read(self, *args)
def WriteStringArray(self, *args) -> "CPLErr":
r"""WriteStringArray(MDArray self, int nDims1, int nDims2, int nDims3, ExtendedDataType buffer_datatype, char ** options) -> CPLErr"""
return _gdal.MDArray_WriteStringArray(self, *args)
def Write(self, *args) -> "CPLErr":
r"""Write(MDArray self, int nDims1, int nDims2, int nDims3, int nDims4, ExtendedDataType buffer_datatype, GIntBig buf_len) -> CPLErr"""
return _gdal.MDArray_Write(self, *args)
def AdviseRead(self, *args) -> "CPLErr":
r"""AdviseRead(MDArray self, int nDims1, int nDims2, char ** options=None) -> CPLErr"""
return _gdal.MDArray_AdviseRead(self, *args)
def GetAttribute(self, *args) -> "GDALAttributeHS *":
r"""GetAttribute(MDArray self, char const * name) -> Attribute"""
return _gdal.MDArray_GetAttribute(self, *args)
def GetAttributes(self, *args) -> "void":
r"""GetAttributes(MDArray self, char ** options=None)"""
return _gdal.MDArray_GetAttributes(self, *args)
def CreateAttribute(self, *args) -> "GDALAttributeHS *":
r"""CreateAttribute(MDArray self, char const * name, int nDimensions, ExtendedDataType data_type, char ** options=None) -> Attribute"""
return _gdal.MDArray_CreateAttribute(self, *args)
def GetNoDataValueAsRaw(self, *args) -> "CPLErr":
r"""GetNoDataValueAsRaw(MDArray self) -> CPLErr"""
return _gdal.MDArray_GetNoDataValueAsRaw(self, *args)
def GetNoDataValueAsDouble(self, *args) -> "void":
r"""GetNoDataValueAsDouble(MDArray self)"""
return _gdal.MDArray_GetNoDataValueAsDouble(self, *args)
def GetNoDataValueAsInt64(self, *args) -> "void":
r"""GetNoDataValueAsInt64(MDArray self)"""
return _gdal.MDArray_GetNoDataValueAsInt64(self, *args)
def GetNoDataValueAsUInt64(self, *args) -> "void":
r"""GetNoDataValueAsUInt64(MDArray self)"""
return _gdal.MDArray_GetNoDataValueAsUInt64(self, *args)
def GetNoDataValueAsString(self, *args) -> "retStringAndCPLFree *":
r"""GetNoDataValueAsString(MDArray self) -> retStringAndCPLFree *"""
return _gdal.MDArray_GetNoDataValueAsString(self, *args)
def SetNoDataValueDouble(self, *args) -> "CPLErr":
r"""SetNoDataValueDouble(MDArray self, double d) -> CPLErr"""
return _gdal.MDArray_SetNoDataValueDouble(self, *args)
def SetNoDataValueInt64(self, *args) -> "CPLErr":
r"""SetNoDataValueInt64(MDArray self, GIntBig v) -> CPLErr"""
return _gdal.MDArray_SetNoDataValueInt64(self, *args)
def SetNoDataValueUInt64(self, *args) -> "CPLErr":
r"""SetNoDataValueUInt64(MDArray self, GUIntBig v) -> CPLErr"""
return _gdal.MDArray_SetNoDataValueUInt64(self, *args)
def SetNoDataValueString(self, *args) -> "CPLErr":
r"""SetNoDataValueString(MDArray self, char const * nodata) -> CPLErr"""
return _gdal.MDArray_SetNoDataValueString(self, *args)
def SetNoDataValueRaw(self, *args) -> "CPLErr":
r"""SetNoDataValueRaw(MDArray self, GIntBig nLen) -> CPLErr"""
return _gdal.MDArray_SetNoDataValueRaw(self, *args)
def DeleteNoDataValue(self, *args) -> "CPLErr":
r"""DeleteNoDataValue(MDArray self) -> CPLErr"""
return _gdal.MDArray_DeleteNoDataValue(self, *args)
def GetOffset(self, *args) -> "void":
r"""GetOffset(MDArray self)"""
return _gdal.MDArray_GetOffset(self, *args)
def GetOffsetStorageType(self, *args) -> "GDALDataType":
r"""GetOffsetStorageType(MDArray self) -> GDALDataType"""
return _gdal.MDArray_GetOffsetStorageType(self, *args)
def GetScale(self, *args) -> "void":
r"""GetScale(MDArray self)"""
return _gdal.MDArray_GetScale(self, *args)
def GetScaleStorageType(self, *args) -> "GDALDataType":
r"""GetScaleStorageType(MDArray self) -> GDALDataType"""
return _gdal.MDArray_GetScaleStorageType(self, *args)
def SetOffset(self, *args, **kwargs) -> "CPLErr":
r"""SetOffset(MDArray self, double val, GDALDataType storageType=GDT_Unknown) -> CPLErr"""
return _gdal.MDArray_SetOffset(self, *args, **kwargs)
def SetScale(self, *args, **kwargs) -> "CPLErr":
r"""SetScale(MDArray self, double val, GDALDataType storageType=GDT_Unknown) -> CPLErr"""
return _gdal.MDArray_SetScale(self, *args, **kwargs)
def SetUnit(self, *args) -> "CPLErr":
r"""SetUnit(MDArray self, char const * unit) -> CPLErr"""
return _gdal.MDArray_SetUnit(self, *args)
def GetUnit(self, *args) -> "char const *":
r"""GetUnit(MDArray self) -> char const *"""
return _gdal.MDArray_GetUnit(self, *args)
def SetSpatialRef(self, *args) -> "OGRErr":
r"""SetSpatialRef(MDArray self, SpatialReference srs) -> OGRErr"""
return _gdal.MDArray_SetSpatialRef(self, *args)
def GetSpatialRef(self, *args) -> "OSRSpatialReferenceShadow *":
r"""GetSpatialRef(MDArray self) -> SpatialReference"""
return _gdal.MDArray_GetSpatialRef(self, *args)
def GetView(self, *args) -> "GDALMDArrayHS *":
r"""GetView(MDArray self, char const * viewExpr) -> MDArray"""
return _gdal.MDArray_GetView(self, *args)
def Transpose(self, *args) -> "GDALMDArrayHS *":
r"""Transpose(MDArray self, int nList) -> MDArray"""
return _gdal.MDArray_Transpose(self, *args)
def GetUnscaled(self, *args) -> "GDALMDArrayHS *":
r"""GetUnscaled(MDArray self) -> MDArray"""
return _gdal.MDArray_GetUnscaled(self, *args)
def GetMask(self, *args) -> "GDALMDArrayHS *":
r"""GetMask(MDArray self, char ** options=None) -> MDArray"""
return _gdal.MDArray_GetMask(self, *args)
def AsClassicDataset(self, *args) -> "GDALDatasetShadow *":
r"""AsClassicDataset(MDArray self, size_t iXDim, size_t iYDim) -> Dataset"""
return _gdal.MDArray_AsClassicDataset(self, *args)
def GetStatistics(self, *args, **kwargs) -> "Statistics *":
r"""GetStatistics(MDArray self, bool approx_ok=FALSE, bool force=TRUE, GDALProgressFunc callback=0, void * callback_data=None) -> Statistics"""
return _gdal.MDArray_GetStatistics(self, *args, **kwargs)
def ComputeStatistics(self, *args, **kwargs) -> "Statistics *":
r"""ComputeStatistics(MDArray self, bool approx_ok=FALSE, GDALProgressFunc callback=0, void * callback_data=None) -> Statistics"""
return _gdal.MDArray_ComputeStatistics(self, *args, **kwargs)
def GetResampled(self, *args) -> "GDALMDArrayHS *":
r"""GetResampled(MDArray self, int nDimensions, GDALRIOResampleAlg resample_alg, OSRSpatialReferenceShadow ** srs, char ** options=None) -> MDArray"""
return _gdal.MDArray_GetResampled(self, *args)
def Cache(self, *args) -> "bool":
r"""Cache(MDArray self, char ** options=None) -> bool"""
return _gdal.MDArray_Cache(self, *args)
def Read(self,
array_start_idx = None,
count = None,
array_step = None,
buffer_stride = None,
buffer_datatype = None):
if not array_start_idx:
array_start_idx = [0] * self.GetDimensionCount()
if not count:
count = [ dim.GetSize() for dim in self.GetDimensions() ]
if not array_step:
array_step = [1] * self.GetDimensionCount()
if not buffer_stride:
stride = 1
buffer_stride = []
# To compute strides we must proceed from the fastest varying dimension
# (the last one), and then reverse the result
for cnt in reversed(count):
buffer_stride.append(stride)
stride *= cnt
buffer_stride.reverse()
if not buffer_datatype:
buffer_datatype = self.GetDataType()
return _gdal.MDArray_Read(self, array_start_idx, count, array_step, buffer_stride, buffer_datatype)
def ReadAsArray(self,
array_start_idx = None,
count = None,
array_step = None,
buffer_datatype = None,
buf_obj = None):
from osgeo import gdal_array
return gdal_array.MDArrayReadAsArray(self, array_start_idx, count, array_step, buffer_datatype, buf_obj)
def AdviseRead(self, array_start_idx = None, count = None, options = []):
if not array_start_idx:
array_start_idx = [0] * self.GetDimensionCount()
if not count:
count = [ (self.GetDimensions()[i].GetSize() - array_start_idx[i]) for i in range (self.GetDimensionCount()) ]
return _gdal.MDArray_AdviseRead(self, array_start_idx, count, options)
def __getitem__(self, item):
def stringify(v):
if v == Ellipsis:
return '...'
if isinstance(v, slice):
return ':'.join([str(x) if x is not None else '' for x in (v.start, v.stop, v.step)])
if isinstance(v, str):
return v
if isinstance(v, (int, type(12345678901234))):
return str(v)
try:
import numpy as np
if v == np.newaxis:
return 'newaxis'
except:
pass
return str(v)
if isinstance(item, str):
return self.GetView('["' + item.replace('\\', '\\\\').replace('"', '\\"') + '"]')
elif isinstance(item, slice):
return self.GetView('[' + stringify(item) + ']')
elif isinstance(item, tuple):
return self.GetView('[' + ','.join([stringify(x) for x in item]) + ']')
else:
return self.GetView('[' + stringify(item) + ']')
def Write(self,
buffer,
array_start_idx = None,
count = None,
array_step = None,
buffer_stride = None,
buffer_datatype = None):
dimCount = self.GetDimensionCount()
# Redirect to numpy-friendly WriteArray() if buffer is a numpy array
# and other arguments are compatible
if type(buffer).__name__ == 'ndarray' and \
count is None and buffer_stride is None and buffer_datatype is None:
return self.WriteArray(buffer, array_start_idx=array_start_idx, array_step=array_step)
# Special case for buffer of type array and 1D arrays
if dimCount == 1 and type(buffer).__name__ == 'array' and \
count is None and buffer_stride is None and buffer_datatype is None:
map_typecode_itemsize_to_gdal = {
('B', 1): GDT_Byte,
('h', 2): GDT_Int16,
('H', 2): GDT_UInt16,
('i', 4): GDT_Int32,
('I', 4): GDT_UInt32,
('l', 4): GDT_Int32,
# ('l', 8): GDT_Int64,
# ('q', 8): GDT_Int64,
# ('Q', 8): GDT_UInt64,
('f', 4): GDT_Float32,
('d', 8): GDT_Float64
}
key = (buffer.typecode, buffer.itemsize)
if key not in map_typecode_itemsize_to_gdal:
raise Exception("unhandled type for buffer of type array")
buffer_datatype = ExtendedDataType.Create(map_typecode_itemsize_to_gdal[key])
# Special case for a list of numeric values and 1D arrays
elif dimCount == 1 and type(buffer) == type([]) and len(buffer) != 0 \
and self.GetDataType().GetClass() != GEDTC_STRING:
buffer_datatype = GDT_Int32
for v in buffer:
if isinstance(v, int):
if v >= (1 << 31) or v < -(1 << 31):
buffer_datatype = GDT_Float64
elif isinstance(v, float):
buffer_datatype = GDT_Float64
else:
raise ValueError('Only lists with integer or float elements are supported')
import array
buffer = array.array('d' if buffer_datatype == GDT_Float64 else 'i', buffer)
buffer_datatype = ExtendedDataType.Create(buffer_datatype)
if not buffer_datatype:
buffer_datatype = self.GetDataType()
is_1d_string = self.GetDataType().GetClass() == GEDTC_STRING and buffer_datatype.GetClass() == GEDTC_STRING and dimCount == 1
if not array_start_idx:
array_start_idx = [0] * dimCount
if not count:
if is_1d_string:
assert type(buffer) == type([])
count = [ len(buffer) ]
else:
count = [ dim.GetSize() for dim in self.GetDimensions() ]
if not array_step:
array_step = [1] * dimCount
if not buffer_stride:
stride = 1
buffer_stride = []
# To compute strides we must proceed from the fastest varying dimension
# (the last one), and then reverse the result
for cnt in reversed(count):
buffer_stride.append(stride)
stride *= cnt
buffer_stride.reverse()
if is_1d_string:
return _gdal.MDArray_WriteStringArray(self, array_start_idx, count, array_step, buffer_datatype, buffer)
return _gdal.MDArray_Write(self, array_start_idx, count, array_step, buffer_stride, buffer_datatype, buffer)
def WriteArray(self, array,
array_start_idx = None,
array_step = None):
from osgeo import gdal_array
return gdal_array.MDArrayWriteArray(self, array, array_start_idx, array_step)
def ReadAsMaskedArray(self,
array_start_idx = None,
count = None,
array_step = None):
""" Return a numpy masked array of ReadAsArray() with GetMask() """
import numpy
mask = self.GetMask()
if mask is not None:
array = self.ReadAsArray(array_start_idx, count, array_step)
mask_array = mask.ReadAsArray(array_start_idx, count, array_step)
bool_array = ~mask_array.astype(bool)
return numpy.ma.array(array, mask=bool_array)
else:
return numpy.ma.array(self.ReadAsArray(array_start_idx, count, array_step), mask=None)
def GetShape(self):
""" Return the shape of the array """
if not self.GetDimensionCount():
return None
shp = ()
for dim in self.GetDimensions():
shp += (dim.GetSize(),)
return shp
shape = property(fget=GetShape, doc='Returns the shape of the array.')
def GetNoDataValue(self):
"""GetNoDataValue(MDArray self) -> value """
dt = self.GetDataType()
if dt.GetClass() == GEDTC_NUMERIC and dt.GetNumericDataType() == gdalconst.GDT_Int64:
return _gdal.MDArray_GetNoDataValueAsInt64(self)
if dt.GetClass() == GEDTC_NUMERIC and dt.GetNumericDataType() == gdalconst.GDT_UInt64:
return _gdal.MDArray_GetNoDataValueAsUInt64(self)
return _gdal.MDArray_GetNoDataValueAsDouble(self)
def SetNoDataValue(self, value):
"""SetNoDataValue(MDArray self, value) -> CPLErr"""
dt = self.GetDataType()
if dt.GetClass() == GEDTC_NUMERIC and dt.GetNumericDataType() == gdalconst.GDT_Int64:
return _gdal.MDArray_SetNoDataValueInt64(self, value)
if dt.GetClass() == GEDTC_NUMERIC and dt.GetNumericDataType() == gdalconst.GDT_UInt64:
return _gdal.MDArray_SetNoDataValueUInt64(self, value)
return _gdal.MDArray_SetNoDataValueDouble(self, value)
# Register MDArray in _gdal:
_gdal.MDArray_swigregister(MDArray)
class Attribute(object):
r"""Proxy of C++ GDALAttributeHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_Attribute
def GetName(self, *args) -> "char const *":
r"""GetName(Attribute self) -> char const *"""
return _gdal.Attribute_GetName(self, *args)
def GetFullName(self, *args) -> "char const *":
r"""GetFullName(Attribute self) -> char const *"""
return _gdal.Attribute_GetFullName(self, *args)
def GetTotalElementsCount(self, *args) -> "unsigned long long":
r"""GetTotalElementsCount(Attribute self) -> unsigned long long"""
return _gdal.Attribute_GetTotalElementsCount(self, *args)
def GetDimensionCount(self, *args) -> "size_t":
r"""GetDimensionCount(Attribute self) -> size_t"""
return _gdal.Attribute_GetDimensionCount(self, *args)
def GetDimensionsSize(self, *args) -> "void":
r"""GetDimensionsSize(Attribute self)"""
return _gdal.Attribute_GetDimensionsSize(self, *args)
def GetDataType(self, *args) -> "GDALExtendedDataTypeHS *":
r"""GetDataType(Attribute self) -> ExtendedDataType"""
return _gdal.Attribute_GetDataType(self, *args)
def ReadAsRaw(self, *args) -> "CPLErr":
r"""ReadAsRaw(Attribute self) -> CPLErr"""
return _gdal.Attribute_ReadAsRaw(self, *args)
def ReadAsString(self, *args) -> "char const *":
r"""ReadAsString(Attribute self) -> char const *"""
return _gdal.Attribute_ReadAsString(self, *args)
def ReadAsInt(self, *args) -> "int":
r"""ReadAsInt(Attribute self) -> int"""
return _gdal.Attribute_ReadAsInt(self, *args)
def ReadAsDouble(self, *args) -> "double":
r"""ReadAsDouble(Attribute self) -> double"""
return _gdal.Attribute_ReadAsDouble(self, *args)
def ReadAsStringArray(self, *args) -> "char **":
r"""ReadAsStringArray(Attribute self) -> char **"""
return _gdal.Attribute_ReadAsStringArray(self, *args)
def ReadAsIntArray(self, *args) -> "void":
r"""ReadAsIntArray(Attribute self)"""
return _gdal.Attribute_ReadAsIntArray(self, *args)
def ReadAsDoubleArray(self, *args) -> "void":
r"""ReadAsDoubleArray(Attribute self)"""
return _gdal.Attribute_ReadAsDoubleArray(self, *args)
def WriteRaw(self, *args) -> "CPLErr":
r"""WriteRaw(Attribute self, GIntBig nLen) -> CPLErr"""
return _gdal.Attribute_WriteRaw(self, *args)
def WriteString(self, *args) -> "CPLErr":
r"""WriteString(Attribute self, char const * val) -> CPLErr"""
return _gdal.Attribute_WriteString(self, *args)
def WriteStringArray(self, *args) -> "CPLErr":
r"""WriteStringArray(Attribute self, char ** vals) -> CPLErr"""
return _gdal.Attribute_WriteStringArray(self, *args)
def WriteInt(self, *args) -> "CPLErr":
r"""WriteInt(Attribute self, int val) -> CPLErr"""
return _gdal.Attribute_WriteInt(self, *args)
def WriteDouble(self, *args) -> "CPLErr":
r"""WriteDouble(Attribute self, double val) -> CPLErr"""
return _gdal.Attribute_WriteDouble(self, *args)
def WriteDoubleArray(self, *args) -> "CPLErr":
r"""WriteDoubleArray(Attribute self, int nList) -> CPLErr"""
return _gdal.Attribute_WriteDoubleArray(self, *args)
def Read(self):
""" Read an attribute and return it with the most appropriate type """
dt = self.GetDataType()
dt_class = dt.GetClass()
if dt_class == GEDTC_STRING:
if self.GetTotalElementsCount() == 1:
s = self.ReadAsString()
if dt.GetSubType() == GEDTST_JSON:
try:
import json
return json.loads(s)
except:
pass
return s
return self.ReadAsStringArray()
if dt_class == GEDTC_NUMERIC:
if dt.GetNumericDataType() in (GDT_Byte, GDT_Int16, GDT_UInt16, GDT_Int32):
if self.GetTotalElementsCount() == 1:
return self.ReadAsInt()
else:
return self.ReadAsIntArray()
else:
if self.GetTotalElementsCount() == 1:
return self.ReadAsDouble()
else:
return self.ReadAsDoubleArray()
return self.ReadAsRaw()
def Write(self, val):
if isinstance(val, (int, type(12345678901234))):
if val >= -0x80000000 and val <= 0x7FFFFFFF:
return self.WriteInt(val)
else:
return self.WriteDouble(val)
if isinstance(val, float):
return self.WriteDouble(val)
if isinstance(val, str) and self.GetDataType().GetClass() != GEDTC_COMPOUND:
return self.WriteString(val)
if isinstance(val, list):
if len(val) == 0:
if self.GetDataType().GetClass() == GEDTC_STRING:
return self.WriteStringArray(val)
else:
return self.WriteDoubleArray(val)
if isinstance(val[0], (int, type(12345678901234), float)):
return self.WriteDoubleArray(val)
if isinstance(val[0], str):
return self.WriteStringArray(val)
if isinstance(val, dict) and self.GetDataType().GetSubType() == GEDTST_JSON:
import json
return self.WriteString(json.dumps(val))
return self.WriteRaw(val)
# Register Attribute in _gdal:
_gdal.Attribute_swigregister(Attribute)
class Dimension(object):
r"""Proxy of C++ GDALDimensionHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_Dimension
def GetName(self, *args) -> "char const *":
r"""GetName(Dimension self) -> char const *"""
return _gdal.Dimension_GetName(self, *args)
def GetFullName(self, *args) -> "char const *":
r"""GetFullName(Dimension self) -> char const *"""
return _gdal.Dimension_GetFullName(self, *args)
def GetType(self, *args) -> "char const *":
r"""GetType(Dimension self) -> char const *"""
return _gdal.Dimension_GetType(self, *args)
def GetDirection(self, *args) -> "char const *":
r"""GetDirection(Dimension self) -> char const *"""
return _gdal.Dimension_GetDirection(self, *args)
def GetSize(self, *args) -> "unsigned long long":
r"""GetSize(Dimension self) -> unsigned long long"""
return _gdal.Dimension_GetSize(self, *args)
def GetIndexingVariable(self, *args) -> "GDALMDArrayHS *":
r"""GetIndexingVariable(Dimension self) -> MDArray"""
return _gdal.Dimension_GetIndexingVariable(self, *args)
def SetIndexingVariable(self, *args) -> "bool":
r"""SetIndexingVariable(Dimension self, MDArray array) -> bool"""
return _gdal.Dimension_SetIndexingVariable(self, *args)
# Register Dimension in _gdal:
_gdal.Dimension_swigregister(Dimension)
GEDTC_NUMERIC = _gdal.GEDTC_NUMERIC
GEDTC_STRING = _gdal.GEDTC_STRING
GEDTC_COMPOUND = _gdal.GEDTC_COMPOUND
class ExtendedDataType(object):
r"""Proxy of C++ GDALExtendedDataTypeHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_ExtendedDataType
@staticmethod
def Create(*args) -> "GDALExtendedDataTypeHS *":
r"""Create(GDALDataType dt) -> ExtendedDataType"""
return _gdal.ExtendedDataType_Create(*args)
@staticmethod
def CreateString(*args) -> "GDALExtendedDataTypeHS *":
r"""CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE) -> ExtendedDataType"""
return _gdal.ExtendedDataType_CreateString(*args)
@staticmethod
def CreateCompound(*args) -> "GDALExtendedDataTypeHS *":
r"""CreateCompound(char const * name, size_t nTotalSize, int nComps) -> ExtendedDataType"""
return _gdal.ExtendedDataType_CreateCompound(*args)
def GetName(self, *args) -> "char const *":
r"""GetName(ExtendedDataType self) -> char const *"""
return _gdal.ExtendedDataType_GetName(self, *args)
def GetClass(self, *args) -> "GDALExtendedDataTypeClass":
r"""GetClass(ExtendedDataType self) -> GDALExtendedDataTypeClass"""
return _gdal.ExtendedDataType_GetClass(self, *args)
def GetNumericDataType(self, *args) -> "GDALDataType":
r"""GetNumericDataType(ExtendedDataType self) -> GDALDataType"""
return _gdal.ExtendedDataType_GetNumericDataType(self, *args)
def GetSize(self, *args) -> "size_t":
r"""GetSize(ExtendedDataType self) -> size_t"""
return _gdal.ExtendedDataType_GetSize(self, *args)
def GetMaxStringLength(self, *args) -> "size_t":
r"""GetMaxStringLength(ExtendedDataType self) -> size_t"""
return _gdal.ExtendedDataType_GetMaxStringLength(self, *args)
def GetSubType(self, *args) -> "GDALExtendedDataTypeSubType":
r"""GetSubType(ExtendedDataType self) -> GDALExtendedDataTypeSubType"""
return _gdal.ExtendedDataType_GetSubType(self, *args)
def GetComponents(self, *args) -> "void":
r"""GetComponents(ExtendedDataType self)"""
return _gdal.ExtendedDataType_GetComponents(self, *args)
def CanConvertTo(self, *args) -> "bool":
r"""CanConvertTo(ExtendedDataType self, ExtendedDataType other) -> bool"""
return _gdal.ExtendedDataType_CanConvertTo(self, *args)
def Equals(self, *args) -> "bool":
r"""Equals(ExtendedDataType self, ExtendedDataType other) -> bool"""
return _gdal.ExtendedDataType_Equals(self, *args)
def __eq__(self, other):
return self.Equals(other)
def __ne__(self, other):
return not self.__eq__(other)
# Register ExtendedDataType in _gdal:
_gdal.ExtendedDataType_swigregister(ExtendedDataType)
def ExtendedDataType_Create(*args) -> "GDALExtendedDataTypeHS *":
r"""ExtendedDataType_Create(GDALDataType dt) -> ExtendedDataType"""
return _gdal.ExtendedDataType_Create(*args)
def ExtendedDataType_CreateString(*args) -> "GDALExtendedDataTypeHS *":
r"""ExtendedDataType_CreateString(size_t nMaxStringLength=0, GDALExtendedDataTypeSubType eSubType=GEDTST_NONE) -> ExtendedDataType"""
return _gdal.ExtendedDataType_CreateString(*args)
def ExtendedDataType_CreateCompound(*args) -> "GDALExtendedDataTypeHS *":
r"""ExtendedDataType_CreateCompound(char const * name, size_t nTotalSize, int nComps) -> ExtendedDataType"""
return _gdal.ExtendedDataType_CreateCompound(*args)
class EDTComponent(object):
r"""Proxy of C++ GDALEDTComponentHS class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_EDTComponent
@staticmethod
def Create(*args) -> "GDALEDTComponentHS *":
r"""Create(char const * name, size_t offset, ExtendedDataType type) -> EDTComponent"""
return _gdal.EDTComponent_Create(*args)
def GetName(self, *args) -> "char const *":
r"""GetName(EDTComponent self) -> char const *"""
return _gdal.EDTComponent_GetName(self, *args)
def GetOffset(self, *args) -> "size_t":
r"""GetOffset(EDTComponent self) -> size_t"""
return _gdal.EDTComponent_GetOffset(self, *args)
def GetType(self, *args) -> "GDALExtendedDataTypeHS *":
r"""GetType(EDTComponent self) -> ExtendedDataType"""
return _gdal.EDTComponent_GetType(self, *args)
# Register EDTComponent in _gdal:
_gdal.EDTComponent_swigregister(EDTComponent)
def EDTComponent_Create(*args) -> "GDALEDTComponentHS *":
r"""EDTComponent_Create(char const * name, size_t offset, ExtendedDataType type) -> EDTComponent"""
return _gdal.EDTComponent_Create(*args)
class Band(MajorObject):
r"""Proxy of C++ GDALRasterBandShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
XSize = property(_gdal.Band_XSize_get, doc=r"""XSize : int""")
YSize = property(_gdal.Band_YSize_get, doc=r"""YSize : int""")
DataType = property(_gdal.Band_DataType_get, doc=r"""DataType : GDALDataType""")
def GetDataset(self, *args) -> "GDALDatasetShadow *":
r"""GetDataset(Band self) -> Dataset"""
return _gdal.Band_GetDataset(self, *args)
def GetBand(self, *args) -> "int":
r"""GetBand(Band self) -> int"""
return _gdal.Band_GetBand(self, *args)
def GetBlockSize(self, *args) -> "void":
r"""GetBlockSize(Band self)"""
return _gdal.Band_GetBlockSize(self, *args)
def GetActualBlockSize(self, *args) -> "void":
r"""GetActualBlockSize(Band self, int nXBlockOff, int nYBlockOff)"""
return _gdal.Band_GetActualBlockSize(self, *args)
def GetColorInterpretation(self, *args) -> "GDALColorInterp":
r"""GetColorInterpretation(Band self) -> GDALColorInterp"""
return _gdal.Band_GetColorInterpretation(self, *args)
def GetRasterColorInterpretation(self, *args) -> "GDALColorInterp":
r"""GetRasterColorInterpretation(Band self) -> GDALColorInterp"""
return _gdal.Band_GetRasterColorInterpretation(self, *args)
def SetColorInterpretation(self, *args) -> "CPLErr":
r"""SetColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
return _gdal.Band_SetColorInterpretation(self, *args)
def SetRasterColorInterpretation(self, *args) -> "CPLErr":
r"""SetRasterColorInterpretation(Band self, GDALColorInterp val) -> CPLErr"""
return _gdal.Band_SetRasterColorInterpretation(self, *args)
def GetNoDataValue(self):
"""GetNoDataValue(Band self) -> value """
if self.DataType == gdalconst.GDT_Int64:
return _gdal.Band_GetNoDataValueAsInt64(self)
if self.DataType == gdalconst.GDT_UInt64:
return _gdal.Band_GetNoDataValueAsUInt64(self)
return _gdal.Band_GetNoDataValue(self)
def GetNoDataValueAsInt64(self, *args) -> "void":
r"""GetNoDataValueAsInt64(Band self)"""
return _gdal.Band_GetNoDataValueAsInt64(self, *args)
def GetNoDataValueAsUInt64(self, *args) -> "void":
r"""GetNoDataValueAsUInt64(Band self)"""
return _gdal.Band_GetNoDataValueAsUInt64(self, *args)
def SetNoDataValue(self, value) -> "CPLErr":
"""SetNoDataValue(Band self, value) -> CPLErr"""
if self.DataType == gdalconst.GDT_Int64:
return _gdal.Band_SetNoDataValueAsInt64(self, value)
if self.DataType == gdalconst.GDT_UInt64:
return _gdal.Band_SetNoDataValueAsUInt64(self, value)
return _gdal.Band_SetNoDataValue(self, value)
def SetNoDataValueAsInt64(self, *args) -> "CPLErr":
r"""SetNoDataValueAsInt64(Band self, GIntBig v) -> CPLErr"""
return _gdal.Band_SetNoDataValueAsInt64(self, *args)
def SetNoDataValueAsUInt64(self, *args) -> "CPLErr":
r"""SetNoDataValueAsUInt64(Band self, GUIntBig v) -> CPLErr"""
return _gdal.Band_SetNoDataValueAsUInt64(self, *args)
def DeleteNoDataValue(self, *args) -> "CPLErr":
r"""DeleteNoDataValue(Band self) -> CPLErr"""
return _gdal.Band_DeleteNoDataValue(self, *args)
def GetUnitType(self, *args) -> "char const *":
r"""GetUnitType(Band self) -> char const *"""
return _gdal.Band_GetUnitType(self, *args)
def SetUnitType(self, *args) -> "CPLErr":
r"""SetUnitType(Band self, char const * val) -> CPLErr"""
return _gdal.Band_SetUnitType(self, *args)
def GetRasterCategoryNames(self, *args) -> "char **":
r"""GetRasterCategoryNames(Band self) -> char **"""
return _gdal.Band_GetRasterCategoryNames(self, *args)
def SetRasterCategoryNames(self, *args) -> "CPLErr":
r"""SetRasterCategoryNames(Band self, char ** names) -> CPLErr"""
return _gdal.Band_SetRasterCategoryNames(self, *args)
def GetMinimum(self, *args) -> "void":
r"""GetMinimum(Band self)"""
return _gdal.Band_GetMinimum(self, *args)
def GetMaximum(self, *args) -> "void":
r"""GetMaximum(Band self)"""
return _gdal.Band_GetMaximum(self, *args)
def GetOffset(self, *args) -> "void":
r"""GetOffset(Band self)"""
return _gdal.Band_GetOffset(self, *args)
def GetScale(self, *args) -> "void":
r"""GetScale(Band self)"""
return _gdal.Band_GetScale(self, *args)
def SetOffset(self, *args) -> "CPLErr":
r"""SetOffset(Band self, double val) -> CPLErr"""
return _gdal.Band_SetOffset(self, *args)
def SetScale(self, *args) -> "CPLErr":
r"""SetScale(Band self, double val) -> CPLErr"""
return _gdal.Band_SetScale(self, *args)
def GetStatistics(self, *args) -> "CPLErr":
r"""GetStatistics(Band self, int approx_ok, int force) -> CPLErr"""
return _gdal.Band_GetStatistics(self, *args)
def ComputeStatistics(self, *args, **kwargs) -> "CPLErr":
"""ComputeStatistics(Band self, bool approx_ok, callback=None, callback_data=None) -> CPLErr"""
if len(args) == 1:
kwargs["approx_ok"] = args[0]
args = ()
if "approx_ok" in kwargs:
# Compatibility with older signature that used int for approx_ok
if kwargs["approx_ok"] == 0:
kwargs["approx_ok"] = False
elif kwargs["approx_ok"] == 1:
kwargs["approx_ok"] = True
elif isinstance(kwargs["approx_ok"], int):
raise Exception("approx_ok value should be 0/1/False/True")
return _gdal.Band_ComputeStatistics(self, *args, **kwargs)
def SetStatistics(self, *args) -> "CPLErr":
r"""SetStatistics(Band self, double min, double max, double mean, double stddev) -> CPLErr"""
return _gdal.Band_SetStatistics(self, *args)
def GetOverviewCount(self, *args) -> "int":
r"""GetOverviewCount(Band self) -> int"""
return _gdal.Band_GetOverviewCount(self, *args)
def GetOverview(self, *args) -> "GDALRasterBandShadow *":
r"""GetOverview(Band self, int i) -> Band"""
return _gdal.Band_GetOverview(self, *args)
def Checksum(self, *args, **kwargs) -> "int":
r"""Checksum(Band self, int xoff=0, int yoff=0, int * xsize=None, int * ysize=None) -> int"""
return _gdal.Band_Checksum(self, *args, **kwargs)
def ComputeRasterMinMax(self, *args, **kwargs):
"""ComputeRasterMinMax(Band self, bool approx_ok=False, bool can_return_none=False) -> (min, max) or None"""
if len(args) == 1:
kwargs["approx_ok"] = args[0]
args = ()
if "approx_ok" in kwargs:
# Compatibility with older signature that used int for approx_ok
if kwargs["approx_ok"] == 0:
kwargs["approx_ok"] = False
elif kwargs["approx_ok"] == 1:
kwargs["approx_ok"] = True
elif isinstance(kwargs["approx_ok"], int):
raise Exception("approx_ok value should be 0/1/False/True")
# can_return_null is used in other methods
if "can_return_null" in kwargs:
kwargs["can_return_none"] = kwargs["can_return_null"];
del kwargs["can_return_null"]
return _gdal.Band_ComputeRasterMinMax(self, *args, **kwargs)
def ComputeBandStats(self, *args) -> "void":
r"""ComputeBandStats(Band self, int samplestep=1)"""
return _gdal.Band_ComputeBandStats(self, *args)
def Fill(self, *args) -> "CPLErr":
r"""Fill(Band self, double real_fill, double imag_fill=0.0) -> CPLErr"""
return _gdal.Band_Fill(self, *args)
def WriteRaster(self, *args, **kwargs) -> "CPLErr":
r"""WriteRaster(Band self, int xoff, int yoff, int xsize, int ysize, GIntBig buf_len, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None) -> CPLErr"""
return _gdal.Band_WriteRaster(self, *args, **kwargs)
def FlushCache(self, *args) -> "void":
r"""FlushCache(Band self)"""
return _gdal.Band_FlushCache(self, *args)
def GetRasterColorTable(self, *args) -> "GDALColorTableShadow *":
r"""GetRasterColorTable(Band self) -> ColorTable"""
return _gdal.Band_GetRasterColorTable(self, *args)
def GetColorTable(self, *args) -> "GDALColorTableShadow *":
r"""GetColorTable(Band self) -> ColorTable"""
return _gdal.Band_GetColorTable(self, *args)
def SetRasterColorTable(self, *args) -> "int":
r"""SetRasterColorTable(Band self, ColorTable arg) -> int"""
return _gdal.Band_SetRasterColorTable(self, *args)
def SetColorTable(self, *args) -> "int":
r"""SetColorTable(Band self, ColorTable arg) -> int"""
return _gdal.Band_SetColorTable(self, *args)
def GetDefaultRAT(self, *args) -> "GDALRasterAttributeTableShadow *":
r"""GetDefaultRAT(Band self) -> RasterAttributeTable"""
return _gdal.Band_GetDefaultRAT(self, *args)
def SetDefaultRAT(self, *args) -> "int":
r"""SetDefaultRAT(Band self, RasterAttributeTable table) -> int"""
return _gdal.Band_SetDefaultRAT(self, *args)
def GetMaskBand(self, *args) -> "GDALRasterBandShadow *":
r"""GetMaskBand(Band self) -> Band"""
return _gdal.Band_GetMaskBand(self, *args)
def GetMaskFlags(self, *args) -> "int":
r"""GetMaskFlags(Band self) -> int"""
return _gdal.Band_GetMaskFlags(self, *args)
def CreateMaskBand(self, *args) -> "CPLErr":
r"""CreateMaskBand(Band self, int nFlags) -> CPLErr"""
return _gdal.Band_CreateMaskBand(self, *args)
def IsMaskBand(self, *args) -> "bool":
r"""IsMaskBand(Band self) -> bool"""
return _gdal.Band_IsMaskBand(self, *args)
def GetHistogram(self, *args, **kwargs) -> "CPLErr":
r"""GetHistogram(Band self, double min=-0.5, double max=255.5, int buckets=256, int include_out_of_range=0, int approx_ok=1, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
return _gdal.Band_GetHistogram(self, *args, **kwargs)
def GetDefaultHistogram(self, *args, **kwargs) -> "CPLErr":
r"""GetDefaultHistogram(Band self, double * min_ret=None, double * max_ret=None, int * buckets_ret=None, GUIntBig ** ppanHistogram=None, int force=1, GDALProgressFunc callback=0, void * callback_data=None) -> CPLErr"""
return _gdal.Band_GetDefaultHistogram(self, *args, **kwargs)
def SetDefaultHistogram(self, *args) -> "CPLErr":
r"""SetDefaultHistogram(Band self, double min, double max, int buckets_in) -> CPLErr"""
return _gdal.Band_SetDefaultHistogram(self, *args)
def HasArbitraryOverviews(self, *args) -> "bool":
r"""HasArbitraryOverviews(Band self) -> bool"""
return _gdal.Band_HasArbitraryOverviews(self, *args)
def GetCategoryNames(self, *args) -> "char **":
r"""GetCategoryNames(Band self) -> char **"""
return _gdal.Band_GetCategoryNames(self, *args)
def SetCategoryNames(self, *args) -> "CPLErr":
r"""SetCategoryNames(Band self, char ** papszCategoryNames) -> CPLErr"""
return _gdal.Band_SetCategoryNames(self, *args)
def GetVirtualMem(self, *args, **kwargs) -> "CPLVirtualMemShadow *":
r"""GetVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nBufXSize, int nBufYSize, GDALDataType eBufType, size_t nCacheSize, size_t nPageSizeHint, char ** options=None) -> VirtualMem"""
return _gdal.Band_GetVirtualMem(self, *args, **kwargs)
def GetVirtualMemAuto(self, *args, **kwargs) -> "CPLVirtualMemShadow *":
r"""GetVirtualMemAuto(Band self, GDALRWFlag eRWFlag, char ** options=None) -> VirtualMem"""
return _gdal.Band_GetVirtualMemAuto(self, *args, **kwargs)
def GetTiledVirtualMem(self, *args, **kwargs) -> "CPLVirtualMemShadow *":
r"""GetTiledVirtualMem(Band self, GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, int nYSize, int nTileXSize, int nTileYSize, GDALDataType eBufType, size_t nCacheSize, char ** options=None) -> VirtualMem"""
return _gdal.Band_GetTiledVirtualMem(self, *args, **kwargs)
def GetDataCoverageStatus(self, *args) -> "int":
r"""GetDataCoverageStatus(Band self, int nXOff, int nYOff, int nXSize, int nYSize, int nMaskFlagStop=0) -> int"""
return _gdal.Band_GetDataCoverageStatus(self, *args)
def AdviseRead(self, *args) -> "CPLErr":
r"""AdviseRead(Band self, int xoff, int yoff, int xsize, int ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, char ** options=None) -> CPLErr"""
return _gdal.Band_AdviseRead(self, *args)
def AsMDArray(self, *args) -> "GDALMDArrayHS *":
r"""AsMDArray(Band self) -> MDArray"""
return _gdal.Band_AsMDArray(self, *args)
def ReadRaster1(self, *args, **kwargs) -> "CPLErr":
r"""ReadRaster1(Band self, double xoff, double yoff, double xsize, double ysize, int * buf_xsize=None, int * buf_ysize=None, GDALDataType * buf_type=None, GIntBig * buf_pixel_space=None, GIntBig * buf_line_space=None, GDALRIOResampleAlg resample_alg=GRIORA_NearestNeighbour, GDALProgressFunc callback=0, void * callback_data=None, void * inputOutputBuf=None) -> CPLErr"""
return _gdal.Band_ReadRaster1(self, *args, **kwargs)
def ReadBlock(self, *args, **kwargs) -> "CPLErr":
r"""ReadBlock(Band self, int xoff, int yoff, void * buf_obj=None) -> CPLErr"""
return _gdal.Band_ReadBlock(self, *args, **kwargs)
def ReadRaster(self, xoff=0, yoff=0, xsize=None, ysize=None,
buf_xsize=None, buf_ysize=None, buf_type=None,
buf_pixel_space=None, buf_line_space=None,
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None,
buf_obj=None):
if xsize is None:
xsize = self.XSize
if ysize is None:
ysize = self.YSize
return _gdal.Band_ReadRaster1(self, xoff, yoff, xsize, ysize,
buf_xsize, buf_ysize, buf_type,
buf_pixel_space, buf_line_space,
resample_alg, callback, callback_data,
buf_obj)
def WriteRaster(self, xoff, yoff, xsize, ysize,
buf_string,
buf_xsize=None, buf_ysize=None, buf_type=None,
buf_pixel_space=None, buf_line_space=None ):
if buf_xsize is None:
buf_xsize = xsize
if buf_ysize is None:
buf_ysize = ysize
# Redirect to numpy-friendly WriteArray() if buf_string is a numpy array
# and other arguments are compatible
if type(buf_string).__name__ == 'ndarray' and \
buf_xsize == xsize and buf_ysize == ysize and buf_type is None and \
buf_pixel_space is None and buf_line_space is None:
return self.WriteArray(buf_string, xoff=xoff, yoff=yoff)
if buf_type is None:
buf_type = self.DataType
return _gdal.Band_WriteRaster(self,
xoff, yoff, xsize, ysize,
buf_string, buf_xsize, buf_ysize, buf_type,
buf_pixel_space, buf_line_space )
def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,
buf_xsize=None, buf_ysize=None, buf_type=None, buf_obj=None,
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None):
""" Reading a chunk of a GDAL band into a numpy array. The optional (buf_xsize,buf_ysize,buf_type)
parameters should generally not be specified if buf_obj is specified. The array is returned"""
from osgeo import gdal_array
return gdal_array.BandReadAsArray(self, xoff, yoff,
win_xsize, win_ysize,
buf_xsize, buf_ysize, buf_type, buf_obj,
resample_alg=resample_alg,
callback=callback,
callback_data=callback_data)
def WriteArray(self, array, xoff=0, yoff=0,
resample_alg=gdalconst.GRIORA_NearestNeighbour,
callback=None,
callback_data=None):
from osgeo import gdal_array
return gdal_array.BandWriteArray(self, array, xoff, yoff,
resample_alg=resample_alg,
callback=callback,
callback_data=callback_data)
def GetVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
xsize=None, ysize=None, bufxsize=None, bufysize=None,
datatype=None,
cache_size = 10 * 1024 * 1024, page_size_hint = 0,
options=None):
"""Return a NumPy array for the band, seen as a virtual memory mapping.
An element is accessed with array[y][x].
Any reference to the array must be dropped before the last reference to the
related dataset is also dropped.
"""
from osgeo import gdal_array
if xsize is None:
xsize = self.XSize
if ysize is None:
ysize = self.YSize
if bufxsize is None:
bufxsize = self.XSize
if bufysize is None:
bufysize = self.YSize
if datatype is None:
datatype = self.DataType
if options is None:
virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint)
else:
virtualmem = self.GetVirtualMem(eAccess, xoff, yoff, xsize, ysize, bufxsize, bufysize, datatype, cache_size, page_size_hint, options)
return gdal_array.VirtualMemGetArray(virtualmem)
def GetVirtualMemAutoArray(self, eAccess=gdalconst.GF_Read, options=None):
"""Return a NumPy array for the band, seen as a virtual memory mapping.
An element is accessed with array[y][x].
Any reference to the array must be dropped before the last reference to the
related dataset is also dropped.
"""
from osgeo import gdal_array
if options is None:
virtualmem = self.GetVirtualMemAuto(eAccess)
else:
virtualmem = self.GetVirtualMemAuto(eAccess, options)
return gdal_array.VirtualMemGetArray( virtualmem )
def GetTiledVirtualMemArray(self, eAccess=gdalconst.GF_Read, xoff=0, yoff=0,
xsize=None, ysize=None, tilexsize=256, tileysize=256,
datatype=None,
cache_size = 10 * 1024 * 1024, options=None):
"""Return a NumPy array for the band, seen as a virtual memory mapping with
a tile organization.
An element is accessed with array[tiley][tilex][y][x].
Any reference to the array must be dropped before the last reference to the
related dataset is also dropped.
"""
from osgeo import gdal_array
if xsize is None:
xsize = self.XSize
if ysize is None:
ysize = self.YSize
if datatype is None:
datatype = self.DataType
if options is None:
virtualmem = self.GetTiledVirtualMem(eAccess, xoff, yoff, xsize, ysize, tilexsize, tileysize, datatype, cache_size)
else:
virtualmem = self.GetTiledVirtualMem(eAccess, xoff, yoff, xsize, ysize, tilexsize, tileysize, datatype, cache_size, options)
return gdal_array.VirtualMemGetArray( virtualmem )
# Register Band in _gdal:
_gdal.Band_swigregister(Band)
class ColorTable(object):
r"""Proxy of C++ GDALColorTableShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
r"""__init__(ColorTable self, GDALPaletteInterp palette=GPI_RGB) -> ColorTable"""
_gdal.ColorTable_swiginit(self, _gdal.new_ColorTable(*args, **kwargs))
__swig_destroy__ = _gdal.delete_ColorTable
def Clone(self, *args) -> "GDALColorTableShadow *":
r"""Clone(ColorTable self) -> ColorTable"""
return _gdal.ColorTable_Clone(self, *args)
def GetPaletteInterpretation(self, *args) -> "GDALPaletteInterp":
r"""GetPaletteInterpretation(ColorTable self) -> GDALPaletteInterp"""
return _gdal.ColorTable_GetPaletteInterpretation(self, *args)
def GetCount(self, *args) -> "int":
r"""GetCount(ColorTable self) -> int"""
return _gdal.ColorTable_GetCount(self, *args)
def GetColorEntry(self, *args) -> "GDALColorEntry *":
r"""GetColorEntry(ColorTable self, int entry) -> ColorEntry"""
return _gdal.ColorTable_GetColorEntry(self, *args)
def GetColorEntryAsRGB(self, *args) -> "int":
r"""GetColorEntryAsRGB(ColorTable self, int entry, ColorEntry centry) -> int"""
return _gdal.ColorTable_GetColorEntryAsRGB(self, *args)
def SetColorEntry(self, *args) -> "void":
r"""SetColorEntry(ColorTable self, int entry, ColorEntry centry)"""
return _gdal.ColorTable_SetColorEntry(self, *args)
def CreateColorRamp(self, *args) -> "void":
r"""CreateColorRamp(ColorTable self, int nStartIndex, ColorEntry startcolor, int nEndIndex, ColorEntry endcolor)"""
return _gdal.ColorTable_CreateColorRamp(self, *args)
# Register ColorTable in _gdal:
_gdal.ColorTable_swigregister(ColorTable)
class RasterAttributeTable(object):
r"""Proxy of C++ GDALRasterAttributeTableShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(RasterAttributeTable self) -> RasterAttributeTable"""
_gdal.RasterAttributeTable_swiginit(self, _gdal.new_RasterAttributeTable(*args))
__swig_destroy__ = _gdal.delete_RasterAttributeTable
def Clone(self, *args) -> "GDALRasterAttributeTableShadow *":
r"""Clone(RasterAttributeTable self) -> RasterAttributeTable"""
return _gdal.RasterAttributeTable_Clone(self, *args)
def GetColumnCount(self, *args) -> "int":
r"""GetColumnCount(RasterAttributeTable self) -> int"""
return _gdal.RasterAttributeTable_GetColumnCount(self, *args)
def GetNameOfCol(self, *args) -> "char const *":
r"""GetNameOfCol(RasterAttributeTable self, int iCol) -> char const *"""
return _gdal.RasterAttributeTable_GetNameOfCol(self, *args)
def GetUsageOfCol(self, *args) -> "GDALRATFieldUsage":
r"""GetUsageOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldUsage"""
return _gdal.RasterAttributeTable_GetUsageOfCol(self, *args)
def GetTypeOfCol(self, *args) -> "GDALRATFieldType":
r"""GetTypeOfCol(RasterAttributeTable self, int iCol) -> GDALRATFieldType"""
return _gdal.RasterAttributeTable_GetTypeOfCol(self, *args)
def GetColOfUsage(self, *args) -> "int":
r"""GetColOfUsage(RasterAttributeTable self, GDALRATFieldUsage eUsage) -> int"""
return _gdal.RasterAttributeTable_GetColOfUsage(self, *args)
def GetRowCount(self, *args) -> "int":
r"""GetRowCount(RasterAttributeTable self) -> int"""
return _gdal.RasterAttributeTable_GetRowCount(self, *args)
def GetValueAsString(self, *args) -> "char const *":
r"""GetValueAsString(RasterAttributeTable self, int iRow, int iCol) -> char const *"""
return _gdal.RasterAttributeTable_GetValueAsString(self, *args)
def GetValueAsInt(self, *args) -> "int":
r"""GetValueAsInt(RasterAttributeTable self, int iRow, int iCol) -> int"""
return _gdal.RasterAttributeTable_GetValueAsInt(self, *args)
def GetValueAsDouble(self, *args) -> "double":
r"""GetValueAsDouble(RasterAttributeTable self, int iRow, int iCol) -> double"""
return _gdal.RasterAttributeTable_GetValueAsDouble(self, *args)
def SetValueAsString(self, *args) -> "void":
r"""SetValueAsString(RasterAttributeTable self, int iRow, int iCol, char const * pszValue)"""
return _gdal.RasterAttributeTable_SetValueAsString(self, *args)
def SetValueAsInt(self, *args) -> "void":
r"""SetValueAsInt(RasterAttributeTable self, int iRow, int iCol, int nValue)"""
return _gdal.RasterAttributeTable_SetValueAsInt(self, *args)
def SetValueAsDouble(self, *args) -> "void":
r"""SetValueAsDouble(RasterAttributeTable self, int iRow, int iCol, double dfValue)"""
return _gdal.RasterAttributeTable_SetValueAsDouble(self, *args)
def SetRowCount(self, *args) -> "void":
r"""SetRowCount(RasterAttributeTable self, int nCount)"""
return _gdal.RasterAttributeTable_SetRowCount(self, *args)
def CreateColumn(self, *args) -> "int":
r"""CreateColumn(RasterAttributeTable self, char const * pszName, GDALRATFieldType eType, GDALRATFieldUsage eUsage) -> int"""
return _gdal.RasterAttributeTable_CreateColumn(self, *args)
def GetLinearBinning(self, *args) -> "bool":
r"""GetLinearBinning(RasterAttributeTable self) -> bool"""
return _gdal.RasterAttributeTable_GetLinearBinning(self, *args)
def SetLinearBinning(self, *args) -> "int":
r"""SetLinearBinning(RasterAttributeTable self, double dfRow0Min, double dfBinSize) -> int"""
return _gdal.RasterAttributeTable_SetLinearBinning(self, *args)
def GetRowOfValue(self, *args) -> "int":
r"""GetRowOfValue(RasterAttributeTable self, double dfValue) -> int"""
return _gdal.RasterAttributeTable_GetRowOfValue(self, *args)
def ChangesAreWrittenToFile(self, *args) -> "int":
r"""ChangesAreWrittenToFile(RasterAttributeTable self) -> int"""
return _gdal.RasterAttributeTable_ChangesAreWrittenToFile(self, *args)
def DumpReadable(self, *args) -> "void":
r"""DumpReadable(RasterAttributeTable self)"""
return _gdal.RasterAttributeTable_DumpReadable(self, *args)
def SetTableType(self, *args) -> "void":
r"""SetTableType(RasterAttributeTable self, GDALRATTableType eTableType)"""
return _gdal.RasterAttributeTable_SetTableType(self, *args)
def GetTableType(self, *args) -> "GDALRATTableType":
r"""GetTableType(RasterAttributeTable self) -> GDALRATTableType"""
return _gdal.RasterAttributeTable_GetTableType(self, *args)
def WriteArray(self, array, field, start=0):
from osgeo import gdal_array
return gdal_array.RATWriteArray(self, array, field, start)
def ReadAsArray(self, field, start=0, length=None):
from osgeo import gdal_array
return gdal_array.RATReadArray(self, field, start, length)
# Register RasterAttributeTable in _gdal:
_gdal.RasterAttributeTable_swigregister(RasterAttributeTable)
class Relationship(object):
r"""Proxy of C++ GDALRelationshipShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(Relationship self, char const * name, char const * leftTableName, char const * rightTableName, GDALRelationshipCardinality cardinality) -> Relationship"""
_gdal.Relationship_swiginit(self, _gdal.new_Relationship(*args))
__swig_destroy__ = _gdal.delete_Relationship
def GetName(self, *args) -> "char const *":
r"""GetName(Relationship self) -> char const *"""
return _gdal.Relationship_GetName(self, *args)
def GetCardinality(self, *args) -> "GDALRelationshipCardinality":
r"""GetCardinality(Relationship self) -> GDALRelationshipCardinality"""
return _gdal.Relationship_GetCardinality(self, *args)
def GetLeftTableName(self, *args) -> "char const *":
r"""GetLeftTableName(Relationship self) -> char const *"""
return _gdal.Relationship_GetLeftTableName(self, *args)
def GetRightTableName(self, *args) -> "char const *":
r"""GetRightTableName(Relationship self) -> char const *"""
return _gdal.Relationship_GetRightTableName(self, *args)
def GetMappingTableName(self, *args) -> "char const *":
r"""GetMappingTableName(Relationship self) -> char const *"""
return _gdal.Relationship_GetMappingTableName(self, *args)
def SetMappingTableName(self, *args) -> "void":
r"""SetMappingTableName(Relationship self, char const * pszName)"""
return _gdal.Relationship_SetMappingTableName(self, *args)
def GetLeftTableFields(self, *args) -> "char **":
r"""GetLeftTableFields(Relationship self) -> char **"""
return _gdal.Relationship_GetLeftTableFields(self, *args)
def GetRightTableFields(self, *args) -> "char **":
r"""GetRightTableFields(Relationship self) -> char **"""
return _gdal.Relationship_GetRightTableFields(self, *args)
def SetLeftTableFields(self, *args) -> "void":
r"""SetLeftTableFields(Relationship self, char ** pFields)"""
return _gdal.Relationship_SetLeftTableFields(self, *args)
def SetRightTableFields(self, *args) -> "void":
r"""SetRightTableFields(Relationship self, char ** pFields)"""
return _gdal.Relationship_SetRightTableFields(self, *args)
def GetLeftMappingTableFields(self, *args) -> "char **":
r"""GetLeftMappingTableFields(Relationship self) -> char **"""
return _gdal.Relationship_GetLeftMappingTableFields(self, *args)
def GetRightMappingTableFields(self, *args) -> "char **":
r"""GetRightMappingTableFields(Relationship self) -> char **"""
return _gdal.Relationship_GetRightMappingTableFields(self, *args)
def SetLeftMappingTableFields(self, *args) -> "void":
r"""SetLeftMappingTableFields(Relationship self, char ** pFields)"""
return _gdal.Relationship_SetLeftMappingTableFields(self, *args)
def SetRightMappingTableFields(self, *args) -> "void":
r"""SetRightMappingTableFields(Relationship self, char ** pFields)"""
return _gdal.Relationship_SetRightMappingTableFields(self, *args)
def GetType(self, *args) -> "GDALRelationshipType":
r"""GetType(Relationship self) -> GDALRelationshipType"""
return _gdal.Relationship_GetType(self, *args)
def SetType(self, *args) -> "void":
r"""SetType(Relationship self, GDALRelationshipType type)"""
return _gdal.Relationship_SetType(self, *args)
def GetForwardPathLabel(self, *args) -> "char const *":
r"""GetForwardPathLabel(Relationship self) -> char const *"""
return _gdal.Relationship_GetForwardPathLabel(self, *args)
def SetForwardPathLabel(self, *args) -> "void":
r"""SetForwardPathLabel(Relationship self, char const * pszLabel)"""
return _gdal.Relationship_SetForwardPathLabel(self, *args)
def GetBackwardPathLabel(self, *args) -> "char const *":
r"""GetBackwardPathLabel(Relationship self) -> char const *"""
return _gdal.Relationship_GetBackwardPathLabel(self, *args)
def SetBackwardPathLabel(self, *args) -> "void":
r"""SetBackwardPathLabel(Relationship self, char const * pszLabel)"""
return _gdal.Relationship_SetBackwardPathLabel(self, *args)
def GetRelatedTableType(self, *args) -> "char const *":
r"""GetRelatedTableType(Relationship self) -> char const *"""
return _gdal.Relationship_GetRelatedTableType(self, *args)
def SetRelatedTableType(self, *args) -> "void":
r"""SetRelatedTableType(Relationship self, char const * pszType)"""
return _gdal.Relationship_SetRelatedTableType(self, *args)
# Register Relationship in _gdal:
_gdal.Relationship_swigregister(Relationship)
def TermProgress_nocb(*args, **kwargs) -> "int":
r"""TermProgress_nocb(double dfProgress, char const * pszMessage=None, void * pData=None) -> int"""
return _gdal.TermProgress_nocb(*args, **kwargs)
TermProgress = _gdal.TermProgress
def ComputeMedianCutPCT(*args, **kwargs) -> "int":
r"""ComputeMedianCutPCT(Band red, Band green, Band blue, int num_colors, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.ComputeMedianCutPCT(*args, **kwargs)
def DitherRGB2PCT(*args, **kwargs) -> "int":
r"""DitherRGB2PCT(Band red, Band green, Band blue, Band target, ColorTable colors, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.DitherRGB2PCT(*args, **kwargs)
def ReprojectImage(*args, **kwargs) -> "CPLErr":
r"""ReprojectImage(Dataset src_ds, Dataset dst_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double WarpMemoryLimit=0.0, double maxerror=0.0, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> CPLErr"""
return _gdal.ReprojectImage(*args, **kwargs)
def ComputeProximity(*args, **kwargs) -> "int":
r"""ComputeProximity(Band srcBand, Band proximityBand, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.ComputeProximity(*args, **kwargs)
def RasterizeLayer(*args, **kwargs) -> "int":
r"""RasterizeLayer(Dataset dataset, int bands, Layer layer, void * pfnTransformer=None, void * pTransformArg=None, int burn_values=0, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.RasterizeLayer(*args, **kwargs)
def Polygonize(*args, **kwargs) -> "int":
r"""Polygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.Polygonize(*args, **kwargs)
def FPolygonize(*args, **kwargs) -> "int":
r"""FPolygonize(Band srcBand, Band maskBand, Layer outLayer, int iPixValField, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.FPolygonize(*args, **kwargs)
def FillNodata(*args, **kwargs) -> "int":
r"""FillNodata(Band targetBand, Band maskBand, double maxSearchDist, int smoothingIterations, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.FillNodata(*args, **kwargs)
def SieveFilter(*args, **kwargs) -> "int":
r"""SieveFilter(Band srcBand, Band maskBand, Band dstBand, int threshold, int connectedness=4, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.SieveFilter(*args, **kwargs)
def RegenerateOverviews(*args, **kwargs) -> "int":
r"""RegenerateOverviews(Band srcBand, int overviewBandCount, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.RegenerateOverviews(*args, **kwargs)
def RegenerateOverview(*args, **kwargs) -> "int":
r"""RegenerateOverview(Band srcBand, Band overviewBand, char const * resampling="average", GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.RegenerateOverview(*args, **kwargs)
def ContourGenerate(*args, **kwargs) -> "int":
r"""ContourGenerate(Band srcBand, double contourInterval, double contourBase, int fixedLevelCount, int useNoData, double noDataValue, Layer dstLayer, int idField, int elevField, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.ContourGenerate(*args, **kwargs)
def ContourGenerateEx(*args, **kwargs) -> "int":
r"""ContourGenerateEx(Band srcBand, Layer dstLayer, char ** options=None, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.ContourGenerateEx(*args, **kwargs)
GVM_Diagonal = _gdal.GVM_Diagonal
GVM_Edge = _gdal.GVM_Edge
GVM_Max = _gdal.GVM_Max
GVM_Min = _gdal.GVM_Min
GVOT_NORMAL = _gdal.GVOT_NORMAL
GVOT_MIN_TARGET_HEIGHT_FROM_DEM = _gdal.GVOT_MIN_TARGET_HEIGHT_FROM_DEM
GVOT_MIN_TARGET_HEIGHT_FROM_GROUND = _gdal.GVOT_MIN_TARGET_HEIGHT_FROM_GROUND
def ViewshedGenerate(*args, **kwargs) -> "GDALDatasetShadow *":
r"""ViewshedGenerate(Band srcBand, char const * driverName, char const * targetRasterName, char ** creationOptions, double observerX, double observerY, double observerHeight, double targetHeight, double visibleVal, double invisibleVal, double outOfRangeVal, double noDataVal, double dfCurvCoeff, GDALViewshedMode mode, double maxDistance, GDALProgressFunc callback=0, void * callback_data=None, GDALViewshedOutputType heightMode=GVOT_NORMAL, char ** options=None) -> Dataset"""
return _gdal.ViewshedGenerate(*args, **kwargs)
def AutoCreateWarpedVRT(*args) -> "GDALDatasetShadow *":
r"""AutoCreateWarpedVRT(Dataset src_ds, char const * src_wkt=None, char const * dst_wkt=None, GDALResampleAlg eResampleAlg=GRA_NearestNeighbour, double maxerror=0.0) -> Dataset"""
return _gdal.AutoCreateWarpedVRT(*args)
def CreatePansharpenedVRT(*args) -> "GDALDatasetShadow *":
r"""CreatePansharpenedVRT(char const * pszXML, Band panchroBand, int nInputSpectralBands) -> Dataset"""
return _gdal.CreatePansharpenedVRT(*args)
class GDALTransformerInfoShadow(object):
r"""Proxy of C++ GDALTransformerInfoShadow class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
def __init__(self, *args, **kwargs):
raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_destroy__ = _gdal.delete_GDALTransformerInfoShadow
def TransformPoint(self, *args) -> "int":
r"""
TransformPoint(GDALTransformerInfoShadow self, int bDstToSrc, double [3] inout) -> int
TransformPoint(GDALTransformerInfoShadow self, int bDstToSrc, double x, double y, double z=0.0) -> int
"""
return _gdal.GDALTransformerInfoShadow_TransformPoint(self, *args)
def TransformPoints(self, *args) -> "int":
r"""TransformPoints(GDALTransformerInfoShadow self, int bDstToSrc, int nCount) -> int"""
return _gdal.GDALTransformerInfoShadow_TransformPoints(self, *args)
def TransformGeolocations(self, *args, **kwargs) -> "int":
r"""TransformGeolocations(GDALTransformerInfoShadow self, Band xBand, Band yBand, Band zBand, GDALProgressFunc callback=0, void * callback_data=None, char ** options=None) -> int"""
return _gdal.GDALTransformerInfoShadow_TransformGeolocations(self, *args, **kwargs)
# Register GDALTransformerInfoShadow in _gdal:
_gdal.GDALTransformerInfoShadow_swigregister(GDALTransformerInfoShadow)
def Transformer(*args) -> "GDALTransformerInfoShadow *":
r"""Transformer(Dataset src, Dataset dst, char ** options) -> GDALTransformerInfoShadow"""
return _gdal.Transformer(*args)
def _ApplyVerticalShiftGrid(*args, **kwargs) -> "GDALDatasetShadow *":
r"""_ApplyVerticalShiftGrid(Dataset src_ds, Dataset grid_ds, bool inverse=False, double srcUnitToMeter=1.0, double dstUnitToMeter=1.0, char ** options=None) -> Dataset"""
return _gdal._ApplyVerticalShiftGrid(*args, **kwargs)
def ApplyGeoTransform(*args) -> "double *, double *":
r"""ApplyGeoTransform(double [6] padfGeoTransform, double dfPixel, double dfLine)"""
return _gdal.ApplyGeoTransform(*args)
def InvGeoTransform(*args) -> "double [6]":
r"""InvGeoTransform(double [6] gt_in) -> RETURN_NONE"""
return _gdal.InvGeoTransform(*args)
def VersionInfo(*args) -> "char const *":
r"""VersionInfo(char const * request="VERSION_NUM") -> char const *"""
return _gdal.VersionInfo(*args)
def AllRegister(*args) -> "void":
r"""AllRegister()"""
return _gdal.AllRegister(*args)
def GDALDestroyDriverManager(*args) -> "void":
r"""GDALDestroyDriverManager()"""
return _gdal.GDALDestroyDriverManager(*args)
def GetCacheMax(*args) -> "GIntBig":
r"""GetCacheMax() -> GIntBig"""
return _gdal.GetCacheMax(*args)
def GetCacheUsed(*args) -> "GIntBig":
r"""GetCacheUsed() -> GIntBig"""
return _gdal.GetCacheUsed(*args)
def SetCacheMax(*args) -> "void":
r"""SetCacheMax(GIntBig nBytes)"""
return _gdal.SetCacheMax(*args)
def GetDataTypeSize(*args) -> "int":
r"""GetDataTypeSize(GDALDataType eDataType) -> int"""
return _gdal.GetDataTypeSize(*args)
def DataTypeIsComplex(*args) -> "int":
r"""DataTypeIsComplex(GDALDataType eDataType) -> int"""
return _gdal.DataTypeIsComplex(*args)
def GetDataTypeName(*args) -> "char const *":
r"""GetDataTypeName(GDALDataType eDataType) -> char const *"""
return _gdal.GetDataTypeName(*args)
def GetDataTypeByName(*args) -> "GDALDataType":
r"""GetDataTypeByName(char const * pszDataTypeName) -> GDALDataType"""
return _gdal.GetDataTypeByName(*args)
def DataTypeUnion(*args) -> "GDALDataType":
r"""DataTypeUnion(GDALDataType a, GDALDataType b) -> GDALDataType"""
return _gdal.DataTypeUnion(*args)
def GetColorInterpretationName(*args) -> "char const *":
r"""GetColorInterpretationName(GDALColorInterp eColorInterp) -> char const *"""
return _gdal.GetColorInterpretationName(*args)
def GetPaletteInterpretationName(*args) -> "char const *":
r"""GetPaletteInterpretationName(GDALPaletteInterp ePaletteInterp) -> char const *"""
return _gdal.GetPaletteInterpretationName(*args)
def DecToDMS(*args) -> "char const *":
r"""DecToDMS(double arg1, char const * arg2, int arg3=2) -> char const *"""
return _gdal.DecToDMS(*args)
def PackedDMSToDec(*args) -> "double":
r"""PackedDMSToDec(double dfPacked) -> double"""
return _gdal.PackedDMSToDec(*args)
def DecToPackedDMS(*args) -> "double":
r"""DecToPackedDMS(double dfDec) -> double"""
return _gdal.DecToPackedDMS(*args)
def ParseXMLString(*args) -> "CPLXMLNode *":
r"""ParseXMLString(char * pszXMLString) -> CPLXMLNode *"""
return _gdal.ParseXMLString(*args)
def SerializeXMLTree(*args) -> "retStringAndCPLFree *":
r"""SerializeXMLTree(CPLXMLNode * xmlnode) -> retStringAndCPLFree *"""
return _gdal.SerializeXMLTree(*args)
def GetJPEG2000Structure(*args) -> "CPLXMLNode *":
r"""GetJPEG2000Structure(char const * pszFilename, char ** options=None) -> CPLXMLNode *"""
return _gdal.GetJPEG2000Structure(*args)
def GetJPEG2000StructureAsString(*args) -> "retStringAndCPLFree *":
r"""GetJPEG2000StructureAsString(char const * pszFilename, char ** options=None) -> retStringAndCPLFree *"""
return _gdal.GetJPEG2000StructureAsString(*args)
def GetDriverCount(*args) -> "int":
r"""GetDriverCount() -> int"""
return _gdal.GetDriverCount(*args)
def GetDriverByName(*args) -> "GDALDriverShadow *":
r"""GetDriverByName(char const * name) -> Driver"""
return _gdal.GetDriverByName(*args)
def GetDriver(*args) -> "GDALDriverShadow *":
r"""GetDriver(int i) -> Driver"""
return _gdal.GetDriver(*args)
def Open(*args) -> "GDALDatasetShadow *":
r"""Open(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) -> Dataset"""
return _gdal.Open(*args)
def OpenEx(*args, **kwargs) -> "GDALDatasetShadow *":
r"""OpenEx(char const * utf8_path, unsigned int nOpenFlags=0, char ** allowed_drivers=None, char ** open_options=None, char ** sibling_files=None) -> Dataset"""
return _gdal.OpenEx(*args, **kwargs)
def OpenShared(*args) -> "GDALDatasetShadow *":
r"""OpenShared(char const * utf8_path, GDALAccess eAccess=GA_ReadOnly) -> Dataset"""
return _gdal.OpenShared(*args)
def IdentifyDriver(*args) -> "GDALDriverShadow *":
r"""IdentifyDriver(char const * utf8_path, char ** papszSiblings=None) -> Driver"""
return _gdal.IdentifyDriver(*args)
def IdentifyDriverEx(*args, **kwargs) -> "GDALDriverShadow *":
r"""IdentifyDriverEx(char const * utf8_path, unsigned int nIdentifyFlags=0, char ** allowed_drivers=None, char ** sibling_files=None) -> Driver"""
return _gdal.IdentifyDriverEx(*args, **kwargs)
def GeneralCmdLineProcessor(*args) -> "char **":
r"""GeneralCmdLineProcessor(char ** papszArgv, int nOptions=0) -> char **"""
return _gdal.GeneralCmdLineProcessor(*args)
__version__ = _gdal.VersionInfo("RELEASE_NAME")
class GDALInfoOptions(object):
r"""Proxy of C++ GDALInfoOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALInfoOptions self, char ** options) -> GDALInfoOptions"""
_gdal.GDALInfoOptions_swiginit(self, _gdal.new_GDALInfoOptions(*args))
__swig_destroy__ = _gdal.delete_GDALInfoOptions
# Register GDALInfoOptions in _gdal:
_gdal.GDALInfoOptions_swigregister(GDALInfoOptions)
def InfoInternal(*args) -> "retStringAndCPLFree *":
r"""InfoInternal(Dataset hDataset, GDALInfoOptions infoOptions) -> retStringAndCPLFree *"""
return _gdal.InfoInternal(*args)
class GDALMultiDimInfoOptions(object):
r"""Proxy of C++ GDALMultiDimInfoOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALMultiDimInfoOptions self, char ** options) -> GDALMultiDimInfoOptions"""
_gdal.GDALMultiDimInfoOptions_swiginit(self, _gdal.new_GDALMultiDimInfoOptions(*args))
__swig_destroy__ = _gdal.delete_GDALMultiDimInfoOptions
# Register GDALMultiDimInfoOptions in _gdal:
_gdal.GDALMultiDimInfoOptions_swigregister(GDALMultiDimInfoOptions)
def MultiDimInfoInternal(*args) -> "retStringAndCPLFree *":
r"""MultiDimInfoInternal(Dataset hDataset, GDALMultiDimInfoOptions infoOptions) -> retStringAndCPLFree *"""
return _gdal.MultiDimInfoInternal(*args)
class GDALTranslateOptions(object):
r"""Proxy of C++ GDALTranslateOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALTranslateOptions self, char ** options) -> GDALTranslateOptions"""
_gdal.GDALTranslateOptions_swiginit(self, _gdal.new_GDALTranslateOptions(*args))
__swig_destroy__ = _gdal.delete_GDALTranslateOptions
# Register GDALTranslateOptions in _gdal:
_gdal.GDALTranslateOptions_swigregister(GDALTranslateOptions)
def TranslateInternal(*args) -> "GDALDatasetShadow *":
r"""TranslateInternal(char const * dest, Dataset dataset, GDALTranslateOptions translateOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.TranslateInternal(*args)
class GDALWarpAppOptions(object):
r"""Proxy of C++ GDALWarpAppOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALWarpAppOptions self, char ** options) -> GDALWarpAppOptions"""
_gdal.GDALWarpAppOptions_swiginit(self, _gdal.new_GDALWarpAppOptions(*args))
__swig_destroy__ = _gdal.delete_GDALWarpAppOptions
# Register GDALWarpAppOptions in _gdal:
_gdal.GDALWarpAppOptions_swigregister(GDALWarpAppOptions)
def wrapper_GDALWarpDestDS(*args) -> "int":
r"""wrapper_GDALWarpDestDS(Dataset dstDS, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.wrapper_GDALWarpDestDS(*args)
def wrapper_GDALWarpDestName(*args) -> "GDALDatasetShadow *":
r"""wrapper_GDALWarpDestName(char const * dest, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.wrapper_GDALWarpDestName(*args)
class GDALVectorTranslateOptions(object):
r"""Proxy of C++ GDALVectorTranslateOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALVectorTranslateOptions self, char ** options) -> GDALVectorTranslateOptions"""
_gdal.GDALVectorTranslateOptions_swiginit(self, _gdal.new_GDALVectorTranslateOptions(*args))
__swig_destroy__ = _gdal.delete_GDALVectorTranslateOptions
# Register GDALVectorTranslateOptions in _gdal:
_gdal.GDALVectorTranslateOptions_swigregister(GDALVectorTranslateOptions)
def wrapper_GDALVectorTranslateDestDS(*args) -> "int":
r"""wrapper_GDALVectorTranslateDestDS(Dataset dstDS, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.wrapper_GDALVectorTranslateDestDS(*args)
def wrapper_GDALVectorTranslateDestName(*args) -> "GDALDatasetShadow *":
r"""wrapper_GDALVectorTranslateDestName(char const * dest, Dataset srcDS, GDALVectorTranslateOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.wrapper_GDALVectorTranslateDestName(*args)
class GDALDEMProcessingOptions(object):
r"""Proxy of C++ GDALDEMProcessingOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALDEMProcessingOptions self, char ** options) -> GDALDEMProcessingOptions"""
_gdal.GDALDEMProcessingOptions_swiginit(self, _gdal.new_GDALDEMProcessingOptions(*args))
__swig_destroy__ = _gdal.delete_GDALDEMProcessingOptions
# Register GDALDEMProcessingOptions in _gdal:
_gdal.GDALDEMProcessingOptions_swigregister(GDALDEMProcessingOptions)
def DEMProcessingInternal(*args) -> "GDALDatasetShadow *":
r"""DEMProcessingInternal(char const * dest, Dataset dataset, char const * pszProcessing, char const * pszColorFilename, GDALDEMProcessingOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.DEMProcessingInternal(*args)
class GDALNearblackOptions(object):
r"""Proxy of C++ GDALNearblackOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALNearblackOptions self, char ** options) -> GDALNearblackOptions"""
_gdal.GDALNearblackOptions_swiginit(self, _gdal.new_GDALNearblackOptions(*args))
__swig_destroy__ = _gdal.delete_GDALNearblackOptions
# Register GDALNearblackOptions in _gdal:
_gdal.GDALNearblackOptions_swigregister(GDALNearblackOptions)
def wrapper_GDALNearblackDestDS(*args) -> "int":
r"""wrapper_GDALNearblackDestDS(Dataset dstDS, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.wrapper_GDALNearblackDestDS(*args)
def wrapper_GDALNearblackDestName(*args) -> "GDALDatasetShadow *":
r"""wrapper_GDALNearblackDestName(char const * dest, Dataset srcDS, GDALNearblackOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.wrapper_GDALNearblackDestName(*args)
class GDALGridOptions(object):
r"""Proxy of C++ GDALGridOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALGridOptions self, char ** options) -> GDALGridOptions"""
_gdal.GDALGridOptions_swiginit(self, _gdal.new_GDALGridOptions(*args))
__swig_destroy__ = _gdal.delete_GDALGridOptions
# Register GDALGridOptions in _gdal:
_gdal.GDALGridOptions_swigregister(GDALGridOptions)
def GridInternal(*args) -> "GDALDatasetShadow *":
r"""GridInternal(char const * dest, Dataset dataset, GDALGridOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.GridInternal(*args)
class GDALRasterizeOptions(object):
r"""Proxy of C++ GDALRasterizeOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALRasterizeOptions self, char ** options) -> GDALRasterizeOptions"""
_gdal.GDALRasterizeOptions_swiginit(self, _gdal.new_GDALRasterizeOptions(*args))
__swig_destroy__ = _gdal.delete_GDALRasterizeOptions
# Register GDALRasterizeOptions in _gdal:
_gdal.GDALRasterizeOptions_swigregister(GDALRasterizeOptions)
def wrapper_GDALRasterizeDestDS(*args) -> "int":
r"""wrapper_GDALRasterizeDestDS(Dataset dstDS, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> int"""
return _gdal.wrapper_GDALRasterizeDestDS(*args)
def wrapper_GDALRasterizeDestName(*args) -> "GDALDatasetShadow *":
r"""wrapper_GDALRasterizeDestName(char const * dest, Dataset srcDS, GDALRasterizeOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.wrapper_GDALRasterizeDestName(*args)
class GDALBuildVRTOptions(object):
r"""Proxy of C++ GDALBuildVRTOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALBuildVRTOptions self, char ** options) -> GDALBuildVRTOptions"""
_gdal.GDALBuildVRTOptions_swiginit(self, _gdal.new_GDALBuildVRTOptions(*args))
__swig_destroy__ = _gdal.delete_GDALBuildVRTOptions
# Register GDALBuildVRTOptions in _gdal:
_gdal.GDALBuildVRTOptions_swigregister(GDALBuildVRTOptions)
def BuildVRTInternalObjects(*args) -> "GDALDatasetShadow *":
r"""BuildVRTInternalObjects(char const * dest, int object_list_count, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.BuildVRTInternalObjects(*args)
def BuildVRTInternalNames(*args) -> "GDALDatasetShadow *":
r"""BuildVRTInternalNames(char const * dest, char ** source_filenames, GDALBuildVRTOptions options, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.BuildVRTInternalNames(*args)
class GDALMultiDimTranslateOptions(object):
r"""Proxy of C++ GDALMultiDimTranslateOptions class."""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
__repr__ = _swig_repr
def __init__(self, *args):
r"""__init__(GDALMultiDimTranslateOptions self, char ** options) -> GDALMultiDimTranslateOptions"""
_gdal.GDALMultiDimTranslateOptions_swiginit(self, _gdal.new_GDALMultiDimTranslateOptions(*args))
__swig_destroy__ = _gdal.delete_GDALMultiDimTranslateOptions
# Register GDALMultiDimTranslateOptions in _gdal:
_gdal.GDALMultiDimTranslateOptions_swigregister(GDALMultiDimTranslateOptions)
def wrapper_GDALMultiDimTranslateDestName(*args) -> "GDALDatasetShadow *":
r"""wrapper_GDALMultiDimTranslateDestName(char const * dest, int object_list_count, GDALMultiDimTranslateOptions multiDimTranslateOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
return _gdal.wrapper_GDALMultiDimTranslateDestName(*args)
|