leafmap module¶
Main module.
GoogleMapsTileProvider
¶
Bases: TileProvider
Google Maps TileProvider.
Source code in leafmap/common.py
19202 19203 19204 19205 19206 19207 19208 19209 19210 19211 19212 19213 19214 19215 19216 19217 19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 | |
__init__(map_type='roadmap', language='en-Us', region='US', api_key=None, **kwargs)
¶
Generates Google Map tiles using the provided parameters. To get an API key
and enable Map Tiles API, visit
https://developers.google.com/maps/get-started#create-project.
You can set the API key using the environment variable
GOOGLE_MAPS_API_KEY or by passing it as an argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
map_type
|
str
|
The type of map to generate. Options are 'roadmap', 'satellite', 'terrain', 'hybrid', 'traffic', 'streetview'. Defaults to 'roadmap'. |
'roadmap'
|
language
|
str
|
An IETF language tag that specifies the language used to display information on the tiles, such as 'zh-Cn'. Defaults to 'en-Us'. |
'en-Us'
|
region
|
str
|
A Common Locale Data Repository region identifier (two uppercase letters) that represents the physical location of the user. Defaults to 'US'. |
'US'
|
api_key
|
str
|
The API key to use for the Google Maps API. If not provided, it will try to get it from the environment or Colab user data with the key 'GOOGLE_MAPS_API_KEY'. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional parameters to pass to the map generation. For more info, visit https://bit.ly/3UhbZKU |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the API key is not provided and cannot be found in the environment or Colab user data. |
ValueError
|
If the map_type is not one of the allowed types. |
Example
from leafmap.basemaps import GoogleMapsTileProvider m = leafmap.Map() basemap = GoogleMapsTileProvider(map_type='roadmap', language="en-Us", region="US", scale="scaleFactor2x", highDpi=True) m.add_basemap(basemap)
Source code in leafmap/common.py
19218 19219 19220 19221 19222 19223 19224 19225 19226 19227 19228 19229 19230 19231 19232 19233 19234 19235 19236 19237 19238 19239 19240 19241 19242 19243 19244 19245 19246 19247 19248 19249 19250 19251 19252 19253 19254 19255 19256 19257 19258 19259 19260 19261 19262 19263 19264 19265 19266 19267 19268 19269 19270 19271 19272 19273 19274 19275 19276 19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 | |
ImageOverlay
¶
Bases: ImageOverlay
ImageOverlay class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
http URL or local file path to the image. |
required |
bounds
|
tuple
|
bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)). |
required |
Source code in leafmap/leafmap.py
7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 | |
Map
¶
Bases: Map
The Map class inherits ipyleaflet.Map. The arguments you can pass to the Map can be found at https://ipyleaflet.readthedocs.io/en/latest/api_reference/map.html. By default, the Map will add OpenStreetMap as the basemap.
Returns:
| Name | Type | Description |
|---|---|---|
object |
ipyleaflet map object. |
Source code in leafmap/leafmap.py
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 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 | |
add(obj, index=None, **kwargs)
¶
Adds a layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
object
|
The layer to add to the map. |
required |
index
|
int
|
The index at which to add the layer. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_basemap(basemap='HYBRID', show=True, **kwargs)
¶
Adds a basemap to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basemap
|
str
|
Can be one of string from basemaps. Defaults to 'HYBRID'. |
'HYBRID'
|
visible
|
bool
|
Whether the basemap is visible or not. Defaults to True. |
required |
**kwargs
|
Keyword arguments for the TileLayer. |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_basemap_gui(position='topright')
¶
Add the basemap widget to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the widget. Defaults to "topright". |
'topright'
|
Source code in leafmap/leafmap.py
5528 5529 5530 5531 5532 5533 5534 5535 5536 | |
add_bbox(bbox, layer_name='Bounding Box', color='blue', fill_color=None, fill_opacity=0.1, weight=2, **kwargs)
¶
Add a bbox defined by [x_min, y_min, x_max, y_max] to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
Union[List[float], Tuple[float, float, float, float], Sequence[float]]
|
A list or tuple containing four numbers representing the bounding box: [x_min, y_min, x_max, y_max]. Assumed to be in longitude/latitude coordinates. |
required |
layer_name
|
str
|
The name to assign to the GeoJSON layer. Defaults to "Bounding Box". |
'Bounding Box'
|
color
|
str
|
The color of the bounding box outline (stroke). Defaults to "blue". |
'blue'
|
fill_color
|
Optional[str]
|
The fill color of the bounding box. If None, the box will not be filled. Defaults to None. |
None
|
fill_opacity
|
float
|
The opacity of the fill color (only used if fill_color is provided). Value should be between 0.0 and 1.0. Defaults to 0.1. |
0.1
|
weight
|
int
|
The thickness of the bounding box outline (stroke). Defaults to 2. |
2
|
**kwargs
|
Additional keyword arguments to pass directly to the
underlying |
{}
|
Source code in leafmap/leafmap.py
5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 | |
add_census_data(wms, layer, census_dict=None, **kwargs)
¶
Adds a census data layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wms
|
str
|
The wms to use. For example, "Current", "ACS 2021", "Census 2020". See the complete list at https://tigerweb.geo.census.gov/tigerwebmain/TIGERweb_wms.html |
required |
layer
|
str
|
The layer name to add to the map. |
required |
census_dict
|
dict
|
A dictionary containing census data. Defaults to None. It can be obtained from the get_census_dict() function. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_circle_markers_from_xy(data, x='lon', y='lat', radius=10, popup=None, font_size=2, stroke=True, color='#0033FF', weight=2, fill=True, fill_color=None, fill_opacity=0.2, opacity=1.0, layer_name='Circle Markers', **kwargs)
¶
Adds a marker cluster to the map. For a list of options, see https://ipyleaflet.readthedocs.io/en/latest/_modules/ipyleaflet/leaflet.html#Path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame
|
A csv or Pandas DataFrame containing x, y, z values. |
required |
x
|
str
|
The column name for the x values. Defaults to "lon". |
'lon'
|
y
|
str
|
The column name for the y values. Defaults to "lat". |
'lat'
|
radius
|
int
|
The radius of the circle. Defaults to 10. |
10
|
popup
|
list
|
A list of column names to be used as the popup. Defaults to None. |
None
|
font_size
|
int
|
The font size of the popup. Defaults to 2. |
2
|
stroke
|
bool
|
Whether to stroke the path. Defaults to True. |
True
|
color
|
str
|
The color of the path. Defaults to "#0033FF". |
'#0033FF'
|
weight
|
int
|
The weight of the path. Defaults to 2. |
2
|
fill
|
bool
|
Whether to fill the path with color. Defaults to True. |
True
|
fill_color
|
str
|
The fill color of the path. Defaults to None. |
None
|
fill_opacity
|
float
|
The fill opacity of the path. Defaults to 0.2. |
0.2
|
opacity
|
float
|
The opacity of the path. Defaults to 1.0. |
1.0
|
layer_name
|
str
|
The layer name to use for the marker cluster. Defaults to "Circle Markers". |
'Circle Markers'
|
Source code in leafmap/leafmap.py
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 | |
add_cmr_layer(concept_id, datetime=None, backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, name='CMR Layer', attribution='NASA Earthdata', opacity=1.0, shown=True, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, zoom_to_layer=True, layer_index=None, **kwargs)
¶
Adds a NASA Earthdata CMR layer to the map using TiTiler CMR.
This method allows you to visualize NASA Earthdata collections directly on the map using the TiTiler CMR endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). Defaults to None. |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. Required when using backend='xarray'. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
name
|
str
|
The layer name. Defaults to 'CMR Layer'. |
'CMR Layer'
|
attribution
|
str
|
Attribution text. Defaults to 'NASA Earthdata'. |
'NASA Earthdata'
|
opacity
|
float
|
Layer opacity (0.0 to 1.0). Defaults to 1.0. |
1.0
|
shown
|
bool
|
Whether the layer is visible. Defaults to True. |
True
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer extent. Defaults to True. |
True
|
layer_index
|
int
|
Index to insert the layer. Defaults to None. |
None
|
**kwargs
|
Additional arguments passed to the TiTiler CMR endpoint. |
{}
|
Examples:
1 2 3 4 5 6 7 8 9 10 11 | |
1 2 3 4 5 6 7 8 9 10 | |
Source code in leafmap/leafmap.py
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 | |
add_cmr_timeseries(concept_id, datetime, step='P1D', temporal_mode='point', backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, name_prefix='CMR', attribution='NASA Earthdata', opacity=1.0, time_interval=1, position='bottomright', slider_length='150px', titiler_cmr_endpoint=None, **kwargs)
¶
Adds a NASA Earthdata CMR time series layer with an interactive time slider.
This method creates multiple tile layers for different time steps and adds a time slider control to navigate through the time series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime range (e.g., '2024-01-01/2024-01-31'). |
required |
step
|
str
|
ISO 8601 duration for time steps (e.g., 'P1D' for 1 day, 'P1M' for 1 month, 'P2W' for 2 weeks). Defaults to 'P1D'. |
'P1D'
|
temporal_mode
|
str
|
Temporal mode - 'point' or 'range'. Defaults to 'point'. |
'point'
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
name_prefix
|
str
|
Prefix for layer names. Defaults to 'CMR'. |
'CMR'
|
attribution
|
str
|
Attribution text. Defaults to 'NASA Earthdata'. |
'NASA Earthdata'
|
opacity
|
float
|
Layer opacity (0.0 to 1.0). Defaults to 1.0. |
1.0
|
time_interval
|
int
|
Time interval in seconds between frames. Defaults to 1. |
1
|
position
|
str
|
Position of the time slider ('topleft', 'topright', 'bottomleft', 'bottomright'). Defaults to 'bottomright'. |
'bottomright'
|
slider_length
|
str
|
Length of the time slider. Defaults to '150px'. |
'150px'
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional arguments passed to the TiTiler CMR endpoint. |
{}
|
Example
m = leafmap.Map() m.add_cmr_timeseries( ... concept_id="C2036881735-POCLOUD", ... datetime="2023-11-01/2024-10-30", ... step="P1M", ... backend="xarray", ... variable="sea_ice_fraction", ... colormap_name="blues_r", ... rescale="0,1" ... )
Source code in leafmap/leafmap.py
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 | |
add_cog_layer(url, name='Untitled', attribution='', opacity=1.0, shown=True, bands=None, titiler_endpoint=None, zoom_to_layer=True, layer_index=None, overwrite=False, **kwargs)
¶
Adds a COG TileLayer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the COG tile layer. |
required |
name
|
str
|
The layer name to use for the layer. Defaults to 'Untitled'. |
'Untitled'
|
attribution
|
str
|
The attribution to use. Defaults to ''. |
''
|
opacity
|
float
|
The opacity of the layer. Defaults to 1. |
1.0
|
shown
|
bool
|
A flag indicating whether the layer should be on by default. Defaults to True. |
True
|
bands
|
list
|
A list of bands to use for the layer. Defaults to None. |
None
|
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer extent. Defaults to True. |
True
|
layer_index
|
int
|
The index at which to add the layer. Defaults to None. |
None
|
overwrite
|
bool
|
Whether to overwrite the layer if it already exists. Defaults to False. |
False
|
**kwargs
|
Arbitrary keyword arguments, including bidx, expression, nodata, unscale, resampling, rescale,
color_formula, colormap, colormap_name, return_mask. See https://developmentseed.org/titiler/endpoints/cog/
and https://cogeotiff.github.io/rio-tiler/colormap/. To select a certain bands, use bidx=[1, 2, 3].
apply a rescaling to multiple bands, use something like |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_colorbar(colors, vmin=0, vmax=1.0, index=None, caption='', categorical=False, step=None, height='45px', transparent_bg=False, position='bottomright', **kwargs)
¶
Add a branca colorbar to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
list
|
The set of colors to be used for interpolation. Colors can be provided in the form: * tuples of RGBA ints between 0 and 255 (e.g: (255, 255, 0) or (255, 255, 0, 255)) * tuples of RGBA floats between 0. and 1. (e.g: (1.,1.,0.) or (1., 1., 0., 1.)) * HTML-like string (e.g: “#ffff00) * a color name or shortcut (e.g: “y” or “yellow”) |
required |
vmin
|
int
|
The minimal value for the colormap. Values lower than vmin will be bound directly to colors[0].. Defaults to 0. |
0
|
vmax
|
float
|
The maximal value for the colormap. Values higher than vmax will be bound directly to colors[-1]. Defaults to 1.0. |
1.0
|
index
|
list
|
The values corresponding to each color. It has to be sorted, and have the same length as colors. If None, a regular grid between vmin and vmax is created.. Defaults to None. |
None
|
caption
|
str
|
The caption for the colormap. Defaults to "". |
''
|
categorical
|
bool
|
Whether or not to create a categorical colormap. Defaults to False. |
False
|
step
|
int
|
The step to split the LinearColormap into a StepColormap. Defaults to None. |
None
|
height
|
str
|
The height of the colormap widget. Defaults to "45px". |
'45px'
|
transparent_bg
|
bool
|
Whether to use transparent background for the colormap widget. Defaults to True. |
False
|
position
|
str
|
The position for the colormap widget. Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
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 | |
add_colormap(cmap='gray', colors=None, discrete=False, label=None, width=3, height=0.25, orientation='horizontal', vmin=0, vmax=1.0, axis_off=False, show_name=False, font_size=8, transparent_bg=False, position='bottomright', **kwargs)
¶
Adds a matplotlib colormap to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmap
|
str
|
Matplotlib colormap. Defaults to "gray". See https://matplotlib.org/3.3.4/tutorials/colors/colormaps.html#sphx-glr-tutorials-colors-colormaps-py for options. |
'gray'
|
colors
|
list
|
A list of custom colors to create a colormap. Defaults to None. |
None
|
discrete
|
bool
|
Whether to create a discrete colorbar. Defaults to False. |
False
|
label
|
str
|
Label for the colorbar. Defaults to None. |
None
|
width
|
float
|
The width of the colormap. Defaults to 8.0. |
3
|
height
|
float
|
The height of the colormap. Defaults to 0.4. |
0.25
|
orientation
|
str
|
The orientation of the colormap. Defaults to "horizontal". |
'horizontal'
|
vmin
|
float
|
The minimum value range. Defaults to 0. |
0
|
vmax
|
float
|
The maximum value range. Defaults to 1.0. |
1.0
|
axis_off
|
bool
|
Whether to turn axis off. Defaults to False. |
False
|
show_name
|
bool
|
Whether to show the colormap name. Defaults to False. |
False
|
font_size
|
int
|
Font size of the text. Defaults to 12. |
8
|
transparent_bg
|
bool
|
Whether to use transparent background for the colormap widget. Defaults to True. |
False
|
position
|
str
|
The position for the colormap widget. Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
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 | |
add_data(data, column, colors=None, labels=None, cmap=None, scheme='Quantiles', k=5, add_legend=True, legend_title=None, legend_position='bottomright', legend_kwds=None, classification_kwds=None, layer_name='Untitled', style=None, hover_style=None, style_callback=None, marker_radius=10, marker_args=None, info_mode='on_hover', encoding='utf-8', **kwargs)
¶
Add vector data to the map with a variety of classification schemes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame | GeoDataFrame
|
The data to classify. It can be a filepath to a vector dataset, a pandas dataframe, or a geopandas geodataframe. |
required |
column
|
str
|
The column to classify. |
required |
cmap
|
str
|
The name of a colormap recognized by matplotlib. Defaults to None. |
None
|
colors
|
list
|
A list of colors to use for the classification. Defaults to None. |
None
|
labels
|
list
|
A list of labels to use for the legend. Defaults to None. |
None
|
scheme
|
str
|
Name of a choropleth classification scheme (requires mapclassify). Name of a choropleth classification scheme (requires mapclassify). A mapclassify.MapClassifier object will be used under the hood. Supported are all schemes provided by mapclassify (e.g. 'BoxPlot', 'EqualInterval', 'FisherJenks', 'FisherJenksSampled', 'HeadTailBreaks', 'JenksCaspall', 'JenksCaspallForced', 'JenksCaspallSampled', 'MaxP', 'MaximumBreaks', 'NaturalBreaks', 'Quantiles', 'Percentiles', 'StdMean', 'UserDefined'). Arguments can be passed in classification_kwds. |
'Quantiles'
|
k
|
int
|
Number of classes (ignored if scheme is None or if column is categorical). Default to 5. |
5
|
add_legend
|
bool
|
Whether to add a legend to the map. Defaults to True. |
True
|
legend_title
|
str
|
The title of the legend. Defaults to None. |
None
|
legend_position
|
str
|
The position of the legend. Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'. Defaults to 'bottomright'. |
'bottomright'
|
legend_kwds
|
dict
|
Keyword arguments to pass to :func: |
None
|
classification_kwds
|
dict
|
Keyword arguments to pass to mapclassify. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to None. style is a dictionary of the following form: style = { "stroke": False, "color": "#ff0000", "weight": 1, "opacity": 1, "fill": True, "fillColor": "#ffffff", "fillOpacity": 1.0, "dashArray": "9" "clickable": True, } |
None
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. hover_style is a dictionary of the following form: hover_style = {"weight": style["weight"] + 1, "fillOpacity": 0.5} |
None
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. style_callback is a function that takes the feature as argument and should return a dictionary of the following form: style_callback = lambda feat: {"fillColor": feat["properties"]["color"]} |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
encoding
|
str
|
The encoding of the GeoJSON file. Defaults to "utf-8". |
'utf-8'
|
**kwargs
|
Additional keyword arguments to pass to the GeoJSON class, such as fields, which can be a list of column names to be included in the popup. |
{}
|
Source code in leafmap/leafmap.py
4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 | |
add_ee_layer(ee_object=None, vis_params={}, asset_id=None, name=None, attribution='Google Earth Engine', shown=True, opacity=1.0, **kwargs)
¶
Adds a Google Earth Engine tile layer to the map based on the tile layer URL from https://github.com/opengeos/ee-tile-layers/blob/main/datasets.tsv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ee_object
|
object
|
The Earth Engine object to display. |
None
|
vis_params
|
dict
|
Visualization parameters. For example, {'min': 0, 'max': 100}. |
{}
|
asset_id
|
str
|
The ID of the Earth Engine asset. |
None
|
name
|
str
|
The name of the tile layer. If not provided, the asset ID will be used. Default is None. |
None
|
attribution
|
str
|
The attribution text to be displayed. Default is "Google Earth Engine". |
'Google Earth Engine'
|
shown
|
bool
|
Whether the tile layer should be shown on the map. Default is True. |
True
|
opacity
|
float
|
The opacity of the tile layer. Default is 1.0. |
1.0
|
**kwargs
|
Additional keyword arguments to be passed to the underlying |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
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 | |
add_fire_data(data=None, bbox=None, place=None, collection='snapshot_perimeter_nrt', datetime=None, farea_min=None, layer_name='Fire Perimeters', style=None, hover_style=None, style_callback=None, info_mode='on_hover', zoom_to_layer=True, **kwargs)
¶
Add NASA fire perimeter data to the map.
This method fetches and displays fire perimeter data from the NASA Fire Event Data Suite (FEDs) via the OpenVEDA OGC API Features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Optional[Union[str, GeoDataFrame]]
|
Pre-loaded fire data as a file path or GeoDataFrame. If provided, bbox and place are ignored. |
None
|
bbox
|
Optional[List[float]]
|
Bounding box [west, south, east, north] in EPSG:4326. |
None
|
place
|
Optional[str]
|
Place name to geocode (e.g., "California"). |
None
|
collection
|
str
|
Fire collection ID. Options: - "snapshot_perimeter_nrt": 20-day recent fire perimeters (default) - "lf_perimeter_nrt": Current year large fires (>5 km²) - "lf_perimeter_archive": 2018-2021 Western US archived fires - "lf_fireline_nrt": Active fire lines - "lf_newfirepix_nrt": New fire pixels |
'snapshot_perimeter_nrt'
|
datetime
|
Optional[str]
|
ISO 8601 date/time or interval (e.g., "2024-07-01/2024-07-31"). |
None
|
farea_min
|
Optional[float]
|
Minimum fire area in km² to filter results. |
None
|
layer_name
|
str
|
Name for the layer. Defaults to "Fire Perimeters". |
'Fire Perimeters'
|
style
|
Optional[Dict]
|
Style dictionary for the fire perimeters. Defaults to orange/red. |
None
|
hover_style
|
Optional[Dict]
|
Hover style dictionary. |
None
|
style_callback
|
Optional[Callable]
|
Styling function called for each feature. |
None
|
info_mode
|
str
|
Display attributes "on_hover" or "on_click". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. |
True
|
**kwargs
|
Additional keyword arguments for add_gdf(). |
{}
|
Example
m = leafmap.Map() m.add_fire_data(place="California", datetime="2024-07-01/2024-07-31") m
Source code in leafmap/leafmap.py
6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 | |
add_fire_perimeters(bbox=None, place=None, collection='snapshot_perimeter_nrt', datetime=None, farea_min=None, color_column='farea', cmap='YlOrRd', layer_name='Fire Perimeters', style=None, info_mode='on_hover', zoom_to_layer=True, add_legend=True, legend_title='Fire Area (km²)', **kwargs)
¶
Add fire perimeters with color scaling based on fire attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
Optional[List[float]]
|
Bounding box [west, south, east, north] in EPSG:4326. |
None
|
place
|
Optional[str]
|
Place name to geocode (e.g., "California"). |
None
|
collection
|
str
|
Fire collection ID. Defaults to "snapshot_perimeter_nrt". |
'snapshot_perimeter_nrt'
|
datetime
|
Optional[str]
|
ISO 8601 date/time or interval. |
None
|
farea_min
|
Optional[float]
|
Minimum fire area in km² to filter results. |
None
|
color_column
|
Optional[str]
|
Column to use for color scaling. Defaults to "farea". |
'farea'
|
cmap
|
str
|
Colormap name for color scaling. Defaults to "YlOrRd". |
'YlOrRd'
|
layer_name
|
str
|
Name for the layer. |
'Fire Perimeters'
|
style
|
Optional[Dict]
|
Base style dictionary (color will be overridden by colormap). |
None
|
info_mode
|
str
|
Display attributes "on_hover" or "on_click". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. |
True
|
add_legend
|
bool
|
Whether to add a legend. Defaults to True. |
True
|
legend_title
|
str
|
Title for the legend. |
'Fire Area (km²)'
|
**kwargs
|
Additional keyword arguments for add_gdf(). |
{}
|
Example
m = leafmap.Map() m.add_fire_perimeters( ... place="California", ... datetime="2024-07-01/2024-07-31", ... color_column="farea" ... ) m
Source code in leafmap/leafmap.py
6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 | |
add_fire_timeseries(fire_id, collection='snapshot_perimeter_nrt', datetime=None, time_column='t', layer_name='Fire Evolution', style=None, **kwargs)
¶
Add fire perimeter evolution over time with a time slider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fire_id
|
str
|
The fire ID to track over time. |
required |
collection
|
str
|
Fire collection ID. Defaults to "snapshot_perimeter_nrt". |
'snapshot_perimeter_nrt'
|
datetime
|
Optional[str]
|
ISO 8601 date/time or interval to filter by. |
None
|
time_column
|
str
|
Column containing timestamps. Defaults to "t". |
't'
|
layer_name
|
str
|
Name for the layer. |
'Fire Evolution'
|
style
|
Optional[Dict]
|
Style dictionary for the fire perimeters. |
None
|
**kwargs
|
Additional keyword arguments for add_gdf_time_slider(). |
{}
|
Example
m = leafmap.Map() m.add_fire_timeseries(fire_id="2024_CA_001") m
Source code in leafmap/leafmap.py
7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 | |
add_gdf(gdf, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', zoom_to_layer=False, encoding='utf-8', **kwargs)
¶
Adds a GeoDataFrame to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoPandas GeoDataFrame. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer. Defaults to False. |
False
|
encoding
|
str
|
The encoding of the GeoDataFrame. Defaults to "utf-8". |
'utf-8'
|
Source code in leafmap/leafmap.py
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 | |
add_gdf_from_postgis(sql, con, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=['black'], info_mode='on_hover', zoom_to_layer=True, **kwargs)
¶
Reads a PostGIS database and returns data as a GeoDataFrame to be added to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sql
|
str
|
SQL query to execute in selecting entries from database, or name of the table to read from the database. |
required |
con
|
Engine
|
Active connection to the database to query. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
['black']
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer. |
True
|
Source code in leafmap/leafmap.py
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 | |
add_geojson(in_geojson, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', zoom_to_layer=False, encoding='utf-8', **kwargs)
¶
Adds a GeoJSON file to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_geojson
|
str | dict
|
The file path or http URL to the input GeoJSON or a dictionary containing the geojson. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer after adding it to the map. Defaults to False. |
False
|
encoding
|
str
|
The encoding of the GeoJSON file. Defaults to "utf-8". |
'utf-8'
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided GeoJSON file could not be found. |
Source code in leafmap/leafmap.py
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 | |
add_geotiff(url, name='GeoTIFF', attribution='', opacity=1.0, shown=True, bands=None, titiler_endpoint=None, zoom_to_layer=True, layer_index=None, overwrite=False, **kwargs)
¶
Adds a Cloud Optimized GeoTIFF (COG) to the map.
This helper wraps :meth:add_cog_layer so that users can quickly load a
remote GeoTIFF/COG by simply providing its URL. By default it relies on
the TiTiler endpoint configured for the map (the public demo endpoint is
used when none is provided).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The HTTP URL of the GeoTIFF/COG. |
required |
name
|
str
|
Layer name to display in the layer tree.
Defaults to |
'GeoTIFF'
|
attribution
|
str
|
Attribution text for the layer.
Defaults to |
''
|
opacity
|
float
|
Layer opacity between 0.0 and 1.0. Defaults to 1.0. |
1.0
|
shown
|
bool
|
Whether the layer should be visible when first added. Defaults to True. |
True
|
bands
|
Sequence[Union[int, str]]
|
Specific band indices (1-based) or band names to render. Defaults to None which lets Leafmap pick sensible defaults. |
None
|
titiler_endpoint
|
str
|
Custom TiTiler endpoint to use. Defaults to the library's configured endpoint. |
None
|
zoom_to_layer
|
bool
|
Whether to fit the map view to the layer bounds after it loads. Defaults to True. |
True
|
layer_index
|
int
|
Stack index at which to insert the layer. Defaults to None (append). |
None
|
overwrite
|
bool
|
When True, an existing layer with the same name is replaced. Defaults to False. |
False
|
**kwargs
|
Additional keyword arguments forwarded to
:meth: |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_heatmap(data, latitude='latitude', longitude='longitude', value='value', name='Heat map', radius=25, **kwargs)
¶
Adds a heat map to the map. Reference: https://ipyleaflet.readthedocs.io/en/latest/api_reference/heatmap.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | list | DataFrame
|
File path or HTTP URL to the input file or a list of data points in the format of [[x1, y1, z1], [x2, y2, z2]]. For example, https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/world_cities.csv |
required |
latitude
|
str
|
The column name of latitude. Defaults to "latitude". |
'latitude'
|
longitude
|
str
|
The column name of longitude. Defaults to "longitude". |
'longitude'
|
value
|
str
|
The column name of values. Defaults to "value". |
'value'
|
name
|
str
|
Layer name to use. Defaults to "Heat map". |
'Heat map'
|
radius
|
int
|
Radius of each “point” of the heatmap. Defaults to 25. |
25
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If data is not a list. |
Source code in leafmap/leafmap.py
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 | |
add_html(html, position='bottomright', **kwargs)
¶
Add HTML to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML to add. |
required |
position
|
str
|
The position of the HTML, can be one of "topleft", "topright", "bottomleft", "bottomright". Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 | |
add_image(image, position='bottomright', **kwargs)
¶
Add an image to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str | Image
|
The image to add. |
required |
position
|
str
|
The position of the image, can be one of "topleft", "topright", "bottomleft", "bottomright". Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 | |
add_inspector_gui(position='topright', opened=True)
¶
Add the Inspector widget to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the widget. Defaults to "topright". |
'topright'
|
opened
|
bool
|
Whether the widget is open. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 | |
add_kml(in_kml, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', **kwargs)
¶
Adds a KML file to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_kml
|
str
|
The input file path or HTTP URL to the KML. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided KML file could not be found. |
Source code in leafmap/leafmap.py
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 | |
add_labels(data, column, font_size='12pt', font_color='black', font_family='arial', font_weight='normal', x='longitude', y='latitude', draggable=True, layer_name='Labels', **kwargs)
¶
Adds a label layer to the map. Reference: https://ipyleaflet.readthedocs.io/en/latest/api_reference/divicon.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame | GeoDataFrame | str
|
The input data to label. |
required |
column
|
str
|
The column name of the data to label. |
required |
font_size
|
str
|
The font size of the labels. Defaults to "12pt". |
'12pt'
|
font_color
|
str
|
The font color of the labels. Defaults to "black". |
'black'
|
font_family
|
str
|
The font family of the labels. Defaults to "arial". |
'arial'
|
font_weight
|
str
|
The font weight of the labels, can be normal, bold. Defaults to "normal". |
'normal'
|
x
|
str
|
The column name of the longitude. Defaults to "longitude". |
'longitude'
|
y
|
str
|
The column name of the latitude. Defaults to "latitude". |
'latitude'
|
draggable
|
bool
|
Whether the labels are draggable. Defaults to True. |
True
|
layer_name
|
str
|
Layer name to use. Defaults to "Labels". |
'Labels'
|
Source code in leafmap/leafmap.py
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 | |
add_layer(layer)
¶
Adds a layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
ipyleaflet layer
|
The layer to be added. |
required |
Source code in leafmap/leafmap.py
430 431 432 433 434 435 436 437 438 439 | |
add_layer_control(position='topright')
¶
Adds a layer control to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the layer control. Defaults to 'topright'. |
'topright'
|
Source code in leafmap/leafmap.py
510 511 512 513 514 515 516 517 | |
add_layer_manager(position='topright', opened=True)
¶
Add the Layer Manager to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the Layer Manager. Defaults to "topright". |
'topright'
|
Source code in leafmap/leafmap.py
5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 | |
add_legend(title='Legend', legend_dict=None, labels=None, colors=None, position='bottomright', builtin_legend=None, layer_name=None, shape_type='rectangle', **kwargs)
¶
Adds a customized basemap to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Title of the legend. Defaults to 'Legend'. |
'Legend'
|
legend_dict
|
dict
|
A dictionary containing legend items as keys and color as values. If provided, legend_keys and legend_colors will be ignored. Defaults to None. |
None
|
labels
|
list
|
A list of legend keys. Defaults to None. |
None
|
colors
|
list
|
A list of legend colors. Defaults to None. |
None
|
position
|
str
|
Position of the legend. Defaults to 'bottomright'. |
'bottomright'
|
builtin_legend
|
str
|
Name of the builtin legend to add to the map. Defaults to None. |
None
|
layer_name
|
str
|
Layer name of the legend to be associated with. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_marker(location, **kwargs)
¶
Adds a marker to the map. More info about marker at https://ipyleaflet.readthedocs.io/en/latest/api_reference/marker.html.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
list | tuple
|
The location of the marker in the format of [lat, lng]. |
required |
**kwargs
|
Keyword arguments for the marker. |
{}
|
Source code in leafmap/leafmap.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
add_markers(markers, x='lon', y='lat', radius=10, popup=None, font_size=2, stroke=True, color='#0033FF', weight=2, fill=True, fill_color=None, fill_opacity=0.2, opacity=1.0, shape='circle', layer_name='Markers', **kwargs)
¶
Adds markers to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
markers
|
Union[List[List[Union[int, float]]], List[Union[int, float]]]
|
List of markers. Each marker can be defined as a list of [x, y] coordinates or as a single [x, y] coordinate. |
required |
x
|
str
|
Name of the x-coordinate column in the marker data. Defaults to "lon". |
'lon'
|
y
|
str
|
Name of the y-coordinate column in the marker data. Defaults to "lat". |
'lat'
|
radius
|
int
|
Radius of the markers. Defaults to 10. |
10
|
popup
|
str
|
Popup text for the markers. Defaults to None. |
None
|
font_size
|
int
|
Font size of the popup text. Defaults to 2. |
2
|
stroke
|
bool
|
Whether to display marker stroke. Defaults to True. |
True
|
color
|
str
|
Color of the marker stroke. Defaults to "#0033FF". |
'#0033FF'
|
weight
|
int
|
Weight of the marker stroke. Defaults to 2. |
2
|
fill
|
bool
|
Whether to fill markers. Defaults to True. |
True
|
fill_color
|
str
|
Fill color of the markers. Defaults to None. |
None
|
fill_opacity
|
float
|
Opacity of the marker fill. Defaults to 0.2. |
0.2
|
opacity
|
float
|
Opacity of the markers. Defaults to 1.0. |
1.0
|
shape
|
str
|
Shape of the markers. Options are "circle" or "marker". Defaults to "circle". |
'circle'
|
layer_name
|
str
|
Name of the marker layer. Defaults to "Markers". |
'Markers'
|
**kwargs
|
Additional keyword arguments to pass to the marker plotting function. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This function does not return any value. |
Source code in leafmap/leafmap.py
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 | |
add_minimap(zoom=5, position='bottomright')
¶
Adds a minimap (overview) to the ipyleaflet map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom
|
int
|
Initial map zoom level. Defaults to 5. |
5
|
position
|
str
|
Position of the minimap. Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 | |
add_mosaic_layer(url=None, titiler_endpoint=None, name='Mosaic Layer', attribution='', opacity=1.0, shown=True, **kwargs)
¶
Adds a STAC TileLayer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a MosaicJSON. |
None
|
titiler_endpoint
|
str
|
TiTiler endpoint, e.g., "https://titiler.opengeos.org". Defaults to None. |
None
|
name
|
str
|
The layer name to use for the layer. Defaults to 'Mosaic Layer'. |
'Mosaic Layer'
|
attribution
|
str
|
The attribution to use. Defaults to ''. |
''
|
opacity
|
float
|
The opacity of the layer. Defaults to 1. |
1.0
|
shown
|
bool
|
A flag indicating whether the layer should be on by default. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
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 | |
add_netcdf(filename, variables=None, palette=None, vmin=None, vmax=None, nodata=None, attribution=None, layer_name='NetCDF layer', shift_lon=True, lat='lat', lon='lon', lev='lev', level_index=0, time=0, **kwargs)
¶
Generate an ipyleaflet/folium TileLayer from a netCDF file. If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer), try adding to following two lines to the beginning of the notebook if the raster does not render properly.
1 2 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
File path or HTTP URL to the netCDF file. |
required |
variables
|
int
|
The variable/band names to extract data from the netCDF file. Defaults to None. If None, all variables will be extracted. |
None
|
port
|
str
|
The port to use for the server. Defaults to "default". |
required |
palette
|
str
|
The name of the color palette from |
None
|
vmin
|
float
|
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
vmax
|
float
|
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
nodata
|
float
|
The value from the band to use to interpret as not valid data. Defaults to None. |
None
|
attribution
|
str
|
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to use. Defaults to "netCDF layer". |
'NetCDF layer'
|
shift_lon
|
bool
|
Flag to shift longitude values from [0, 360] to the range [-180, 180]. Defaults to True. |
True
|
lat
|
str
|
Name of the latitude variable. Defaults to 'lat'. |
'lat'
|
lon
|
str
|
Name of the longitude variable. Defaults to 'lon'. |
'lon'
|
lev
|
str
|
Name of the level variable. Defaults to 'lev'. |
'lev'
|
level_index
|
int
|
Index of level to use. Defaults to 0'. |
0
|
time
|
int
|
Index of time to use. Defaults to 0'. |
0
|
Source code in leafmap/leafmap.py
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 | |
add_nlcd(years=[2023], add_legend=True, **kwargs)
¶
Adds National Land Cover Database (NLCD) data to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
list
|
A list of years to add. It can be any of 1985-2023. Defaults to [2023]. |
[2023]
|
add_legend
|
bool
|
Whether to add a legend to the map. Defaults to True. |
True
|
**kwargs
|
Additional keyword arguments to pass to the add_cog_layer method. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 | |
add_nlcd_ts(left_year=1985, right_layer=2023, widget_width='70px', add_legend=True, add_layer_control=True, **kwargs)
¶
Adds a time series comparison of NLCD (National Land Cover Database) layers to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left_year
|
int
|
The initial year for the left layer. Defaults to 1985. |
1985
|
right_layer
|
int
|
The initial year for the right layer. Defaults to 2023. |
2023
|
widget_width
|
str
|
The width of the dropdown widgets. Defaults to "70px". |
'70px'
|
add_legend
|
bool
|
If True, adds a legend to the map. Defaults to True. |
True
|
add_layer_control
|
bool
|
If True, adds a layer control to the map. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the cog_tile function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 | |
add_nwi(data, col_name='WETLAND_TY', add_legend=True, style_callback=None, layer_name='Wetlands', **kwargs)
¶
Adds National Wetlands Inventory (NWI) data to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame]
|
The NWI data to add. It can be a file path or a GeoDataFrame. |
required |
col_name
|
str
|
The column name in the GeoDataFrame that contains the wetland types. |
'WETLAND_TY'
|
add_legend
|
bool
|
Whether to add a legend to the map. Defaults to True. |
True
|
style_callback
|
Optional[Callable[[dict], dict]]
|
A callback function to style the features. Defaults to None. |
None
|
layer_name
|
str
|
The name of the layer to add. Defaults to "Wetlands". |
'Wetlands'
|
**kwargs
|
Additional keyword arguments to pass to the add_vector or add_gdf method. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 | |
add_oam_gui(position='topright', opened=True)
¶
Add the OpenAerialMap search widget to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the widget. Defaults to "topright". |
'topright'
|
opened
|
bool
|
Whether the widget is open. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 | |
add_opacity_control(layer=None, position='topright', min_opacity=0.0, max_opacity=1.0, step=0.05)
¶
Adds an interactive opacity control panel to the map.
The panel provides a dropdown to choose from the map layers that expose
an opacity attribute and a slider to adjust the selected layer's
transparency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
str | Layer
|
Layer (or layer name) to select initially. Defaults to the first available layer. |
None
|
position
|
str
|
Location for the widget control.
Defaults to |
'topright'
|
min_opacity
|
float
|
Minimum slider value. Defaults to 0.0. |
0.0
|
max_opacity
|
float
|
Maximum slider value. Defaults to 1.0. |
1.0
|
step
|
float
|
Slider step size. Defaults to 0.05. |
0.05
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_address(address, tags, dist=1000, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within some distance N, S, E, W of address to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
The address to geocode and use as the central point around which to get the geometries. |
required |
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
dist
|
int
|
Distance in meters. Defaults to 1000. |
1000
|
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_bbox(north, south, east, west, tags, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within a N, S, E, W bounding box to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
north
|
float
|
Northern latitude of bounding box. |
required |
south
|
float
|
Southern latitude of bounding box. |
required |
east
|
float
|
Eastern longitude of bounding box. |
required |
west
|
float
|
Western longitude of bounding box. |
required |
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_geocode(query, which_result=None, by_osmid=False, buffer_dist=None, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM data of place(s) by name or ID to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | dict | list
|
Query string(s) or structured dict(s) to geocode. |
required |
which_result
|
int
|
Which geocoding result to use. if None, auto-select the first (Multi)Polygon or raise an error if OSM doesn't return one. to get the top match regardless of geometry type, set which_result=1. Defaults to None. |
None
|
by_osmid
|
bool
|
If True, handle query as an OSM ID for lookup rather than text search. Defaults to False. |
False
|
buffer_dist
|
float
|
Distance to buffer around the place geometry, in meters. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_place(query, tags, which_result=None, buffer_dist=None, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within boundaries of geocodable place(s) to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str | dict | list
|
Query string(s) or structured dict(s) to geocode. |
required |
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
which_result
|
int
|
Which geocoding result to use. if None, auto-select the first (Multi)Polygon or raise an error if OSM doesn't return one. to get the top match regardless of geometry type, set which_result=1. Defaults to None. |
None
|
buffer_dist
|
float
|
Distance to buffer around the place geometry, in meters. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_point(center_point, tags, dist=1000, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within some distance N, S, E, W of a point to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_point
|
tuple
|
The (lat, lng) center point around which to get the geometries. |
required |
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
dist
|
int
|
Distance in meters. Defaults to 1000. |
1000
|
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_polygon(polygon, tags, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within boundaries of a (multi)polygon to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polygon
|
Polygon | MultiPolygon
|
Geographic boundaries to fetch geometries within |
required |
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_osm_from_view(tags, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover')
¶
Adds OSM entities within the current map view to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
dict
|
Dict of tags used for finding objects in the selected area. Results returned are the union, not intersection of each individual tag. Each result matches at least one given tag. The dict keys should be OSM tags, (e.g., building, landuse, highway, etc) and the dict values should be either True to retrieve all items with the given tag, or a string to get a single tag-value combination, or a list of strings to get multiple values for the given tag. For example, tags = {‘building’: True} would return all building footprints in the area. tags = {‘amenity’:True, ‘landuse’:[‘retail’,’commercial’], ‘highway’:’bus_stop’} would return all amenities, landuse=retail, landuse=commercial, and highway=bus_stop. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
Source code in leafmap/leafmap.py
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 | |
add_planet_by_month(year=2016, month=1, layer_name=None, api_key=None, token_name='PLANET_API_KEY', **kwargs)
¶
Adds a Planet global mosaic by month to the map. To get a Planet API key, see https://developers.planet.com/quickstart/apis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
The year of Planet global mosaic, must be >=2016. Defaults to 2016. |
2016
|
month
|
int
|
The month of Planet global mosaic, must be 1-12. Defaults to 1. |
1
|
layer_name
|
str
|
The layer name to use. Defaults to None. |
None
|
api_key
|
str
|
The Planet API key. Defaults to None. |
None
|
token_name
|
str
|
The environment variable name of the API key. Defaults to "PLANET_API_KEY". |
'PLANET_API_KEY'
|
Source code in leafmap/leafmap.py
4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 | |
add_planet_by_quarter(year=2016, quarter=1, layer_name=None, api_key=None, token_name='PLANET_API_KEY', **kwargs)
¶
Adds a Planet global mosaic by quarter to the map. To get a Planet API key, see https://developers.planet.com/quickstart/apis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
The year of Planet global mosaic, must be >=2016. Defaults to 2016. |
2016
|
quarter
|
int
|
The quarter of Planet global mosaic, must be 1-12. Defaults to 1. |
1
|
layer_name
|
str
|
The layer name to use. Defaults to None. |
None
|
api_key
|
str
|
The Planet API key. Defaults to None. |
None
|
token_name
|
str
|
The environment variable name of the API key. Defaults to "PLANET_API_KEY". |
'PLANET_API_KEY'
|
Source code in leafmap/leafmap.py
4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 | |
add_pmtiles(url, style=None, name='PMTiles', show=True, zoom_to_layer=True, **kwargs)
¶
Adds a PMTiles layer to the map. This function is not officially supported yet by ipyleaflet yet. Install it with the following command: pip install git+https://github.com/giswqs/ipyleaflet.git@pmtiles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the PMTiles file. |
required |
style
|
str
|
The CSS style to apply to the layer. Defaults to None. See https://docs.mapbox.com/style-spec/reference/layers/ for more info. |
None
|
name
|
str
|
The name of the layer. Defaults to None. |
'PMTiles'
|
show
|
bool
|
Whether the layer should be shown initially. Defaults to True. |
True
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer extent. Defaults to True. |
True
|
**kwargs
|
Additional keyword arguments to pass to the PMTilesLayer constructor. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
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 | |
add_point_layer(filename, popup=None, layer_name='Marker Cluster', **kwargs)
¶
Adds a point layer to the map with a popup attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
str, http url, path object or file-like object. Either the absolute or relative path to the file or URL to be opened, or any object with a read() method (such as an open file or StringIO) |
required |
popup
|
str | list
|
Column name(s) to be used for popup. Defaults to None. |
None
|
layer_name
|
str
|
A layer name to use. Defaults to "Marker Cluster". |
'Marker Cluster'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the specified column name does not exist. |
ValueError
|
If the specified column names do not exist. |
Source code in leafmap/leafmap.py
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 | |
add_points_from_xy(data, x='longitude', y='latitude', popup=None, layer_name='Marker Cluster', color_column=None, marker_colors=None, icon_colors=['white'], icon_names=['info'], spin=False, add_legend=True, max_cluster_radius=80, **kwargs)
¶
Adds a marker cluster to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame
|
A csv or Pandas DataFrame containing x, y, z values. |
required |
x
|
str
|
The column name for the x values. Defaults to "longitude". |
'longitude'
|
y
|
str
|
The column name for the y values. Defaults to "latitude". |
'latitude'
|
popup
|
list
|
A list of column names to be used as the popup. Defaults to None. |
None
|
layer_name
|
str
|
The name of the layer. Defaults to "Marker Cluster". |
'Marker Cluster'
|
color_column
|
str
|
The column name for the color values. Defaults to None. |
None
|
marker_colors
|
list
|
A list of colors to be used for the markers. Defaults to None. |
None
|
icon_colors
|
list
|
A list of colors to be used for the icons. Defaults to ['white']. |
['white']
|
icon_names
|
list
|
A list of names to be used for the icons. More icons can be found at https://fontawesome.com/v4/icons. Defaults to ['info']. |
['info']
|
spin
|
bool
|
If True, the icon will spin. Defaults to False. |
False
|
add_legend
|
bool
|
If True, a legend will be added to the map. Defaults to True. |
True
|
max_cluster_radius
|
int
|
The maximum cluster radius. Defaults to 80. |
80
|
**kwargs
|
Other keyword arguments to pass to ipyleaflet.MarkerCluster(). For a list of available options, see https://github.com/Leaflet/Leaflet.markercluster. |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_polars(df, geometry='geometry', crs=None, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', zoom_to_layer=False, encoding='utf-8', **kwargs)
¶
Adds a Polars DataFrame with geometry to the map.
This method supports Polars-ST DataFrames with spatial geometry columns and enables direct visualization of Polars-based geospatial data without manual conversion to GeoPandas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
A Polars DataFrame with a geometry column (e.g., from Polars-ST). |
required | |
geometry
|
str
|
The name of the geometry column. Defaults to "geometry". |
'geometry'
|
crs
|
str
|
The CRS of the geometry data (e.g., "EPSG:4326"). If None, defaults to EPSG:4326. For Polars-ST DataFrames, specify the CRS explicitly. |
None
|
layer_name
|
str
|
The layer name to be used. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer. Defaults to False. |
False
|
encoding
|
str
|
The encoding of the GeoDataFrame. Defaults to "utf-8". |
'utf-8'
|
**kwargs
|
Additional keyword arguments to pass to add_gdf. |
{}
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If polars or required dependencies are not installed. |
ValueError
|
If the specified geometry column is not found or contains invalid data. |
TypeError
|
If the input is not a Polars DataFrame. |
Examples:
1 2 3 4 5 | |
Source code in leafmap/leafmap.py
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 | |
add_raster(source, indexes=None, colormap=None, vmin=None, vmax=None, nodata=None, attribution=None, layer_name='Raster', layer_index=None, zoom_to_layer=True, visible=True, opacity=1.0, array_args={}, client_args={'cors_all': False}, overwrite=False, **kwargs)
¶
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server (e.g., Binder, Microsoft Planetary Computer) and
if the raster does not render properly, try installing jupyter-server-proxy using pip install jupyter-server-proxy,
then running the following code before calling this function. For more info, see https://bit.ly/3JbmF93.
1 2 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF. |
required |
indexes
|
int
|
The band(s) to use. Band indexing starts at 1. Defaults to None. |
None
|
colormap
|
str
|
The name of the colormap from |
None
|
vmin
|
float
|
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
vmax
|
float
|
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
nodata
|
float
|
The value from the band to use to interpret as not valid data. Defaults to None. |
None
|
attribution
|
str
|
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to use. Defaults to 'Raster'. |
'Raster'
|
layer_index
|
int
|
The index of the layer. Defaults to None. |
None
|
zoom_to_layer
|
bool
|
Whether to zoom to the extent of the layer. Defaults to True. |
True
|
visible
|
bool
|
Whether the layer is visible. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
array_args
|
dict
|
Additional arguments to pass to |
{}
|
client_args
|
dict
|
Additional arguments to pass to localtileserver.TileClient. Defaults to { "cors_all": False }. |
{'cors_all': False}
|
overwrite
|
bool
|
Whether to overwrite an existing layer with the same name. Defaults to False. |
False
|
Source code in leafmap/leafmap.py
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 | |
add_remote_tile(source, band=None, palette=None, vmin=None, vmax=None, nodata=None, attribution=None, layer_name=None, **kwargs)
¶
Add a remote Cloud Optimized GeoTIFF (COG) to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The path to the remote Cloud Optimized GeoTIFF. |
required |
band
|
int
|
The band to use. Band indexing starts at 1. Defaults to None. |
None
|
palette
|
str
|
The name of the color palette from |
None
|
vmin
|
float
|
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
vmax
|
float
|
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
nodata
|
float
|
The value from the band to use to interpret as not valid data. Defaults to None. |
None
|
attribution
|
str
|
Attribution for the source raster. This defaults to a message about it being a local file.. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to use. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_search_control(url, marker=None, zoom=None, position='topleft', **kwargs)
¶
Adds a search control to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The url to the search API. For example, "https://nominatim.openstreetmap.org/search?format=json&q={s}". |
required |
marker
|
Marker
|
The marker to be used for the search result. Defaults to None. |
None
|
zoom
|
int
|
The zoom level to be used for the search result. Defaults to None. |
None
|
position
|
str
|
The position of the search control. Defaults to "topleft". |
'topleft'
|
kwargs
|
dict
|
Additional keyword arguments to be passed to the search control. See https://ipyleaflet.readthedocs.io/en/latest/api_reference/search_control.html |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_shp(in_shp, layer_name='Untitled', style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', zoom_to_layer=False, encoding='utf-8', **kwargs)
¶
Adds a shapefile to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shp
|
str
|
The input file path or HTTP URL (*.zip) to the shapefile. |
required |
layer_name
|
str
|
The layer name to be used.. Defaults to "Untitled". |
'Untitled'
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer after adding it to the map. Defaults to False. |
False
|
encoding
|
str
|
The encoding of the shapefile. Defaults to "utf-8". |
'utf-8'
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The provided shapefile could not be found. |
Source code in leafmap/leafmap.py
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 | |
add_stac_gui(position='topright', opened=True)
¶
Add the STAC search widget to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
str
|
The position of the widget. Defaults to "topright". |
'topright'
|
opened
|
bool
|
Whether the widget is open. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 | |
add_stac_layer(url=None, collection=None, item=None, assets=None, bands=None, titiler_endpoint=None, name='STAC Layer', attribution='', opacity=1.0, shown=True, fit_bounds=True, layer_index=None, **kwargs)
¶
Adds a STAC TileLayer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a STAC item, e.g., https://canada-spot-ortho.s3.amazonaws.com/canada_spot_orthoimages/canada_spot5_orthoimages/S5_2007/S5_11055_6057_20070622/S5_11055_6057_20070622.json |
None
|
collection
|
str
|
The Microsoft Planetary Computer STAC collection ID, e.g., landsat-8-c2-l2. |
None
|
item
|
str
|
The Microsoft Planetary Computer STAC item ID, e.g., LC08_L2SP_047027_20201204_02_T1. |
None
|
assets
|
str | list
|
The Microsoft Planetary Computer STAC asset ID, e.g., ["SR_B7", "SR_B5", "SR_B4"]. |
None
|
bands
|
list
|
A list of band names, e.g., ["SR_B7", "SR_B5", "SR_B4"] |
None
|
titiler_endpoint
|
str
|
TiTiler endpoint, e.g., "https://titiler.opengeos.org", "https://planetarycomputer.microsoft.com/api/data/v1", "planetary-computer", "pc". Defaults to None. |
None
|
name
|
str
|
The layer name to use for the layer. Defaults to 'STAC Layer'. |
'STAC Layer'
|
attribution
|
str
|
The attribution to use. Defaults to ''. |
''
|
opacity
|
float
|
The opacity of the layer. Defaults to 1. |
1.0
|
shown
|
bool
|
A flag indicating whether the layer should be on by default. Defaults to True. |
True
|
fit_bounds
|
bool
|
A flag indicating whether the map should be zoomed to the layer extent. Defaults to True. |
True
|
layer_index
|
int
|
The index at which to add the layer. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_text(text, fontsize=20, fontcolor='black', bold=False, padding='5px', background=True, bg_color='white', border_radius='5px', position='bottomright', **kwargs)
¶
Add text to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to add. |
required |
fontsize
|
int
|
The font size. Defaults to 20. |
20
|
fontcolor
|
str
|
The font color. Defaults to "black". |
'black'
|
bold
|
bool
|
Whether to use bold font. Defaults to False. |
False
|
padding
|
str
|
The padding. Defaults to "5px". |
'5px'
|
background
|
bool
|
Whether to use background. Defaults to True. |
True
|
bg_color
|
str
|
The background color. Defaults to "white". |
'white'
|
border_radius
|
str
|
The border radius. Defaults to "5px". |
'5px'
|
position
|
str
|
The position of the widget. Defaults to "bottomright". |
'bottomright'
|
Source code in leafmap/leafmap.py
5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 | |
add_tile_layer(url, name, attribution, opacity=1.0, shown=True, layer_index=None, **kwargs)
¶
Adds a TileLayer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the tile layer. |
required |
name
|
str
|
The layer name to use for the layer. |
required |
attribution
|
str
|
The attribution to use. |
required |
opacity
|
float
|
The opacity of the layer. Defaults to 1. |
1.0
|
shown
|
bool
|
A flag indicating whether the layer should be on by default. Defaults to True. |
True
|
layer_index
|
int
|
The index at which to add the layer. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_time_slider(layers={}, labels=None, time_interval=1, position='bottomright', slider_length='150px', zoom_to_layer=False, tile_args=None, **kwargs)
¶
Adds a time slider to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
dict
|
The dictionary containing a set of XYZ tile layers. |
{}
|
labels
|
list
|
The list of labels to be used for the time series. Defaults to None. |
None
|
time_interval
|
int
|
Time interval in seconds. Defaults to 1. |
1
|
position
|
str
|
Position to place the time slider, can be any of ['topleft', 'topright', 'bottomleft', 'bottomright']. Defaults to "bottomright". |
'bottomright'
|
slider_length
|
str
|
Length of the time slider. Defaults to "150px". |
'150px'
|
zoom_to_layer
|
bool
|
Whether to zoom to the extent of the selected layer. Defaults to False. |
False
|
tile_args
|
dict
|
Additional arguments to pass to the get_local_tile_layer function. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
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 | |
add_vector(filename, layer_name='Untitled', bbox=None, mask=None, rows=None, style={}, hover_style={}, style_callback=None, fill_colors=None, info_mode='on_hover', zoom_to_layer=False, encoding='utf-8', **kwargs)
¶
Adds any geopandas-supported vector dataset to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Either the absolute or relative path to the file or URL to be opened, or any object with a read() method (such as an open file or StringIO). |
required |
layer_name
|
str
|
The layer name to use. Defaults to "Untitled". |
'Untitled'
|
bbox
|
tuple | GeoDataFrame or GeoSeries | shapely Geometry
|
Filter features by given bounding box, GeoSeries, GeoDataFrame or a shapely geometry. CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame. Cannot be used with mask. Defaults to None. |
None
|
mask
|
dict | GeoDataFrame or GeoSeries | shapely Geometry
|
Filter for features that intersect with the given dict-like geojson geometry, GeoSeries, GeoDataFrame or shapely geometry. CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame. Cannot be used with bbox. Defaults to None. |
None
|
rows
|
int or slice
|
Load in specific rows by passing an integer (first n rows) or a slice() object.. Defaults to None. |
None
|
style
|
dict
|
A dictionary specifying the style to be used. Defaults to {}. |
{}
|
hover_style
|
dict
|
Hover style dictionary. Defaults to {}. |
{}
|
style_callback
|
function
|
Styling function that is called for each feature, and should return the feature style. This styling function takes the feature as argument. Defaults to None. |
None
|
fill_colors
|
list
|
The random colors to use for filling polygons. Defaults to ["black"]. |
None
|
info_mode
|
str
|
Displays the attributes by either on_hover or on_click. Any value other than "on_hover" or "on_click" will be treated as None. Defaults to "on_hover". |
'on_hover'
|
encoding
|
str
|
The encoding to use to read the file. Defaults to "utf-8". |
'utf-8'
|
Source code in leafmap/leafmap.py
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 | |
add_vector_tile(url, styles={}, layer_name='Vector Tile', **kwargs)
¶
Adds a VectorTileLayer to the map. It wraps the ipyleaflet.VectorTileLayer class. See https://ipyleaflet.readthedocs.io/en/latest/layers/vector_tile.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the tile layer |
required |
styles
|
(dict, optional)
|
Style dict, specific to the vector tile source. |
{}
|
layer_name
|
str
|
The layer name to use for the layer. Defaults to 'Vector Tile'. |
'Vector Tile'
|
kwargs
|
Additional keyword arguments to pass to the ipyleaflet.VectorTileLayer class. |
{}
|
Source code in leafmap/leafmap.py
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 | |
add_velocity(data, zonal_speed, meridional_speed, latitude_dimension='lat', longitude_dimension='lon', level_dimension='lev', level_index=0, time_index=0, velocity_scale=0.01, max_velocity=20, display_options={}, name='Velocity', color_scale=None)
¶
Add a velocity layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | Dataset
|
The data to use for the velocity layer. It can be a file path to a NetCDF file or an xarray Dataset. |
required |
zonal_speed
|
str
|
Name of the zonal speed in the dataset. See https://en.wikipedia.org/wiki/Zonal_and_meridional_flow. |
required |
meridional_speed
|
str
|
Name of the meridional speed in the dataset. See https://en.wikipedia.org/wiki/Zonal_and_meridional_flow. |
required |
latitude_dimension
|
str
|
Name of the latitude dimension in the dataset. Defaults to 'lat'. |
'lat'
|
longitude_dimension
|
str
|
Name of the longitude dimension in the dataset. Defaults to 'lon'. |
'lon'
|
level_dimension
|
str
|
Name of the level dimension in the dataset. Defaults to 'lev'. |
'lev'
|
level_index
|
int
|
The index of the level dimension to display. Defaults to 0. |
0
|
time_index
|
int
|
The index of the time dimension to display. Defaults to 0. |
0
|
velocity_scale
|
float
|
The scale of the velocity. Defaults to 0.01. |
0.01
|
max_velocity
|
int
|
The maximum velocity to display. Defaults to 20. |
20
|
display_options
|
dict
|
The display options for the velocity layer. Defaults to {}. See https://bit.ly/3uf8t6w. |
{}
|
name
|
str
|
Layer name to use . Defaults to 'Velocity'. |
'Velocity'
|
color_scale
|
list
|
List of RGB color values for the velocity vector color scale. Defaults to []. See https://bit.ly/3uf8t6w. |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If the xarray package is not installed. |
ValueError
|
If the data is not a NetCDF file or an xarray Dataset. |
Source code in leafmap/leafmap.py
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 | |
add_wayback_layer(date=None, name=None, attribution='Esri', quiet=False, **kwargs)
¶
Adds a Wayback layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
str
|
The date of the layer. Defaults to None. |
None
|
name
|
str
|
The name of the layer. Defaults to None. |
None
|
attribution
|
str
|
The attribution of the layer. Defaults to "Esri". |
'Esri'
|
**kwargs
|
Additional keyword arguments to pass to the add_tile_layer method. |
{}
|
Source code in leafmap/leafmap.py
6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 | |
add_wayback_layers(left_date='2014-02-20', right_date=None, widget_width='120px', add_layer_control=False, **kwargs)
¶
Adds a time series comparison of Wayback (ArcGIS Wayback) layers to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left_date
|
str
|
The initial date for the left layer in "YYYY-MM-DD" format. Defaults to "2014-02-20". |
'2014-02-20'
|
right_date
|
str
|
The initial date for the right layer in "YYYY-MM-DD" format. Defaults to None. |
None
|
widget_width
|
str
|
The width of the date pickers. Defaults to "120px". |
'120px'
|
add_layer_control
|
bool
|
If True, adds a layer control to the map. Defaults to True. |
False
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the cog_tile function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 | |
add_wayback_time_slider(**kwargs)
¶
Add a time slider for Wayback layers.
Source code in leafmap/leafmap.py
6892 6893 6894 6895 6896 6897 | |
add_widget(content, position='bottomright', add_header=False, opened=True, show_close_button=True, widget_icon='gear', close_button_icon='times', widget_args={}, close_button_args={}, display_widget=None, **kwargs)
¶
Add a widget (e.g., text, HTML, figure) to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str | Widget | object
|
The widget to add. |
required |
position
|
str
|
The position of the widget. Defaults to "bottomright". |
'bottomright'
|
add_header
|
bool
|
Whether to add a header with close buttons to the widget. Defaults to False. |
False
|
opened
|
bool
|
Whether to open the toolbar. Defaults to True. |
True
|
show_close_button
|
bool
|
Whether to show the close button. Defaults to True. |
True
|
widget_icon
|
str
|
The icon name for the toolbar button. Defaults to 'gear'. |
'gear'
|
close_button_icon
|
str
|
The icon name for the close button. Defaults to "times". |
'times'
|
widget_args
|
dict
|
Additional arguments to pass to the toolbar button. Defaults to {}. |
{}
|
close_button_args
|
dict
|
Additional arguments to pass to the close button. Defaults to {}. |
{}
|
display_widget
|
Widget
|
The widget to be displayed when the toolbar is clicked. |
None
|
**kwargs
|
Additional arguments to pass to the HTML or Output widgets |
{}
|
Source code in leafmap/leafmap.py
5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 | |
add_wms_layer(url, layers, name=None, attribution='', format='image/png', transparent=True, opacity=1.0, shown=True, **kwargs)
¶
Add a WMS layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the WMS web service. |
required |
layers
|
str
|
Comma-separated list of WMS layers to show. |
required |
name
|
str
|
The layer name to use on the layer control. Defaults to None. |
None
|
attribution
|
str
|
The attribution of the data layer. Defaults to ''. |
''
|
format
|
str
|
WMS image format (use ‘image/png’ for layers with transparency). Defaults to 'image/png'. |
'image/png'
|
transparent
|
bool
|
If True, the WMS service will return images with transparency. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
shown
|
bool
|
A flag indicating whether the layer should be on by default. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
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 | |
add_xy_data(in_csv, x='longitude', y='latitude', label=None, layer_name='Marker cluster')
¶
Adds points from a CSV file containing lat/lon information and display data on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
The file path to the input CSV file. |
required |
x
|
str
|
The name of the column containing longitude coordinates. Defaults to "longitude". |
'longitude'
|
y
|
str
|
The name of the column containing latitude coordinates. Defaults to "latitude". |
'latitude'
|
label
|
str
|
The name of the column containing label information to used for marker popup. Defaults to None. |
None
|
layer_name
|
str
|
The layer name to use. Defaults to "Marker cluster". |
'Marker cluster'
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The specified input csv does not exist. |
ValueError
|
The specified x column does not exist. |
ValueError
|
The specified y column does not exist. |
ValueError
|
The specified label column does not exist. |
Source code in leafmap/leafmap.py
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 | |
add_xyz_service(provider, **kwargs)
¶
Add a XYZ tile layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
A tile layer name starts with xyz or qms. For example, xyz.OpenTopoMap, |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
The provider is not valid. It must start with xyz or qms. |
Source code in leafmap/leafmap.py
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 | |
add_zarr(url, variable=None, name='Zarr Layer', attribution='', opacity=1.0, shown=True, titiler_endpoint=None, fit_bounds=True, layer_index=None, group=None, decode_times=False, time_index=0, **kwargs)
¶
Adds a Zarr dataset to the map as a tile layer.
This method uses titiler-xarray to dynamically serve tiles from Zarr datasets (local or remote). It supports both single-variable and multi-variable datasets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to a Zarr dataset (HTTP, S3, or local path). Examples: - "https://example.com/data.zarr" - "s3://bucket/data.zarr" |
required |
variable
|
str
|
The variable name to visualize. Required for multi-variable datasets. Defaults to None. |
None
|
name
|
str
|
The layer name. Defaults to "Zarr Layer". |
'Zarr Layer'
|
attribution
|
str
|
Attribution for the layer. Defaults to "". |
''
|
opacity
|
float
|
Layer opacity (0.0 to 1.0). Defaults to 1.0. |
1.0
|
shown
|
bool
|
Whether the layer is visible. Defaults to True. |
True
|
titiler_endpoint
|
str
|
TiTiler endpoint URL that supports titiler-xarray. If not provided, the endpoint is resolved automatically: the TITILER_XARRAY_ENDPOINT environment variable is checked first, and if it is not set, the library's default TiTiler endpoint is used. |
None
|
fit_bounds
|
bool
|
Zoom to layer extent. Defaults to True. |
True
|
layer_index
|
int
|
Index to insert the layer. Defaults to None. |
None
|
group
|
str
|
Zarr group path within the dataset. Defaults to None. |
None
|
decode_times
|
bool
|
Whether to decode times. Defaults to False. |
False
|
time_index
|
int
|
Index of the time dimension to visualize. Required for datasets with a time dimension. Defaults to 0 (first time step). Set to None if the dataset has no time dimension. |
0
|
**kwargs
|
Additional arguments passed to the titiler endpoint: - rescale (str): Value range, e.g., "0,255" - colormap_name (str): Colormap name, e.g., "viridis", "terrain" - colormap (str): JSON-encoded custom colormap - nodata (float): Nodata value - resampling (str): Resampling method (nearest, bilinear, etc.) - sel (str): Custom dimension selection, e.g., "time=5" |
{}
|
Example
m = leafmap.Map() url = "https://example.com/temperature.zarr" m.add_zarr(url, variable="temperature", colormap_name="viridis")
Source code in leafmap/leafmap.py
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 | |
basemap_demo()
¶
A demo for using leafmap basemaps.
Source code in leafmap/leafmap.py
2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 | |
batch_edit_lines(data, style=None, hover_style=None, highlight_style=None, changed_style=None, display_props=None, name='GeoJSON', text_width='250px', zoom_to_layer=True, **kwargs)
¶
Batch editing lines on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame, Dict[str, Any]]
|
The data to be edited, either as a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
style
|
Optional[Dict[str, Any]]
|
The style dictionary for the polygons. Defaults to None. |
None
|
hover_style
|
Optional[Dict[str, Any]]
|
The hover style dictionary for the polygons. Defaults to None. |
None
|
name
|
str
|
The name of the GeoJSON layer. Defaults to "GeoJSON". |
'GeoJSON'
|
widget_width
|
str
|
The width of the widgets. Defaults to "250px". |
required |
info_mode
|
str
|
The mode for displaying information, either "on_click" or "on_hover". Defaults to "on_click". |
required |
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not a GeoDataFrame or a GeoJSON dictionary. |
Source code in leafmap/leafmap.py
6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 | |
batch_edit_points(data, style=None, hover_style=None, changed_style=None, display_props=None, name='Points', text_width='250px', zoom_to_layer=True, **kwargs)
¶
Batch editing points (CircleMarkers) on the map from GeoJSON data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, dict]
|
The GeoJSON data or path to the GeoJSON file. |
required |
style
|
Optional[Dict[str, Any]]
|
Style for the CircleMarkers. |
None
|
hover_style
|
Optional[Dict[str, Any]]
|
Style for the CircleMarkers on hover. |
None
|
changed_style
|
Optional[Dict[str, Any]]
|
Style for the CircleMarkers when changed. |
None
|
display_props
|
Optional[List[str]]
|
List of properties to display in the attribute editor. |
None
|
name
|
str
|
Name of the layer group. |
'Points'
|
text_width
|
str
|
Width of the text widgets in the attribute editor. |
'250px'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the LayerGroup. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not a GeoDataFrame or a GeoJSON dictionary. |
ValueError
|
If the GeoJSON data does not contain only Point geometries. |
Source code in leafmap/leafmap.py
6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 | |
batch_edit_polygons(data, style=None, hover_style=None, highlight_style=None, changed_style=None, display_props=None, name='GeoJSON', text_width='250px', zoom_to_layer=True, **kwargs)
¶
Batch editing polygons on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame, Dict[str, Any]]
|
The data to be edited, either as a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
style
|
Optional[Dict[str, Any]]
|
The style dictionary for the polygons. Defaults to None. |
None
|
hover_style
|
Optional[Dict[str, Any]]
|
The hover style dictionary for the polygons. Defaults to None. |
None
|
name
|
str
|
The name of the GeoJSON layer. Defaults to "GeoJSON". |
'GeoJSON'
|
widget_width
|
str
|
The width of the widgets. Defaults to "250px". |
required |
info_mode
|
str
|
The mode for displaying information, either "on_click" or "on_hover". Defaults to "on_click". |
required |
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not a GeoDataFrame or a GeoJSON dictionary. |
Source code in leafmap/leafmap.py
6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 | |
clear_drawings()
¶
Clear drawings on the map.
Source code in leafmap/leafmap.py
5463 5464 5465 5466 5467 5468 | |
edit_lines(data, style=None, hover_style=None, name='GeoJSON', widget_width='250px', info_mode='on_click', zoom_to_layer=True, **kwargs)
¶
Edit lines on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame, Dict[str, Any]]
|
The data to be edited, either as a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
style
|
Optional[Dict[str, Any]]
|
The style dictionary for the lines. Defaults to None. |
None
|
hover_style
|
Optional[Dict[str, Any]]
|
The hover style dictionary for the lines. Defaults to None. |
None
|
name
|
str
|
The name of the GeoJSON layer. Defaults to "GeoJSON". |
'GeoJSON'
|
widget_width
|
str
|
The width of the widgets. Defaults to "250px". |
'250px'
|
info_mode
|
str
|
The mode for displaying information, either "on_click" or "on_hover". Defaults to "on_click". |
'on_click'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not a GeoDataFrame or a GeoJSON dictionary. |
Source code in leafmap/leafmap.py
5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 | |
edit_points(data, display_props=None, widget_width='250px', name='Points', radius=5, color='white', weight=1, fill_color='#3388ff', fill_opacity=0.6, **kwargs)
¶
Edit points on a map by creating interactive circle markers with popups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame, Dict[str, Any]]
|
The data source, which can be a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
display_props
|
Optional[List[str]]
|
List of properties to display in the popup. Defaults to None. |
None
|
widget_width
|
str
|
Width of the widget in the popup. Defaults to "250px". |
'250px'
|
name
|
str
|
Name of the layer group. Defaults to "Points". |
'Points'
|
radius
|
int
|
Initial radius of the circle markers. Defaults to 5. |
5
|
color
|
str
|
Outline color of the circle markers. Defaults to "white". |
'white'
|
weight
|
int
|
Outline weight of the circle markers. Defaults to 1. |
1
|
fill_color
|
str
|
Fill color of the circle markers. Defaults to "#3388ff". |
'#3388ff'
|
fill_opacity
|
float
|
Fill opacity of the circle markers. Defaults to 0.6. |
0.6
|
**kwargs
|
Any
|
Additional arguments for the CircleMarker. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 | |
edit_polygons(data, style=None, hover_style=None, name='GeoJSON', widget_width='250px', info_mode='on_click', zoom_to_layer=True, **kwargs)
¶
Edit polygons on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, GeoDataFrame, Dict[str, Any]]
|
The data to be edited, either as a file path, GeoDataFrame, or GeoJSON dictionary. |
required |
style
|
Optional[Dict[str, Any]]
|
The style dictionary for the polygons. Defaults to None. |
None
|
hover_style
|
Optional[Dict[str, Any]]
|
The hover style dictionary for the polygons. Defaults to None. |
None
|
name
|
str
|
The name of the GeoJSON layer. Defaults to "GeoJSON". |
'GeoJSON'
|
widget_width
|
str
|
The width of the widgets. Defaults to "250px". |
'250px'
|
info_mode
|
str
|
The mode for displaying information, either "on_click" or "on_hover". Defaults to "on_click". |
'on_click'
|
zoom_to_layer
|
bool
|
Whether to zoom to the layer bounds. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the GeoJSON layer. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the data is not a GeoDataFrame or a GeoJSON dictionary. |
Source code in leafmap/leafmap.py
5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 | |
edit_vector(data, **kwargs)
¶
Edit a vector layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict | str
|
The data to edit. It can be a GeoJSON dictionary or a file path. |
required |
Source code in leafmap/leafmap.py
4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 | |
find_layer(name)
¶
Finds layer by name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
object |
ipyleaflet layer object. |
Source code in leafmap/leafmap.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
find_layer_index(name)
¶
Finds layer index by name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Index of the layer with the specified name |
Source code in leafmap/leafmap.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
get_bbox()
¶
Get the bounds of the map as a list of [(]minx, miny, maxx, maxy].
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The bounds of the map as a list of [(]minx, miny, maxx, maxy]. |
Source code in leafmap/leafmap.py
5359 5360 5361 5362 5363 5364 5365 5366 5367 | |
get_draw_props(n=None, return_df=False)
¶
Get the properties of the draw features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The maximum number of attributes to return. Defaults to None. |
None
|
return_df
|
bool
|
If True, return a pandas dataframe. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A pandas dataframe containing the properties of the draw features. |
Source code in leafmap/leafmap.py
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 | |
get_layer_names()
¶
Gets layer names as a list.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list of layer names. |
Source code in leafmap/leafmap.py
300 301 302 303 304 305 306 307 308 309 310 311 312 | |
get_pc_collections()
¶
Get the list of Microsoft Planetary Computer collections.
Source code in leafmap/leafmap.py
4737 4738 4739 4740 | |
get_scale()
¶
Returns the approximate pixel scale of the current map view, in meters.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Map resolution in meters. |
Source code in leafmap/leafmap.py
287 288 289 290 291 292 293 294 295 296 297 298 | |
image_overlay(url, bounds, name)
¶
Overlays an image from the Internet or locally on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
http URL or local file path to the image. |
required |
bounds
|
tuple
|
bounding box of the image in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)). |
required |
name
|
str
|
name of the layer to show on the layer control. |
required |
Source code in leafmap/leafmap.py
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 | |
layer_opacity(name, value=1.0)
¶
Changes layer opacity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer to change opacity. |
required |
value
|
float
|
The opacity value to set. Defaults to 1.0. |
1.0
|
Source code in leafmap/leafmap.py
519 520 521 522 523 524 525 526 527 528 529 530 | |
marker_cluster(event='click', add_marker=True)
¶
Captures user inputs and add markers to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
str
|
[description]. Defaults to 'click'. |
'click'
|
add_marker
|
bool
|
If True, add markers to the map. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
object |
a marker cluster. |
Source code in leafmap/leafmap.py
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 | |
oam_search(bbox=None, start_date=None, end_date=None, limit=100, info_mode='on_click', layer_args={}, add_image=True, **kwargs)
¶
Search OpenAerialMap for images within a bounding box and time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
list | str
|
The bounding box [xmin, ymin, xmax, ymax] to search within. Defaults to None. |
None
|
start_date
|
str
|
The start date to search within, such as "2015-04-20T00:00:00.000Z". Defaults to None. |
None
|
end_date
|
str
|
The end date to search within, such as "2015-04-21T00:00:00.000Z". Defaults to None. |
None
|
limit
|
int
|
The maximum number of results to return. Defaults to 100. |
100
|
info_mode
|
str
|
The mode to use for the info popup. Can be 'on_hover' or 'on_click'. Defaults to 'on_click'. |
'on_click'
|
layer_args
|
dict
|
The layer arguments for add_gdf() function. Defaults to {}. |
{}
|
add_image
|
bool
|
Whether to add the first 10 images to the map. Defaults to True. |
True
|
**kwargs
|
Additional keyword arguments to pass to the API. See https://hotosm.github.io/oam-api/ |
{}
|
Source code in leafmap/leafmap.py
5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 | |
remove(widget)
¶
Removes a widget to the map.
Source code in leafmap/leafmap.py
5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 | |
remove_labels()
¶
Removes all labels from the map.
Source code in leafmap/leafmap.py
4533 4534 4535 4536 4537 | |
save_draw_features(out_file, crs='EPSG:4326', **kwargs)
¶
Save the draw features to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_file
|
str
|
The output file path. |
required |
crs
|
str
|
The CRS of the output GeoJSON. Defaults to "EPSG:4326". |
'EPSG:4326'
|
Source code in leafmap/leafmap.py
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 | |
save_edits(filename, drop_style=True, crs='EPSG:4326', **kwargs)
¶
Save the edited GeoJSON data to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to save the edited GeoJSON data. |
required |
drop_style
|
bool
|
Whether to drop the style properties from the GeoJSON data. Defaults to True. |
True
|
crs
|
str
|
The CRS of the GeoJSON data. Defaults to "EPSG:4326". |
'EPSG:4326'
|
**kwargs
|
Any
|
Additional arguments passed to the GeoDataFrame |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/leafmap.py
5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 | |
set_catalog_source(source)
¶
Set the catalog source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog_source
|
str
|
The catalog source. Defaults to "landsat". |
required |
Source code in leafmap/leafmap.py
5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 | |
set_center(lon, lat, zoom=None)
¶
Centers the map view at a given coordinates with the given zoom level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
float
|
The longitude of the center, in degrees. |
required |
lat
|
float
|
The latitude of the center, in degrees. |
required |
zoom
|
int
|
The zoom level, from 1 to 24. Defaults to None. |
None
|
Source code in leafmap/leafmap.py
257 258 259 260 261 262 263 264 265 266 267 | |
split_map(left_layer='TERRAIN', right_layer='OpenTopoMap', left_args={}, right_args={}, left_array_args={}, right_array_args={}, zoom_control=True, fullscreen_control=True, layer_control=True, add_close_button=False, left_label=None, right_label=None, left_position='bottomleft', right_position='bottomright', widget_layout=None, draggable=True)
¶
Adds split map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left_layer
|
str
|
The left tile layer. Can be a local file path, HTTP URL, or a basemap name. Defaults to 'TERRAIN'. |
'TERRAIN'
|
right_layer
|
str
|
The right tile layer. Can be a local file path, HTTP URL, or a basemap name. Defaults to 'OpenTopoMap'. |
'OpenTopoMap'
|
left_args
|
dict
|
The arguments for the left tile layer. Defaults to {}. |
{}
|
right_args
|
dict
|
The arguments for the right tile layer. Defaults to {}. |
{}
|
left_array_args
|
dict
|
The arguments for array_to_image for the left layer. Defaults to {}. |
{}
|
right_array_args
|
dict
|
The arguments for array_to_image for the right layer. Defaults to {}. |
{}
|
zoom_control
|
bool
|
Whether to add zoom control. Defaults to True. |
True
|
fullscreen_control
|
bool
|
Whether to add fullscreen control. Defaults to True. |
True
|
layer_control
|
bool
|
Whether to add layer control. Defaults to True. |
True
|
add_close_button
|
bool
|
Whether to add a close button. Defaults to False. |
False
|
left_label
|
str
|
The label for the left layer. Defaults to None. |
None
|
right_label
|
str
|
The label for the right layer. Defaults to None. |
None
|
left_position
|
str
|
The position for the left label. Defaults to "bottomleft". |
'bottomleft'
|
right_position
|
str
|
The position for the right label. Defaults to "bottomright". |
'bottomright'
|
widget_layout
|
dict
|
The layout for the widget. Defaults to None. |
None
|
draggable
|
bool
|
Whether the split map is draggable. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
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 | |
static_map(width=950, height=600, out_file=None, **kwargs)
¶
Display an ipyleaflet static map in a Jupyter Notebook.
Args m (ipyleaflet.Map): An ipyleaflet map. width (int, optional): Width of the map. Defaults to 950. height (int, optional): Height of the map. Defaults to 600. read_only (bool, optional): Whether to hide the side panel to disable map customization. Defaults to False. out_file (str, optional): Output html file path. Defaults to None.
Source code in leafmap/leafmap.py
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 | |
to_html(outfile=None, title='My Map', width='100%', height='880px', add_layer_control=True, **kwargs)
¶
Saves the map as an HTML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outfile
|
str
|
The output file path to the HTML file. |
None
|
title
|
str
|
The title of the HTML file. Defaults to 'My Map'. |
'My Map'
|
width
|
str
|
The width of the map in pixels or percentage. Defaults to '100%'. |
'100%'
|
height
|
str
|
The height of the map in pixels. Defaults to '880px'. |
'880px'
|
add_layer_control
|
bool
|
Whether to add the LayersControl. Defaults to True. |
True
|
Source code in leafmap/leafmap.py
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 | |
to_image(outfile=None, monitor=1)
¶
Saves the map as a PNG or JPG image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outfile
|
str
|
The output file path to the image. Defaults to None. |
None
|
monitor
|
int
|
The monitor to take the screenshot. Defaults to 1. |
1
|
Source code in leafmap/leafmap.py
2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 | |
to_streamlit(width=None, height=600, scrolling=False, **kwargs)
¶
Renders map figure in a Streamlit app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Width of the map. Defaults to None. |
None
|
height
|
int
|
Height of the map. Defaults to 600. |
600
|
responsive
|
bool
|
Whether to make the map responsive. Defaults to True. |
required |
scrolling
|
bool
|
If True, show a scrollbar when the content is larger than the iframe. Otherwise, do not show a scrollbar. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
streamlit.components: components.html object. |
Source code in leafmap/leafmap.py
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 | |
toolbar_reset()
¶
Reset the toolbar so that no tool is selected.
Source code in leafmap/leafmap.py
2792 2793 2794 2795 2796 | |
update_draw_features()
¶
Update the draw features by removing features that have been edited and no longer exist.
Source code in leafmap/leafmap.py
4770 4771 4772 4773 4774 4775 4776 4777 | |
update_draw_props(df)
¶
Update the draw features properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
A pandas dataframe containing the properties of the draw features. |
required |
Source code in leafmap/leafmap.py
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 | |
update_layer_manager()
¶
Update the Layer Manager.
Source code in leafmap/leafmap.py
5482 5483 5484 5485 5486 5487 5488 | |
user_roi_bounds(decimals=4)
¶
Get the bounds of the user drawn ROI as a tuple of (minx, miny, maxx, maxy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
decimals
|
int
|
The number of decimals to round the coordinates to. Defaults to 4. |
4
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
The bounds of the user drawn ROI as a tuple of (minx, miny, maxx, maxy). |
Source code in leafmap/leafmap.py
5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 | |
video_overlay(url, bounds, layer_name=None, **kwargs)
¶
Overlays a video from the Internet on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
http URL of the video, such as "https://www.mapbox.com/bites/00188/patricia_nasa.webm" |
required |
bounds
|
tuple
|
bounding box of the video in the format of (lower_left(lat, lon), upper_right(lat, lon)), such as ((13, -130), (32, -100)). |
required |
layer_name
|
str
|
name of the layer to show on the layer control. |
None
|
Source code in leafmap/leafmap.py
2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 | |
zoom_to_bounds(bounds)
¶
Zooms to a bounding box in the form of [minx, miny, maxx, maxy].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
list | tuple
|
A list/tuple containing minx, miny, maxx, maxy values for the bounds. |
required |
Source code in leafmap/leafmap.py
269 270 271 272 273 274 275 276 | |
zoom_to_gdf(gdf)
¶
Zooms to the bounding box of a GeoPandas GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoPandas GeoDataFrame. |
required |
Source code in leafmap/leafmap.py
278 279 280 281 282 283 284 285 | |
PlanetaryComputerEndpoint
¶
Bases: TitilerEndpoint
This class contains the methods for the Microsoft Planetary Computer endpoint.
Source code in leafmap/stac.py
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 | |
__init__(endpoint='https://planetarycomputer.microsoft.com/api/data/v1', name='item', TileMatrixSetId='WebMercatorQuad')
¶
Initialize the PlanetaryComputerEndpoint object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The endpoint of the titiler server. Defaults to "https://planetarycomputer.microsoft.com/api/data/v1". |
'https://planetarycomputer.microsoft.com/api/data/v1'
|
name
|
str
|
The name to be used in the file path. Defaults to "item". |
'item'
|
TileMatrixSetId
|
str
|
The TileMatrixSetId to be used in the file path. Defaults to "WebMercatorQuad". |
'WebMercatorQuad'
|
Source code in leafmap/stac.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
The_national_map_USGS
¶
The national map is a collection of topological datasets, maintained by the USGS.
It provides an API endpoint which can be used to find downloadable links for the products offered. - Full description of datasets available can retrieved. This consists of metadata such as detail description and publication dates. - A wide range of dataformats are available
This class is a tiny wrapper to find and download files using the API.
More complete documentation for the API can be found at https://apps.nationalmap.gov/tnmaccess/#/
Source code in leafmap/common.py
6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 | |
datasets
property
¶
Returns a list of dataset tags (most common human readable self description for specific datasets).
datasets_full
property
¶
Full description of datasets provided. Returns a JSON or empty list.
prodFormats
property
¶
Return all datatypes available in any of the collections. Note that "All" is only peculiar to one dataset.
download_tiles(region=None, out_dir=None, download_args={}, geopandas_args={}, API={})
¶
Download the US National Elevation Datasets (NED) for a region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str | list
|
An URL|filepath to a vector dataset Or a list of bounds in the form of [minx, miny, maxx, maxy]. Alternatively you could use API parameters such as polygon or bbox. |
None
|
out_dir
|
str
|
The directory to download the files to. Defaults to None, which uses the current working directory. |
None
|
download_args
|
dict
|
A dictionary of arguments to pass to the download_file function. Defaults to {}. |
{}
|
geopandas_args
|
dict
|
A dictionary of arguments to pass to the geopandas.read_file() function. Used for reading a region URL|filepath. |
{}
|
API
|
dict
|
A dictionary of arguments to pass to the self.find_details() function. Exposes most of the documented API. Defaults to {}. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 | |
find_details(bbox=None, polygon=None, datasets=None, prodFormats=None, prodExtents=None, q=None, dateType=None, start=None, end=None, offset=0, max=None, outputFormat='JSON', polyType=None, polyCode=None, extentQuery=None)
¶
Possible search parameters (kwargs) support by API
Parameter Values Description
bbox 'minx, miny, maxx, maxy' Geographic longitude/latitude values expressed in decimal degrees in a comma-delimited list. polygon '[x,y x,y x,y x,y x,y]' Polygon, longitude/latitude values expressed in decimal degrees in a space-delimited list. datasets See: Datasets (Optional) Dataset tag name (sbDatasetTag) From https://apps.nationalmap.gov/tnmaccess/#/product prodFormats See: Product Formats (Optional) Dataset-specific format
Product Extents (Optional)
Dataset-specific extent
q free text Text input which can be used to filter by product titles and text descriptions. dateType dateCreated | lastUpdated | Publication Type of date to search by. start 'YYYY-MM-DD' Start date end 'YYYY-MM-DD' End date (required if start date is provided) offset integer Offset into paginated results - default=0 max integer Number of results returned outputFormat JSON | CSV | pjson Default=JSON polyType state | huc2 | huc4 | huc8 Well Known Polygon Type. Use this parameter to deliver data by state or HUC (hydrologic unit codes defined by the Watershed Boundary Dataset/WBD) polyCode state FIPS code or huc number Well Known Polygon Code. This value needs to coordinate with the polyType parameter. extentQuery integer A Polygon code in the science base system, typically from an uploaded shapefile
Source code in leafmap/common.py
6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 | |
find_tiles(region=None, return_type='list', geopandas_args={}, API={})
¶
Find a list of downloadable files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str | list
|
An URL|filepath to a vector dataset Or a list of bounds in the form of [minx, miny, maxx, maxy]. Alternatively you could use API parameters such as polygon or bbox. |
None
|
return_type
|
str
|
list | dict. Defaults to list. Changes the return output type and content. |
'list'
|
geopandas_args
|
dict
|
A dictionary of arguments to pass to the geopandas.read_file() function. Used for reading a region URL|filepath. |
{}
|
API
|
dict
|
A dictionary of arguments to pass to the self.find_details() function. Exposes most of the documented API parameters. Defaults to {}. |
{}
|
Returns:
| Type | Description |
|---|---|
Union[List[str], Dict]
|
A list of download URLs if return_type is 'list', otherwise a dictionary with URLs and related metadata. |
Source code in leafmap/common.py
6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 | |
parse_region(region, geopandas_args={})
¶
Translate a Vector dataset to its bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str | list
|
an URL|filepath to a vector dataset to a polygon |
required |
geopandas_args
|
dict
|
A dictionary of arguments to pass to the geopandas.read_file() function. Used for reading a region URL|filepath. |
{}
|
Source code in leafmap/common.py
6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 | |
TitilerCMREndpoint
¶
This class contains the methods for the TiTiler CMR endpoint.
Source code in leafmap/stac.py
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 | |
__init__(endpoint=None, TileMatrixSetId='WebMercatorQuad')
¶
Initialize the TitilerCMREndpoint object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The TiTiler CMR endpoint URL. Defaults to "https://staging.openveda.cloud/api/titiler-cmr". |
None
|
TileMatrixSetId
|
str
|
The TileMatrixSetId. Defaults to "WebMercatorQuad". |
'WebMercatorQuad'
|
Source code in leafmap/stac.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
url_for_statistics()
¶
Get the URL for the statistics endpoint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
The statistics endpoint URL. |
Source code in leafmap/stac.py
170 171 172 173 174 175 176 | |
url_for_tilejson()
¶
Get the URL for the TileJSON endpoint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
The TileJSON endpoint URL. |
Source code in leafmap/stac.py
140 141 142 143 144 145 146 | |
url_for_timeseries()
¶
Get the URL for the time series endpoint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
The time series endpoint URL. |
Source code in leafmap/stac.py
186 187 188 189 190 191 192 | |
url_for_timeseries_gif(bbox, width=512, height=512)
¶
Get the URL for the time series animated GIF endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
list | tuple
|
Bounding box as [minx, miny, maxx, maxy]. |
required |
width
|
int
|
Width of the GIF in pixels. Defaults to 512. |
512
|
height
|
int
|
Height of the GIF in pixels. Defaults to 512. |
512
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
The time series GIF endpoint URL. |
Source code in leafmap/stac.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
url_for_timeseries_statistics()
¶
Get the URL for the time series statistics endpoint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
The time series statistics endpoint URL. |
Source code in leafmap/stac.py
178 179 180 181 182 183 184 | |
url_for_timeseries_tilejson()
¶
Get the URL for the time series TileJSON endpoint.
Returns:
| Name | Type | Description |
|---|---|---|
str |
The time series TileJSON endpoint URL. |
Source code in leafmap/stac.py
148 149 150 151 152 153 154 | |
TitilerEndpoint
¶
This class contains the methods for the titiler endpoint.
Source code in leafmap/stac.py
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 | |
__init__(endpoint=None, name='stac', TileMatrixSetId='WebMercatorQuad')
¶
Initialize the TiTilerEndpoint object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The endpoint of the titiler server. Defaults to "https://titiler.opengeos.org". |
None
|
name
|
str
|
The name to be used in the file path. Defaults to "stac". |
'stac'
|
TileMatrixSetId
|
str
|
The TileMatrixSetId to be used in the file path. Defaults to "WebMercatorQuad". |
'WebMercatorQuad'
|
Source code in leafmap/stac.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
WhiteboxTools
¶
Bases: WhiteboxTools
This class inherits the whitebox WhiteboxTools class.
Source code in leafmap/common.py
37 38 39 40 41 | |
add_crs(filename, epsg)
¶
Add a CRS to a raster dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename of the raster dataset. |
required |
epsg
|
int | str
|
The EPSG code of the CRS. |
required |
Source code in leafmap/common.py
6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 | |
add_image_to_gif(in_gif, out_gif, in_image, xy=None, image_size=(80, 80), circle_mask=False)
¶
Adds an image logo to a GIF image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_gif
|
str
|
Input file path to the GIF image. |
required |
out_gif
|
str
|
Output file path to the GIF image. |
required |
in_image
|
str
|
Input file path to the image. |
required |
xy
|
tuple
|
Top left corner of the text. It can be formatted like this: (10, 10) or ('15%', '25%'). Defaults to None. |
None
|
image_size
|
tuple
|
Resize image. Defaults to (80, 80). |
(80, 80)
|
circle_mask
|
bool
|
Whether to apply a circle mask to the image. This only works with non-png images. Defaults to False. |
False
|
Source code in leafmap/common.py
8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 | |
add_mask_to_image(image, mask, output, color='red')
¶
Overlay a binary mask (e.g., roads, building footprints, etc) on an image. Credits to Xingjian Shi for the sample code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
A local path or HTTP URL to an image. |
required |
mask
|
str
|
A local path or HTTP URL to a binary mask. |
required |
output
|
str
|
A local path to the output image. |
required |
color
|
str
|
Color of the mask. Defaults to 'red'. |
'red'
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If rasterio and detectron2 are not installed. |
Source code in leafmap/common.py
7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 | |
add_progress_bar_to_gif(in_gif, out_gif, progress_bar_color='blue', progress_bar_height=5, duration=100, loop=0)
¶
Adds a progress bar to a GIF image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_gif
|
str
|
The file path to the input GIF image. |
required |
out_gif
|
str
|
The file path to the output GIF image. |
required |
progress_bar_color
|
str
|
Color for the progress bar. Defaults to 'white'. |
'blue'
|
progress_bar_height
|
int
|
Height of the progress bar. Defaults to 5. |
5
|
duration
|
int
|
controls how long each frame will be displayed for, in milliseconds. It is the inverse of the frame rate. Setting it to 100 milliseconds gives 10 frames per second. You can decrease the duration to give a smoother animation. Defaults to 100. |
100
|
loop
|
int
|
controls how many times the animation repeats. The default, 1, means that the animation will play once and then stop (displaying the last frame). A value of 0 means that the animation will repeat forever. Defaults to 0. |
0
|
Source code in leafmap/common.py
8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 | |
add_text_to_gif(in_gif, out_gif, xy=None, text_sequence=None, font_type='arial.ttf', font_size=20, font_color='#000000', add_progress_bar=True, progress_bar_color='white', progress_bar_height=5, duration=100, loop=0)
¶
Adds animated text to a GIF image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_gif
|
str
|
The file path to the input GIF image. |
required |
out_gif
|
str
|
The file path to the output GIF image. |
required |
xy
|
tuple
|
Top left corner of the text. It can be formatted like this: (10, 10) or ('15%', '25%'). Defaults to None. |
None
|
text_sequence
|
(int, str, list)
|
Text to be drawn. It can be an integer number, a string, or a list of strings. Defaults to None. |
None
|
font_type
|
str
|
Font type. Defaults to "arial.ttf". |
'arial.ttf'
|
font_size
|
int
|
Font size. Defaults to 20. |
20
|
font_color
|
str
|
Font color. It can be a string (e.g., 'red'), rgb tuple (e.g., (255, 127, 0)), or hex code (e.g., '#ff00ff'). Defaults to '#000000'. |
'#000000'
|
add_progress_bar
|
bool
|
Whether to add a progress bar at the bottom of the GIF. Defaults to True. |
True
|
progress_bar_color
|
str
|
Color for the progress bar. Defaults to 'white'. |
'white'
|
progress_bar_height
|
int
|
Height of the progress bar. Defaults to 5. |
5
|
duration
|
int
|
controls how long each frame will be displayed for, in milliseconds. It is the inverse of the frame rate. Setting it to 100 milliseconds gives 10 frames per second. You can decrease the duration to give a smoother animation.. Defaults to 100. |
100
|
loop
|
int
|
controls how many times the animation repeats. The default, 1, means that the animation will play once and then stop (displaying the last frame). A value of 0 means that the animation will repeat forever. Defaults to 0. |
0
|
Source code in leafmap/common.py
7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 | |
add_unique_class(data, column, class_column='class', mapping=None)
¶
Add a unique integer class column to a vector dataset based on an existing column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str or GeoDataFrame
|
Input vector data as file path or GeoDataFrame. |
required |
column
|
str
|
The column name used for generating unique classes. |
required |
class_column
|
str
|
The name of the new column to store integer classes. Default is "class". |
'class'
|
mapping
|
dict
|
A dictionary mapping original values to integer classes. If not provided, a mapping will be generated automatically starting from 1. |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The updated GeoDataFrame with the new class column. |
Source code in leafmap/common.py
19500 19501 19502 19503 19504 19505 19506 19507 19508 19509 19510 19511 19512 19513 19514 19515 19516 19517 19518 19519 19520 19521 19522 19523 19524 19525 19526 19527 19528 19529 19530 19531 19532 | |
adjust_longitude(in_fc)
¶
Adjusts longitude if it is less than -180 or greater than 180.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_fc
|
dict
|
The input dictionary containing coordinates. |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
A dictionary containing the converted longitudes. |
Source code in leafmap/common.py
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 | |
arc_active_map()
¶
Get the active map in ArcGIS Pro.
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
The active map in ArcGIS Pro. |
Source code in leafmap/common.py
9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 | |
arc_active_view()
¶
Get the active view in ArcGIS Pro.
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
The active view in ArcGIS Pro. |
Source code in leafmap/common.py
9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 | |
arc_add_layer(url, name=None, shown=True, opacity=1.0)
¶
Add a layer to the active map in ArcGIS Pro.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the tile layer to add. |
required |
name
|
str
|
The name of the layer. Defaults to None. |
None
|
shown
|
bool
|
Whether the layer is shown. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
Source code in leafmap/common.py
9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 | |
arc_zoom_to_bounds(bounds)
¶
Zoom to a bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
list
|
The bounding box to zoom to in the form [xmin, ymin, xmax, ymax] or [(ymin, xmin), (ymax, xmax)]. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
description |
Source code in leafmap/common.py
9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 | |
arc_zoom_to_extent(xmin, ymin, xmax, ymax)
¶
Zoom to an extent in ArcGIS Pro.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xmin
|
float
|
The minimum x value of the extent. |
required |
ymin
|
float
|
The minimum y value of the extent. |
required |
xmax
|
float
|
The maximum x value of the extent. |
required |
ymax
|
float
|
The maximum y value of the extent. |
required |
Source code in leafmap/common.py
9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 | |
array_to_image(array, output=None, source=None, dtype=None, compress='deflate', transpose=True, cellsize=None, crs=None, transform=None, driver='COG', colormap=None, **kwargs)
¶
Save a NumPy array as a GeoTIFF using the projection information from an existing GeoTIFF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
The NumPy array to be saved as a GeoTIFF. |
required |
output
|
str
|
The path to the output image. If None, a temporary file will be created. Defaults to None. |
None
|
source
|
str
|
The path to an existing GeoTIFF file with map projection information. Defaults to None. |
None
|
dtype
|
dtype
|
The data type of the output array. Defaults to None. |
None
|
compress
|
str
|
The compression method. Can be one of the following: "deflate", "lzw", "packbits", "jpeg". Defaults to "deflate". |
'deflate'
|
transpose
|
bool
|
Whether to transpose the array from (bands, rows, columns) to (rows, columns, bands). Defaults to True. |
True
|
cellsize
|
float
|
The resolution of the output image in meters. Defaults to None. |
None
|
crs
|
str
|
The CRS of the output image. Defaults to None. |
None
|
transform
|
tuple
|
The affine transformation matrix, can be rio.transform() or a tuple like (0.5, 0.0, -180.25, 0.0, -0.5, 83.780361). Defaults to None. |
None
|
driver
|
str
|
The driver to use for creating the output file, such as 'GTiff'. Defaults to "COG". |
'COG'
|
colormap
|
dict
|
A dictionary defining the colormap (value: (R, G, B, A)). |
None
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the rasterio.open() function. |
{}
|
Source code in leafmap/common.py
11808 11809 11810 11811 11812 11813 11814 11815 11816 11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828 11829 11830 11831 11832 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 11954 11955 11956 11957 11958 11959 11960 11961 11962 11963 11964 11965 11966 11967 11968 11969 11970 11971 11972 11973 11974 11975 11976 11977 11978 11979 11980 11981 11982 11983 11984 11985 11986 11987 11988 11989 11990 11991 11992 11993 | |
array_to_memory_file(array, source=None, dtype=None, compress='deflate', transpose=True, cellsize=None, crs=None, transform=None, driver='COG', colormap=None, **kwargs)
¶
Convert a NumPy array to a memory file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
The input NumPy array. |
required |
source
|
str
|
Path to the source file to extract metadata from. Defaults to None. |
None
|
dtype
|
str
|
The desired data type of the array. Defaults to None. |
None
|
compress
|
str
|
The compression method for the output file. Defaults to "deflate". |
'deflate'
|
transpose
|
bool
|
Whether to transpose the array from (bands, rows, columns) to (rows, columns, bands). Defaults to True. |
True
|
cellsize
|
float
|
The cell size of the array if source is not provided. Defaults to None. |
None
|
crs
|
str
|
The coordinate reference system of the array if source is not provided. Defaults to None. |
None
|
transform
|
tuple
|
The affine transformation matrix if source is not provided. Can be rio.transform() or a tuple like (0.5, 0.0, -180.25, 0.0, -0.5, 83.780361). Defaults to None. |
None
|
driver
|
str
|
The driver to use for creating the output file, such as 'GTiff'. Defaults to "COG". |
'COG'
|
colormap
|
dict
|
A dictionary defining the colormap (value: (R, G, B, A)). |
None
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the rasterio.open() function. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The rasterio dataset reader object for the converted array. |
Source code in leafmap/common.py
11638 11639 11640 11641 11642 11643 11644 11645 11646 11647 11648 11649 11650 11651 11652 11653 11654 11655 11656 11657 11658 11659 11660 11661 11662 11663 11664 11665 11666 11667 11668 11669 11670 11671 11672 11673 11674 11675 11676 11677 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 11693 11694 11695 11696 11697 11698 11699 11700 11701 11702 11703 11704 11705 11706 11707 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 11754 11755 11756 11757 11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 11774 11775 11776 11777 11778 11779 11780 11781 11782 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 | |
assign_continuous_colors(df, column, cmap=None, colors=None, labels=None, scheme='Quantiles', k=5, legend_kwds=None, classification_kwds=None, to_rgb=True, return_type='array', return_legend=False)
¶
Assigns continuous colors to a DataFrame column based on a specified scheme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
A pandas DataFrame. |
required |
column
|
str
|
The name of the column to assign colors. |
required |
cmap
|
str
|
The name of the colormap to use. |
None
|
colors
|
list
|
A list of custom colors. |
None
|
labels
|
list
|
A list of custom labels for the legend. |
None
|
scheme
|
str
|
The scheme for classifying the data. Default is 'Quantiles'. |
'Quantiles'
|
k
|
int
|
The number of classes for classification. |
5
|
legend_kwds
|
dict
|
Additional keyword arguments for configuring the legend. |
None
|
classification_kwds
|
dict
|
Additional keyword arguments for configuring the classification. |
None
|
to_rgb
|
bool
|
Whether to convert colors to RGB values. Default is True. |
True
|
return_type
|
str
|
The type of the returned values. Default is 'array'. |
'array'
|
return_legend
|
bool
|
Whether to return the legend. Default is False. |
False
|
Returns:
| Type | Description |
|---|---|
Union[ndarray, Tuple[ndarray, dict]]
|
The assigned colors as a numpy array or a tuple containing the colors and the legend, depending on the value of return_legend. |
Source code in leafmap/common.py
15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 | |
assign_discrete_colors(df, column, cmap, to_rgb=True, return_type='array')
¶
Assigns unique colors to each category in a categorical column of a dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The input dataframe. |
required |
column
|
str
|
The name of the categorical column. |
required |
cmap
|
dict
|
A dictionary mapping categories to colors. |
required |
to_rgb
|
bool
|
Whether to convert the colors to RGB values. Defaults to True. |
True
|
return_type
|
str
|
The type of the returned values. Can be 'list' or 'array'. Defaults to 'array'. |
'array'
|
Returns:
| Type | Description |
|---|---|
Union[List, ndarray]
|
A list of colors for each category in the categorical column. |
Source code in leafmap/common.py
15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 | |
bar_chart(data=None, x=None, y=None, color=None, descending=True, sort_column=None, max_rows=None, x_label=None, y_label=None, title=None, legend_title=None, width=None, height=500, layout_args={}, **kwargs)
¶
Create a bar chart with plotly.express,
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame | array-like | dict | str (local file path or HTTP URL) This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constructed under the hood using the other arguments. |
None
|
|
x
|
str or int or Series or array-like
Either a name of a column in |
None
|
|
y
|
str or int or Series or array-like
Either a name of a column in |
None
|
|
color
|
str or int or Series or array-like
Either a name of a column in |
None
|
|
descending
|
bool
|
Whether to sort the data in descending order. Defaults to True. |
True
|
sort_column
|
str
|
The column to sort the data. Defaults to None. |
None
|
max_rows
|
int
|
Maximum number of rows to display. Defaults to None. |
None
|
x_label
|
str
|
Label for the x axis. Defaults to None. |
None
|
y_label
|
str
|
Label for the y axis. Defaults to None. |
None
|
title
|
str
|
Title for the plot. Defaults to None. |
None
|
legend_title
|
str
|
Title for the legend. Defaults to None. |
None
|
width
|
int
|
Width of the plot in pixels. Defaults to None. |
None
|
height
|
int
|
Height of the plot in pixels. Defaults to 500. |
500
|
layout_args
|
dict
|
Layout arguments for the plot to be passed to fig.update_layout(), such as {'title':'Plot Title', 'title_x':0.5}. Defaults to None. |
{}
|
**kwargs
|
Any additional arguments to pass to plotly.express.bar(), such as: pattern_shape: str or int or Series or array-like
Either a name of a column in |
{}
|
Returns:
| Type | Description |
|---|---|
|
plotly.graph_objs._figure.Figure: A plotly figure object. |
Source code in leafmap/plot.py
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 | |
basemap_xyz_tiles()
¶
Returns a dictionary containing a set of basemaps that are XYZ tile layers.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dictionary of XYZ tile layers. |
Source code in leafmap/common.py
2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 | |
bbox_to_gdf(bbox, crs='epsg:4326')
¶
Convert a bounding box to a GeoPandas GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
list
|
A bounding box in the format of [minx, miny, maxx, maxy]. |
required |
crs
|
str
|
The CRS of the bounding box. Defaults to 'epsg:4326'. |
'epsg:4326'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
A GeoDataFrame with a single polygon. |
Source code in leafmap/common.py
7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 | |
bbox_to_geojson(bounds)
¶
Convert coordinates of a bounding box to a geojson.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
list | tuple
|
A list of coordinates representing [left, bottom, right, top] or m.bounds. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A geojson feature. |
Source code in leafmap/common.py
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 | |
bbox_to_polygon(bbox)
¶
Convert a bounding box to a shapely Polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
list
|
A bounding box in the format of [minx, miny, maxx, maxy]. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A shapely Polygon. |
Source code in leafmap/common.py
7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 | |
blend_images(img1, img2, alpha=0.5, output=False, show=True, figsize=(12, 10), axis='off', **kwargs)
¶
Blends two images together using the addWeighted function from the OpenCV library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img1
|
ndarray
|
The first input image on top represented as a NumPy array. |
required |
img2
|
ndarray
|
The second input image at the bottom represented as a NumPy array. |
required |
alpha
|
float
|
The weighting factor for the first image in the blend. By default, this is set to 0.5. |
0.5
|
output
|
str
|
The path to the output image. Defaults to False. |
False
|
show
|
bool
|
Whether to display the blended image. Defaults to True. |
True
|
figsize
|
tuple
|
The size of the figure. Defaults to (12, 10). |
(12, 10)
|
axis
|
str
|
The axis of the figure. Defaults to "off". |
'off'
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the cv2.addWeighted() function. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The blended image as a NumPy array. |
Source code in leafmap/common.py
14159 14160 14161 14162 14163 14164 14165 14166 14167 14168 14169 14170 14171 14172 14173 14174 14175 14176 14177 14178 14179 14180 14181 14182 14183 14184 14185 14186 14187 14188 14189 14190 14191 14192 14193 14194 14195 14196 14197 14198 14199 14200 14201 14202 14203 14204 14205 14206 14207 14208 14209 14210 14211 14212 14213 14214 14215 14216 14217 14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 | |
bounds_to_xy_range(bounds)
¶
Convert bounds to x and y range to be used as input to bokeh map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Union[List[Union[Tuple[float, float], float]], Tuple[float, float, float, float]]
|
A list of bounds in the form [(south, west), (north, east)] or [xmin, ymin, xmax, ymax]. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[Tuple[float, float], Tuple[float, float]]
|
Tuple[Tuple[float, float], Tuple[float, float]]: A tuple of (x_range, y_range). |
Source code in leafmap/common.py
7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 | |
center_zoom_to_xy_range(center, zoom)
¶
Convert center and zoom to x and y range to be used as input to bokeh map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
tuple
|
A tuple of (latitude, longitude). |
required |
zoom
|
int
|
The zoom level. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[Tuple[float, float], Tuple[float, float]]
|
A tuple of (x_range, y_range). |
Source code in leafmap/common.py
7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 | |
cesium_to_streamlit(html, width=800, height=600, responsive=True, scrolling=False, token_name=None, token_value=None, **kwargs)
¶
Renders an cesium HTML file in a Streamlit app. This method is a static Streamlit Component, meaning, no information is passed back from Leaflet on browser interaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML file to render. It can a local file path or a URL. |
required |
width
|
int
|
Width of the map. Defaults to 800. |
800
|
height
|
int
|
Height of the map. Defaults to 600. |
600
|
responsive
|
bool
|
Whether to make the map responsive. Defaults to True. |
True
|
scrolling
|
bool
|
Whether to allow the map to scroll. Defaults to False. |
False
|
token_name
|
str
|
The name of the token in the HTML file to be replaced. Defaults to None. |
None
|
token_value
|
str
|
The value of the token to pass to the HTML file. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A Streamlit components.html object. |
Source code in leafmap/common.py
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 | |
check_cmap(cmap)
¶
Check the colormap and return a list of colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmap
|
str | list | Box
|
The colormap to check. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of colors. |
Source code in leafmap/common.py
5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 | |
check_color(in_color)
¶
Checks the input color and returns the corresponding hex color code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_color
|
str or tuple or list
|
It can be a string (e.g., 'red', '#ffff00', 'ffff00', 'ff0') or RGB tuple/list (e.g., (255, 127, 0)). |
required |
Returns:
| Type | Description |
|---|---|
str
|
A hex color code. |
Source code in leafmap/common.py
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 | |
check_dir(dir_path, make_dirs=True)
¶
Checks if a directory exists and creates it if it does not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_path
|
[str
|
The path to the directory. |
required |
make_dirs
|
bool
|
Whether to create the directory if it does not exist. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the directory could not be found. |
TypeError
|
If the input directory path is not a string. |
Returns:
| Type | Description |
|---|---|
str
|
The path to the directory. |
Source code in leafmap/common.py
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 | |
check_file_path(file_path, make_dirs=True)
¶
Gets the absolute file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
The path to the file. |
required |
make_dirs
|
bool
|
Whether to create the directory if it does not exist. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the directory could not be found. |
TypeError
|
If the input directory path is not a string. |
Returns:
| Type | Description |
|---|---|
str
|
The absolute path to the file. |
Source code in leafmap/common.py
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 | |
check_html_string(html_string)
¶
Check if an HTML string contains local images and convert them to base64.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html_string
|
str
|
The HTML string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The HTML string with local images converted to base64. |
Source code in leafmap/common.py
11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 11249 11250 11251 11252 11253 11254 11255 11256 11257 11258 11259 11260 11261 11262 11263 | |
check_titiler_cmr_endpoint(titiler_cmr_endpoint=None)
¶
Returns the TiTiler CMR endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
titiler_cmr_endpoint
|
str
|
The TiTiler CMR endpoint URL. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
TitilerCMREndpoint |
TitilerCMREndpoint
|
The TiTiler CMR endpoint object. |
Source code in leafmap/stac.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
check_titiler_endpoint(titiler_endpoint=None)
¶
Returns the default titiler endpoint.
Returns:
| Type | Description |
|---|---|
Any
|
The titiler endpoint. |
Source code in leafmap/stac.py
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 | |
check_url(url)
¶
Check if an HTTP URL is working.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the URL is working (returns a 200 status code), False otherwise. |
Source code in leafmap/common.py
15183 15184 15185 15186 15187 15188 15189 15190 15191 15192 15193 15194 15195 15196 15197 15198 15199 | |
classify(data, column, cmap=None, colors=None, labels=None, scheme='Quantiles', k=5, legend_kwds=None, classification_kwds=None)
¶
Classify a dataframe column using a variety of classification schemes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame | GeoDataFrame
|
The data to classify. It can be a filepath to a vector dataset, a pandas dataframe, or a geopandas geodataframe. |
required |
column
|
str
|
The column to classify. |
required |
cmap
|
str
|
The name of a colormap recognized by matplotlib. Defaults to None. |
None
|
colors
|
list
|
A list of colors to use for the classification. Defaults to None. |
None
|
labels
|
list
|
A list of labels to use for the legend. Defaults to None. |
None
|
scheme
|
str
|
Name of a choropleth classification scheme (requires mapclassify). Name of a choropleth classification scheme (requires mapclassify). A mapclassify.MapClassifier object will be used under the hood. Supported are all schemes provided by mapclassify (e.g. 'BoxPlot', 'EqualInterval', 'FisherJenks', 'FisherJenksSampled', 'HeadTailBreaks', 'JenksCaspall', 'JenksCaspallForced', 'JenksCaspallSampled', 'MaxP', 'MaximumBreaks', 'NaturalBreaks', 'Quantiles', 'Percentiles', 'StdMean', 'UserDefined'). Arguments can be passed in classification_kwds. |
'Quantiles'
|
k
|
int
|
Number of classes (ignored if scheme is None or if column is categorical). Default to 5. |
5
|
legend_kwds
|
dict
|
Keyword arguments to pass to :func: |
None
|
classification_kwds
|
dict
|
Keyword arguments to pass to mapclassify. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[Any, Dict[str, Any]]
|
A pandas dataframe with the classification applied and a legend dictionary. |
Source code in leafmap/common.py
5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 | |
clip_image(image, mask, output, to_cog=True)
¶
Clip an image by mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
Path to the image file in GeoTIFF format. |
required |
mask
|
str | list | dict
|
The mask used to extract the image. It can be a path to vector datasets (e.g., GeoJSON, Shapefile), a list of coordinates, or m.user_roi. |
required |
output
|
str
|
Path to the output file. |
required |
to_cog
|
bool
|
Flags to indicate if you want to convert the output to COG. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If the fiona or rasterio package is not installed. |
FileNotFoundError
|
If the image is not found. |
ValueError
|
If the mask is not a valid GeoJSON or raster file. |
FileNotFoundError
|
If the mask file is not found. |
Source code in leafmap/common.py
5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 | |
clip_raster(image, geometry, geom_crs=None, dst_crs=None, resolution=None, driver='COG', compress='DEFLATE', bands=None, match_raster=None, output=None, verbose=True, **kwargs)
¶
Clip a raster by a geometry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str
|
Path to the image file in GeoTIFF format. |
required |
geometry
|
str | GeoDataFrame | dict | list
|
The geometry to clip the raster by. It can be a path to vector datasets (e.g., GeoJSON, Shapefile), a geopandas.GeoDataFrame, a dictionary, or a list of 4 numbers (minx, miny, maxx, maxy) representing a bounding box. |
required |
geom_crs
|
str
|
The coordinate reference system of the geometry. Defaults to None. |
None
|
dst_crs
|
str
|
The coordinate reference system of the output raster. Defaults to None. |
None
|
resolution
|
int
|
The resolution of the output raster. Defaults to None. If a single value is provided, the resolution will be the same in both x and y directions. If a tuple of two values is provided, the first value will be the resolution in the x direction and the second value will be the resolution in the y direction. |
None
|
driver
|
str
|
The driver of the output raster. Defaults to "COG". |
'COG'
|
compress
|
str
|
The compression of the output raster. Defaults to "DEFLATE". |
'DEFLATE'
|
bands
|
list
|
The indices of the bands to clip. Defaults to None. Start from 1. |
None
|
match_raster
|
str
|
Path to the raster to match the resolution and CRS of the output raster. Defaults to None. |
None
|
output
|
str
|
Path to the output raster file. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to pass to rasterio.reproject. |
{}
|
Source code in leafmap/common.py
5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 | |
clip_vector(input_gdf, clip_geom=None, bbox=None, output=None)
¶
Clip a vector dataset using either a bounding box or another vector dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_gdf
|
str | Path | GeoDataFrame
|
The input vector data, either as a file path or a GeoDataFrame. |
required |
clip_geom
|
str | Path | GeoDataFrame
|
A vector dataset used for clipping, either as a file path or GeoDataFrame. |
None
|
bbox
|
tuple
|
Bounding box defined as (minx, miny, maxx, maxy). |
None
|
output
|
str | Path
|
File path to save the clipped result. If None, the result is not saved. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The clipped GeoDataFrame. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
ValueError
|
If |
Source code in leafmap/common.py
19443 19444 19445 19446 19447 19448 19449 19450 19451 19452 19453 19454 19455 19456 19457 19458 19459 19460 19461 19462 19463 19464 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 19475 19476 19477 19478 19479 19480 19481 19482 19483 19484 19485 19486 19487 19488 19489 19490 19491 19492 19493 19494 19495 19496 19497 | |
close_duckdb_connections(database_path=None, quiet=True)
¶
Close DuckDB connections for a specific database or all databases.
This function closes all connections in the connection pool for the specified database, allowing other programs to access the database file. This is useful when you're done using the database and want to release the file lock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database_path
|
str
|
Path to the DuckDB database file. If None, closes connections for all databases. Defaults to None. |
None
|
quiet
|
bool
|
If True, suppress status messages. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
None |
Example
import leafmap
After using add_duckdb_layer¶
m = leafmap.Map() m.add_duckdb_layer("tiles.db")
Later, close the connections¶
leafmap.close_duckdb_connections()
Or close connections for a specific database¶
leafmap.close_duckdb_connections("tiles.db")
Source code in leafmap/common.py
13433 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 | |
cmr_animated_gif(concept_id, datetime, bbox, width=512, height=512, step='P1D', temporal_mode='point', backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, fps=1, output=None, titiler_cmr_endpoint=None, **kwargs)
¶
Generate animated GIF for time series from TiTiler CMR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime range (e.g., '2024-01-01/2024-01-31'). |
required |
bbox
|
list | tuple
|
Bounding box as [minx, miny, maxx, maxy]. |
required |
width
|
int
|
Width of the GIF in pixels. Defaults to 512. |
512
|
height
|
int
|
Height of the GIF in pixels. Defaults to 512. |
512
|
step
|
str
|
ISO 8601 duration for time steps (e.g., 'P1D' for 1 day, 'P1M' for 1 month). Defaults to 'P1D'. |
'P1D'
|
temporal_mode
|
str
|
Temporal mode - 'point' or 'range'. Defaults to 'point'. |
'point'
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
fps
|
int
|
Frames per second for the GIF. Defaults to 1. |
1
|
output
|
str
|
Output file path. If None, returns the URL. |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The GIF URL or output file path. |
Source code in leafmap/stac.py
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 | |
cmr_bounds(concept_id, datetime=None, backend='rasterio', variable=None, titiler_cmr_endpoint=None, **kwargs)
¶
Get bounding box from TiTiler CMR TileJSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[float]
|
Bounding box as [minx, miny, maxx, maxy]. |
Source code in leafmap/stac.py
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 | |
cmr_center(concept_id, datetime=None, backend='rasterio', variable=None, titiler_cmr_endpoint=None, **kwargs)
¶
Get center coordinates from TiTiler CMR TileJSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[float, float]
|
Center coordinates as (longitude, latitude). |
Source code in leafmap/stac.py
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 | |
cmr_statistics(concept_id, datetime=None, geojson=None, backend='rasterio', variable=None, bands=None, titiler_cmr_endpoint=None, **kwargs)
¶
Calculate statistics for an AOI from TiTiler CMR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). |
None
|
geojson
|
dict | str
|
GeoJSON geometry or file path for the AOI. |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict
|
Statistics for the AOI. |
Source code in leafmap/stac.py
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 | |
cmr_tile(concept_id, datetime=None, backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)
¶
Get tile URL from TiTiler CMR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters to pass to the TiTiler CMR endpoint. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The tile URL template. |
Source code in leafmap/stac.py
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 | |
cmr_tilejson(concept_id, datetime=None, backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)
¶
Fetch TileJSON metadata from TiTiler CMR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime or range (e.g., '2024-01-15' or '2024-01-01/2024-01-31'). |
None
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters to pass to the TiTiler CMR endpoint. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict
|
TileJSON metadata dict with tiles, bounds, center, minzoom, maxzoom. |
Source code in leafmap/stac.py
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 | |
cmr_timeseries_tilejson(concept_id, datetime, step='P1D', temporal_mode='point', backend='rasterio', variable=None, bands=None, bands_regex=None, expression=None, rescale=None, colormap_name=None, color_formula=None, titiler_cmr_endpoint=None, **kwargs)
¶
Get time series TileJSON dict from TiTiler CMR.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
concept_id
|
str
|
NASA CMR collection concept ID (e.g., 'C2036881735-POCLOUD'). |
required |
datetime
|
str
|
RFC3339 datetime range (e.g., '2024-01-01/2024-01-31'). |
required |
step
|
str
|
ISO 8601 duration for time steps (e.g., 'P1D' for 1 day, 'P1M' for 1 month, 'P2W' for 2 weeks). Defaults to 'P1D'. |
'P1D'
|
temporal_mode
|
str
|
Temporal mode - 'point' or 'range'. Defaults to 'point'. |
'point'
|
backend
|
str
|
Backend to use - 'rasterio' for COGs or 'xarray' for NetCDF/Zarr. Defaults to 'rasterio'. |
'rasterio'
|
variable
|
str
|
Variable name for xarray backend datasets. |
None
|
bands
|
str | list
|
Band name(s) for rasterio backend. |
None
|
bands_regex
|
str
|
Regex pattern for selecting bands (e.g., 'B[0-9][]'). |
None
|
expression
|
str
|
Band math expression (e.g., '(B05-B04)/(B05+B04)'). |
None
|
rescale
|
str | list
|
Min/max values for rescaling (e.g., '270,305' or [[270, 305]]). |
None
|
colormap_name
|
str
|
Name of colormap (e.g., 'thermal', 'viridis'). |
None
|
color_formula
|
str
|
Color formula (e.g., 'Gamma RGB 3.5 Saturation 1.7'). |
None
|
titiler_cmr_endpoint
|
str
|
TiTiler CMR endpoint URL. |
None
|
**kwargs
|
Additional parameters. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, Dict]
|
Dictionary mapping datetime strings to TileJSON metadata. |
Source code in leafmap/stac.py
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 | |
cog_bands(url, titiler_endpoint=None)
¶
Get band names of a Cloud Optimized GeoTIFF (COG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
Returns:
| Type | Description |
|---|---|
List
|
A list of band names. |
Source code in leafmap/stac.py
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 | |
cog_bounds(url, titiler_endpoint=None)
¶
Get the bounding box of a Cloud Optimized GeoTIFF (COG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List
|
A list of values representing [left, bottom, right, top] |
Source code in leafmap/stac.py
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 | |
cog_center(url, titiler_endpoint=None)
¶
Get the centroid of a Cloud Optimized GeoTIFF (COG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
Returns:
| Type | Description |
|---|---|
Tuple
|
A tuple representing (longitude, latitude). |
Source code in leafmap/stac.py
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 | |
cog_info(url, titiler_endpoint=None, return_geojson=False)
¶
Get band statistics of a Cloud Optimized GeoTIFF (COG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List
|
A dictionary of band info. |
Source code in leafmap/stac.py
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 | |
cog_mosaic(links, titiler_endpoint=None, username='anonymous', layername=None, overwrite=False, verbose=True, **kwargs)
¶
Creates a COG mosaic from a list of COG URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
list
|
A list containing COG HTTP URLs. |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
username
|
str
|
User name for the titiler endpoint. Defaults to "anonymous". |
'anonymous'
|
layername
|
[type]
|
Layer name to use. Defaults to None. |
None
|
overwrite
|
bool
|
Whether to overwrite the layer name if existing. Defaults to False. |
False
|
verbose
|
bool
|
Whether to print out descriptive information. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the COG mosaic fails to create. |
Returns:
| Type | Description |
|---|---|
str
|
The tile URL for the COG mosaic. |
Source code in leafmap/stac.py
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 | |
cog_mosaic_from_file(filepath, skip_rows=0, titiler_endpoint=None, username='anonymous', layername=None, overwrite=False, verbose=True, **kwargs)
¶
Creates a COG mosaic from a csv/txt file stored locally for through HTTP URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Local path or HTTP URL to the csv/txt file containing COG URLs. |
required |
skip_rows
|
int
|
The number of rows to skip in the file. Defaults to 0. |
0
|
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
username
|
str
|
User name for the titiler endpoint. Defaults to "anonymous". |
'anonymous'
|
layername
|
[type]
|
Layer name to use. Defaults to None. |
None
|
overwrite
|
bool
|
Whether to overwrite the layer name if existing. Defaults to False. |
False
|
verbose
|
bool
|
Whether to print out descriptive information. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The tile URL for the COG mosaic. |
Source code in leafmap/stac.py
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 | |
cog_pixel_value(lon, lat, url, bidx, titiler_endpoint=None, verbose=True, **kwargs)
¶
Get pixel value from COG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon
|
float
|
Longitude of the pixel. |
required |
lat
|
float
|
Latitude of the pixel. |
required |
url
|
str
|
HTTP URL to a COG, e.g., 'https://github.com/opengeos/data/releases/download/raster/Libya-2023-07-01.tif' |
required |
bidx
|
str
|
Dataset band indexes (e.g bidx=1, bidx=1&bidx=2&bidx=3). Defaults to None. |
required |
titiler_endpoint
|
str
|
TiTiler endpoint, e.g., "https://titiler.opengeos.org", "planetary-computer", "pc". Defaults to None. |
None
|
verbose
|
bool
|
Print status messages. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List
|
A dictionary of band info. |
Source code in leafmap/stac.py
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 | |
cog_stats(url, titiler_endpoint=None)
¶
Get band statistics of a Cloud Optimized GeoTIFF (COG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
list |
List
|
A dictionary of band statistics. |
Source code in leafmap/stac.py
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 | |
cog_tile(url, bands=None, titiler_endpoint=None, **kwargs)
¶
Get a tile layer from a Cloud Optimized GeoTIFF (COG). Source code adapted from https://developmentseed.org/titiler/examples/notebooks/Working_with_CloudOptimizedGeoTIFF_simple/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif. Default to None |
required |
bands
|
list
|
List of bands to use. Defaults to None. |
None
|
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
**kwargs
|
Any
|
Additional arguments to pass to the titiler endpoint. For more information about the available arguments, see https://developmentseed.org/titiler/endpoints/cog/#tiles.
For example, to apply a rescaling to multiple bands, use something like |
{}
|
Returns:
| Type | Description |
|---|---|
Tuple
|
The COG tile layer URL and bounds. |
Source code in leafmap/stac.py
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 | |
cog_tile_vmin_vmax(url, bands=None, titiler_endpoint=None, percentile=True, **kwargs)
¶
Get a tile layer from a Cloud Optimized GeoTIFF (COG) and return the minimum and maximum values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
HTTP URL to a COG, e.g., https://opendata.digitalglobe.com/events/mauritius-oil-spill/post-event/2020-08-12/105001001F1B5B00/105001001F1B5B00.tif |
required |
bands
|
list
|
List of bands to use. Defaults to None. |
None
|
titiler_endpoint
|
str
|
TiTiler endpoint. Defaults to "https://titiler.opengeos.org". |
None
|
percentile
|
bool
|
Whether to use percentiles or not. Defaults to True. |
True
|
Source code in leafmap/stac.py
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 | |
cog_validate(source, verbose=False)
¶
Validate Cloud Optimized Geotiff.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
A dataset path or URL. Will be opened in "r" mode. |
required |
verbose
|
bool
|
Whether to print the output of the validation. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If the rio-cogeo package is not installed. |
FileNotFoundError
|
If the provided file could not be found. |
Returns:
| Type | Description |
|---|---|
Tuple[bool, List[str], List[str]]
|
A tuple containing the validation results (True if src_path is a valid COG, list of validation errors, and a list of validation warnings). |
Source code in leafmap/common.py
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 | |
color_code_dataframe(data, legend_dict)
¶
Converts values in a dataframe to color codes based on a legend dictionary.
This function takes a dataframe (or path to a dataframe) and a legend dictionary and returns a new dataframe with values replaced by their corresponding color codes. It supports both numeric range legends and categorical legends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, DataFrame, GeoDataFrame]
|
Input data source, can be: - Path to a CSV file or geospatial file - pandas DataFrame - geopandas GeoDataFrame |
required |
legend_dict
|
Dict[str, str]
|
Dictionary mapping values to colors, can be: - Numeric ranges ("[ 100000, 200000]") mapped to color codes - Categorical values ("low", "medium") mapped to color codes - Can include a "Nodata" key for None/NaN values |
required |
Returns:
| Type | Description |
|---|---|
Union[DataFrame, GeoDataFrame]
|
A new dataframe with values replaced by color codes, preserving the |
Union[DataFrame, GeoDataFrame]
|
input data type (DataFrame or GeoDataFrame) |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input data type is not supported |
ValueError
|
If the file format is not supported |
Examples:
1 2 3 4 5 6 7 | |
1 2 3 4 5 6 7 8 9 | |
Source code in leafmap/common.py
18590 18591 18592 18593 18594 18595 18596 18597 18598 18599 18600 18601 18602 18603 18604 18605 18606 18607 18608 18609 18610 18611 18612 18613 18614 18615 18616 18617 18618 18619 18620 18621 18622 18623 18624 18625 18626 18627 18628 18629 18630 18631 18632 18633 18634 18635 18636 18637 18638 18639 18640 18641 18642 18643 18644 18645 18646 18647 18648 18649 18650 18651 18652 18653 18654 18655 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 18672 18673 18674 18675 18676 18677 18678 18679 18680 18681 18682 18683 18684 18685 18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 18700 18701 18702 18703 18704 18705 18706 18707 18708 18709 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 18733 18734 18735 18736 18737 18738 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 18759 18760 18761 18762 18763 18764 18765 18766 18767 18768 18769 18770 18771 18772 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 | |
configure_jupyterhub(base_url=None)
¶
Auto-configure leafmap for JupyterHub environments.
This function automatically detects if running in a JupyterHub environment and configures the necessary environment variables for tile server proxying. It will be called automatically by add_duckdb_layer, so you typically don't need to call it manually.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
The base URL of your JupyterHub instance (e.g., "https://jupyter.example.com"). Required for MapLibre vector tiles due to URL validation requirements. If not provided, vector tiles may not work. |
None
|
Example
import leafmap
Specify your JupyterHub URL for vector tile support¶
leafmap.configure_jupyterhub("https://your-jupyterhub-domain.com")
Now add_duckdb_layer will work correctly¶
Note
MapLibre GL JS's vector tile sources require absolute URLs (with http:// or https://). Raster tiles (add_raster) work with relative URLs, but vector tiles (add_duckdb_layer) do not. This is a limitation of MapLibre GL JS, not leafmap.
Source code in leafmap/common.py
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 | |
connect_points_as_line(gdf, sort_column=None, crs='EPSG:4326', single_line=True)
¶
Connects points in a GeoDataFrame into either a single LineString or multiple LineStrings based on a specified sort column or the index if no column is provided. The resulting GeoDataFrame will have the specified CRS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame containing point geometries. |
required |
sort_column
|
Optional[str]
|
Column name to sort the points by (e.g., 'timestamp'). If None, the index is used for sorting. Defaults to None. |
None
|
crs
|
str
|
The coordinate reference system (CRS) for the resulting GeoDataFrame. Defaults to "EPSG:4326". |
'EPSG:4326'
|
single_line
|
bool
|
If True, generates a single LineString connecting all points. If False, generates multiple LineStrings, each connecting two consecutive points. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
A new GeoDataFrame containing either a single LineString or multiple LineString geometries. based on the single_line parameter, with the specified CRS. |
Example
line_gdf = connect_points_as_line(gdf, 'timestamp', crs="EPSG:3857", single_line=True) line_gdf = connect_points_as_line(gdf, single_line=False) # Uses index and defaults to EPSG:4326
Source code in leafmap/common.py
17990 17991 17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 18002 18003 18004 18005 18006 18007 18008 18009 18010 18011 18012 18013 18014 18015 18016 18017 18018 18019 18020 18021 18022 18023 18024 18025 18026 18027 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 | |
connect_postgis(database, host='localhost', user=None, password=None, port=5432, use_env_var=False)
¶
Connects to a PostGIS database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
str
|
Name of the database |
required |
host
|
str
|
Hosting server for the database. Defaults to "localhost". |
'localhost'
|
user
|
str
|
User name to access the database. Defaults to None. |
None
|
password
|
str
|
Password to access the database. Defaults to None. |
None
|
port
|
int
|
Port number to connect to at the server host. Defaults to 5432. |
5432
|
use_env_var
|
bool
|
Whether to use environment variables. It set to True, user and password are treated as an environment variables with default values user="SQL_USER" and password="SQL_PASSWORD". Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If user is not specified. |
ValueError
|
If password is not specified. |
Returns:
| Type | Description |
|---|---|
Any
|
A SQLAlchemy engine connection string or engine object. |
Source code in leafmap/common.py
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 | |
construct_bbox(*args, buffer=0.001, crs='EPSG:4326', return_gdf=False)
¶
Construct a bounding box (bbox) geometry based on either a centroid point or bbox.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Union[float, Tuple[float, float, float, float]]
|
Coordinates for the geometry. - If 2 arguments are provided, it is interpreted as a centroid (x, y) with a buffer. - If 4 arguments are provided, it is interpreted as a bbox (minx, miny, maxx, maxy). |
()
|
buffer
|
float
|
The buffer distance around the centroid point (default is 0.01 degrees). |
0.001
|
crs
|
str
|
The coordinate reference system (default is "EPSG:4326"). |
'EPSG:4326'
|
return_gdf
|
bool
|
Whether to return a GeoDataFrame (default is False). |
False
|
Returns:
| Type | Description |
|---|---|
Union[Polygon, GeoDataFrame]
|
The constructed bounding box (Polygon). |
Source code in leafmap/common.py
17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 17284 17285 17286 17287 17288 17289 17290 17291 17292 17293 17294 17295 17296 17297 17298 17299 17300 17301 17302 17303 17304 17305 17306 17307 17308 17309 17310 | |
convert_coordinates(x, y, source_crs, target_crs='epsg:4326')
¶
Convert coordinates from the source EPSG code to the target EPSG code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The x-coordinate of the point. |
required |
y
|
float
|
The y-coordinate of the point. |
required |
source_crs
|
str
|
The EPSG code of the source coordinate system. |
required |
target_crs
|
str
|
The EPSG code of the target coordinate system. Defaults to '4326' (EPSG code for WGS84). |
'epsg:4326'
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
A tuple containing the converted longitude and latitude. |
Source code in leafmap/common.py
16308 16309 16310 16311 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 | |
convert_lidar(source, destination=None, point_format_id=None, file_version=None, **kwargs)
¶
Converts a Las from one point format to another Automatically upgrades the file version if source file version is not compatible with the new point_format_id
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | LasBase
|
The source data to be converted. |
required |
destination
|
str
|
The destination file path. Defaults to None. |
None
|
point_format_id
|
int
|
The new point format id (the default is None, which won't change the source format id). |
None
|
file_version
|
str
|
The new file version. None by default which means that the file_version may be upgraded for compatibility with the new point_format. The file version will not be downgraded. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The converted LasData object. |
Source code in leafmap/common.py
5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 | |
convert_to_cog(images, output_dir, prefix='', suffix='_cog', extra_options=None)
¶
Convert all .tif files in a directory to Cloud Optimized GeoTIFFs (COGs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
str | list
|
Input directory containing .tif files, or a list of .tif file paths. |
required |
output_dir
|
str
|
Path to the output directory where COGs will be saved. |
required |
prefix
|
str
|
Prefix to add to the output filenames. |
''
|
suffix
|
str
|
Suffix to add to the output filenames before the .tif extension. |
'_cog'
|
extra_options
|
List[str]
|
Additional gdal_translate options. Example: ["-co", "TILED=YES", "-co", "BLOCKSIZE=512"] |
None
|
Source code in leafmap/common.py
19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 19545 19546 19547 19548 19549 19550 19551 19552 19553 19554 19555 19556 19557 19558 19559 19560 19561 19562 19563 19564 19565 19566 19567 19568 19569 19570 19571 19572 19573 19574 19575 | |
convert_to_gdf(data, geometry=None, lat=None, lon=None, crs='EPSG:4326', included=None, excluded=None, obj_to_str=False, open_args=None, **kwargs)
¶
Convert data to a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[DataFrame, str]
|
The input data, either as a DataFrame or a file path. |
required |
geometry
|
Optional[str]
|
The column name containing geometry data. Defaults to None. |
None
|
lat
|
Optional[str]
|
The column name containing latitude data. Defaults to None. |
None
|
lon
|
Optional[str]
|
The column name containing longitude data. Defaults to None. |
None
|
crs
|
str
|
The coordinate reference system to use. Defaults to "EPSG:4326". |
'EPSG:4326'
|
included
|
Optional[List[str]]
|
List of columns to include. Defaults to None. |
None
|
excluded
|
Optional[List[str]]
|
List of columns to exclude. Defaults to None. |
None
|
obj_to_str
|
bool
|
Whether to convert object dtype columns to string. Defaults to False. |
False
|
open_args
|
Optional[Dict[str, Any]]
|
Additional arguments for file opening functions. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional keyword arguments for GeoDataFrame creation. |
{}
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The converted GeoDataFrame. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file format is unsupported or required columns are not provided. |
Source code in leafmap/common.py
17020 17021 17022 17023 17024 17025 17026 17027 17028 17029 17030 17031 17032 17033 17034 17035 17036 17037 17038 17039 17040 17041 17042 17043 17044 17045 17046 17047 17048 17049 17050 17051 17052 17053 17054 17055 17056 17057 17058 17059 17060 17061 17062 17063 17064 17065 17066 17067 17068 17069 17070 17071 17072 17073 17074 17075 17076 17077 17078 17079 17080 17081 17082 17083 17084 17085 17086 17087 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 | |
coords_to_geojson(coords)
¶
Convert a list of bbox coordinates representing [left, bottom, right, top] to geojson FeatureCollection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
list
|
A list of bbox coordinates representing [left, bottom, right, top]. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A geojson FeatureCollection. |
Source code in leafmap/common.py
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
coords_to_vector(coords, output=None, crs='EPSG:4326', **kwargs)
¶
Convert a list of coordinates to a GeoDataFrame or a vector file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
list
|
A list of coordinates in the format of [(x1, y1), (x2, y2), ...]. |
required |
output
|
str
|
The path to the output vector file. Defaults to None. |
None
|
crs
|
str
|
The CRS of the coordinates. Defaults to "EPSG:4326". |
'EPSG:4326'
|
Returns:
| Type | Description |
|---|---|
Any
|
A GeoDataFrame of the coordinates. |
Source code in leafmap/common.py
11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 11218 11219 11220 11221 11222 11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 | |
coords_to_xy(src_fp, coords, coord_crs='epsg:4326', request_payer='bucket-owner', env_args={}, open_args={}, **kwargs)
¶
Converts a list of coordinates to pixel coordinates, i.e., (col, row) coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_fp
|
str
|
The source raster file path. |
required |
coords
|
list
|
A list of coordinates in the format of [[x1, y1], [x2, y2], ...] |
required |
coord_crs
|
str
|
The coordinate CRS of the input coordinates. Defaults to "epsg:4326". |
'epsg:4326'
|
request_payer
|
str
|
Specifies who pays for the download from S3. Can be "bucket-owner" or "requester". Defaults to "bucket-owner". |
'bucket-owner'
|
env_args
|
dict
|
Additional keyword arguments to pass to rasterio.Env. |
{}
|
open_args
|
dict
|
Additional keyword arguments to pass to rasterio.open. |
{}
|
**kwargs
|
Any
|
Additional keyword arguments to pass to rasterio.transform.rowcol. |
{}
|
Returns:
| Type | Description |
|---|---|
list
|
A list of pixel coordinates in the format of [[x1, y1], [x2, y2], ...] |
Source code in leafmap/common.py
10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 | |
create_code_cell(code='', where='below')
¶
Creates a code cell in the IPython Notebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Code to fill the new code cell with. Defaults to ''. |
''
|
where
|
str
|
Where to add the new code cell. It can be one of the following: above, below, at_bottom. Defaults to 'below'. |
'below'
|
Source code in leafmap/common.py
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 | |
create_download_link(filename, title='Click here to download: ', basename=None)
¶
Downloads a file from voila. Adopted from https://github.com/voila-dashboards/voila/issues/578
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The file path to the file to download |
required |
title
|
str
|
str. Defaults to "Click here to download: ". |
'Click here to download: '
|
Returns:
| Type | Description |
|---|---|
Any
|
HTML download URL. |
Source code in leafmap/common.py
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 | |
create_legend(title='Legend', labels=None, colors=None, legend_dict=None, builtin_legend=None, opacity=1.0, position='bottomright', draggable=True, output=None, style={}, shape_type='rectangle')
¶
Create a legend in HTML format. Reference: https://bit.ly/3oV6vnH
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Title of the legend. Defaults to 'Legend'. Defaults to "Legend". |
'Legend'
|
colors
|
list
|
A list of legend colors. Defaults to None. |
None
|
labels
|
list
|
A list of legend labels. Defaults to None. |
None
|
legend_dict
|
dict
|
A dictionary containing legend items as keys and color as values. If provided, legend_keys and legend_colors will be ignored. Defaults to None. |
None
|
builtin_legend
|
str
|
Name of the builtin legend to add to the map. Defaults to None. |
None
|
opacity
|
float
|
The opacity of the legend. Defaults to 1.0. |
1.0
|
position
|
str
|
The position of the legend, can be one of the following: "topleft", "topright", "bottomleft", "bottomright". Defaults to "bottomright". |
'bottomright'
|
draggable
|
bool
|
If True, the legend can be dragged to a new position. Defaults to True. |
True
|
output
|
str
|
The output file path (*.html) to save the legend. Defaults to None. |
None
|
style
|
dict
|
Additional keyword arguments to style the legend, such as position, bottom, right, z-index, border, background-color, border-radius, padding, font-size, etc. The default style is: style = { 'position': 'fixed', 'z-index': '9999', 'border': '2px solid grey', 'background-color': 'rgba(255, 255, 255, 0.8)', 'border-radius': '5px', 'padding': '10px', 'font-size': '14px', 'bottom': '20px', 'right': '5px' } |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The HTML code of the legend. |
Source code in leafmap/common.py
7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 | |
create_lines_from_points(src_points, dst_points, col='id', distance_col='distance', decimal_places=2, return_gdf=False)
¶
Create LineString features between matching point features from two GeoJSON FeatureCollections based on a shared column (default is 'id').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_points
|
Union[dict, str, GeoDataFrame]
|
Source GeoJSON FeatureCollection with point features. |
required |
dst_points
|
Union[dict, str, GeoDataFrame]
|
Destination GeoJSON FeatureCollection with point features. |
required |
col
|
str
|
The property name to match features between the two collections. |
'id'
|
distance_col
|
str
|
The name of the column to store the distance between the points. |
'distance'
|
decimal_places
|
int
|
The number of decimal places to round the distance to. |
2
|
return_gdf
|
bool
|
If True, returns a GeoDataFrame instead of a dictionary. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
A GeoJSON FeatureCollection containing LineString features. |
Source code in leafmap/common.py
19103 19104 19105 19106 19107 19108 19109 19110 19111 19112 19113 19114 19115 19116 19117 19118 19119 19120 19121 19122 19123 19124 19125 19126 19127 19128 19129 19130 19131 19132 19133 19134 19135 19136 19137 19138 19139 19140 19141 19142 19143 19144 19145 19146 19147 19148 19149 19150 19151 19152 19153 19154 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 | |
create_mosaicjson(images, output)
¶
Create a mosaicJSON file from a list of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
str | list
|
A list of image URLs or a URL to a text file containing a list of image URLs. |
required |
output
|
str
|
The output mosaicJSON file path. |
required |
Source code in leafmap/stac.py
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 | |
create_timelapse(images, out_gif, ext='.tif', bands=None, size=None, bbox=None, fps=5, loop=0, add_progress_bar=True, progress_bar_color='blue', progress_bar_height=5, add_text=False, text_xy=None, text_sequence=None, font_type='arial.ttf', font_size=20, font_color='black', mp4=False, quiet=True, reduce_size=False, clean_up=True, **kwargs)
¶
Creates a timelapse gif from a list of images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
list | str
|
The list of images or input directory to create the gif from. For example, '/path/to/images/*.tif' or ['/path/to/image1.tif', '/path/to/image2.tif', ...] |
required |
out_gif
|
str
|
File path to the output gif. |
required |
ext
|
str
|
The extension of the images. Defaults to '.tif'. |
'.tif'
|
bands
|
list
|
The bands to use for the gif. For example, [0, 1, 2] for RGB, and [0] for grayscale. Defaults to None. |
None
|
size
|
tuple
|
The size of the gif. For example, (500, 500). Defaults to None, using the original size. |
None
|
bbox
|
list
|
The bounding box of the gif. For example, [xmin, ymin, xmax, ymax]. Defaults to None, using the original bounding box. |
None
|
fps
|
int
|
The frames per second of the gif. Defaults to 5. |
5
|
loop
|
int
|
The number of times to loop the gif. Defaults to 0, looping forever. |
0
|
add_progress_bar
|
bool
|
Whether to add a progress bar to the gif. Defaults to True. |
True
|
progress_bar_color
|
str
|
The color of the progress bar, can be color name or hex code. Defaults to 'blue'. |
'blue'
|
progress_bar_height
|
int
|
The height of the progress bar. Defaults to 5. |
5
|
add_text
|
bool
|
Whether to add text to the gif. Defaults to False. |
False
|
text_xy
|
tuple
|
The x, y coordinates of the text. For example, ('10%', '10%'). Defaults to None, using the bottom left corner. |
None
|
text_sequence
|
list
|
The sequence of text to add to the gif. For example, ['year 1', 'year 2', ...]. |
None
|
font_type
|
str
|
The font type of the text, can be 'arial.ttf' or 'alibaba.otf', or any system font. Defaults to 'arial.ttf'. |
'arial.ttf'
|
font_size
|
int
|
The font size of the text. Defaults to 20. |
20
|
font_color
|
str
|
The color of the text, can be color name or hex code. Defaults to 'black'. |
'black'
|
mp4
|
bool
|
Whether to convert the gif to mp4. Defaults to False. |
False
|
quiet
|
bool
|
Whether to print the progress. Defaults to False. |
True
|
reduce_size
|
bool
|
Whether to reduce the size of the gif using ffmpeg. Defaults to False. |
False
|
clean_up
|
bool
|
Whether to clean up the temporary files. Defaults to True. |
True
|
Source code in leafmap/common.py
8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 | |
csv_points_to_shp(in_csv, out_shp, latitude='latitude', longitude='longitude')
¶
Converts a csv file containing points (latitude, longitude) into a shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
File path or HTTP URL to the input csv file. For example, https://raw.githubusercontent.com/opengeos/data/main/world/world_cities.csv |
required |
out_shp
|
str
|
File path to the output shapefile. |
required |
latitude
|
str
|
Column name for the latitude column. Defaults to 'latitude'. |
'latitude'
|
longitude
|
str
|
Column name for the longitude column. Defaults to 'longitude'. |
'longitude'
|
Source code in leafmap/common.py
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 | |
csv_to_df(in_csv, **kwargs)
¶
Converts a CSV file to pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
File path to the input CSV. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A pandas DataFrame. |
Source code in leafmap/common.py
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 | |
csv_to_gdf(in_csv, latitude='latitude', longitude='longitude', geometry=None, crs='EPSG:4326', encoding='utf-8', **kwargs)
¶
Creates points for a CSV file and converts them to a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
The file path to the input CSV file. |
required |
latitude
|
str
|
The name of the column containing latitude coordinates. Defaults to "latitude". |
'latitude'
|
longitude
|
str
|
The name of the column containing longitude coordinates. Defaults to "longitude". |
'longitude'
|
geometry
|
str
|
The name of the column containing geometry. Defaults to None. |
None
|
crs
|
str
|
The coordinate reference system. Defaults to "EPSG:4326". |
'EPSG:4326'
|
encoding
|
str
|
The encoding of characters. Defaults to "utf-8". |
'utf-8'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
A GeoDataFrame. |
Source code in leafmap/common.py
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 | |
csv_to_geojson(in_csv, out_geojson=None, latitude='latitude', longitude='longitude', encoding='utf-8')
¶
Creates points for a CSV file and exports data as a GeoJSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
The file path to the input CSV file. |
required |
out_geojson
|
str
|
The file path to the exported GeoJSON. Default to None. |
None
|
latitude
|
str
|
The name of the column containing latitude coordinates. Defaults to "latitude". |
'latitude'
|
longitude
|
str
|
The name of the column containing longitude coordinates. Defaults to "longitude". |
'longitude'
|
encoding
|
str
|
The encoding of characters. Defaults to "utf-8". |
'utf-8'
|
Source code in leafmap/common.py
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 | |
csv_to_shp(in_csv, out_shp, latitude='latitude', longitude='longitude', encoding='utf-8')
¶
Converts a csv file with latlon info to a point shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
The input csv file containing longitude and latitude columns. |
required |
out_shp
|
str
|
The file path to the output shapefile. |
required |
latitude
|
str
|
The column name of the latitude column. Defaults to 'latitude'. |
'latitude'
|
longitude
|
str
|
The column name of the longitude column. Defaults to 'longitude'. |
'longitude'
|
Source code in leafmap/common.py
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 | |
csv_to_vector(in_csv, output, latitude='latitude', longitude='longitude', geometry=None, crs='EPSG:4326', encoding='utf-8', **kwargs)
¶
Creates points for a CSV file and converts them to a vector dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_csv
|
str
|
The file path to the input CSV file. |
required |
output
|
str
|
The file path to the output vector dataset. |
required |
latitude
|
str
|
The name of the column containing latitude coordinates. Defaults to "latitude". |
'latitude'
|
longitude
|
str
|
The name of the column containing longitude coordinates. Defaults to "longitude". |
'longitude'
|
geometry
|
str
|
The name of the column containing geometry. Defaults to None. |
None
|
crs
|
str
|
The coordinate reference system. Defaults to "EPSG:4326". |
'EPSG:4326'
|
encoding
|
str
|
The encoding of characters. Defaults to "utf-8". |
'utf-8'
|
**kwargs
|
Any
|
Additional keyword arguments to pass to gdf.to_file(). |
{}
|
Source code in leafmap/common.py
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 | |
d2s_tile(url, titiler_endpoint=None, **kwargs)
¶
Generate a D2S tile URL with optional API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The base URL for the tile. |
required |
titiler_endpoint
|
str
|
The endpoint for the titiler service. Defaults to "https://tt.d2s.org". |
None
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the cog_stats function. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The modified URL with the API key if required, otherwise the original URL. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the API key is required but not set in the environment variables. |
Source code in leafmap/common.py
16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 | |
delete_shp(in_shp, verbose=False)
¶
Deletes a shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_shp
|
str
|
The input shapefile to delete. |
required |
verbose
|
bool
|
Whether to print out descriptive text. Defaults to True. |
False
|
Source code in leafmap/common.py
1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 | |
df_to_gdf(df, geometry='geometry', src_crs='EPSG:4326', dst_crs=None, **kwargs)
¶
Converts a pandas DataFrame to a GeoPandas GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The pandas DataFrame to convert. |
required |
geometry
|
str
|
The name of the geometry column in the DataFrame. |
'geometry'
|
src_crs
|
str
|
The coordinate reference system (CRS) of the GeoDataFrame. Default is "EPSG:4326". |
'EPSG:4326'
|
dst_crs
|
str
|
The target CRS of the GeoDataFrame. Default is None |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The converted GeoPandas GeoDataFrame. |
Source code in leafmap/common.py
15154 15155 15156 15157 15158 15159 15160 15161 15162 15163 15164 15165 15166 15167 15168 15169 15170 15171 15172 15173 15174 15175 15176 15177 15178 15179 15180 | |
df_to_geojson(df, out_geojson=None, latitude='latitude', longitude='longitude', encoding='utf-8')
¶
Creates points for a Pandas DataFrame and exports data as a GeoJSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The input Pandas DataFrame. |
required |
out_geojson
|
str
|
The file path to the exported GeoJSON. Default to None. |
None
|
latitude
|
str
|
The name of the column containing latitude coordinates. Defaults to "latitude". |
'latitude'
|
longitude
|
str
|
The name of the column containing longitude coordinates. Defaults to "longitude". |
'longitude'
|
encoding
|
str
|
The encoding of characters. Defaults to "utf-8". |
'utf-8'
|
Source code in leafmap/common.py
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 | |
dict_to_json(data, file_path, indent=4)
¶
Writes a dictionary to a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
A dictionary. |
required |
file_path
|
str
|
The path to the JSON file. |
required |
indent
|
int
|
The indentation of the JSON file. Defaults to 4. |
4
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input data is not a dictionary. |
Source code in leafmap/common.py
4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 | |
disjoint(input_features, selecting_features, output=None, **kwargs)
¶
Find the features in the input_features that do not intersect the selecting_features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_features
|
str | GeoDataFrame
|
The input features to select from. Can be a file path or a GeoDataFrame. |
required |
selecting_features
|
str | GeoDataFrame
|
The features in the Input Features parameter will be selected based on their relationship to the features from this layer. |
required |
output
|
are
|
The output path to save the GeoDataFrame in a vector format (e.g., shapefile). Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The path to the output file or the GeoDataFrame. |
Source code in leafmap/common.py
9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 | |
display_html(html, width='100%', height=500)
¶
Displays an HTML file or HTML string in a Jupyter Notebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
Union[str, bytes]
|
Path to an HTML file or an HTML string. |
required |
width
|
str
|
Width of the displayed iframe. Default is '100%'. |
'100%'
|
height
|
int
|
Height of the displayed iframe. Default is 500. |
500
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
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 | |
download_data_catalogs(out_dir=None, quiet=True, overwrite=False)
¶
Download geospatial data catalogs from https://github.com/giswqs/geospatial-data-catalogs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dir
|
str
|
The output directory. Defaults to None. |
None
|
quiet
|
bool
|
Whether to suppress the download progress bar. Defaults to True. |
True
|
overwrite
|
bool
|
Whether to overwrite the existing data catalog. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path to the downloaded data catalog. |
Source code in leafmap/stac.py
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 | |
download_file(url=None, output=None, quiet=False, proxy=None, speed=None, use_cookies=True, verify=True, id=None, fuzzy=False, resume=False, unzip=True, overwrite=False, subfolder=False)
¶
Download a file from URL, including Google Drive shared URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Google Drive URL is also supported. Defaults to None. |
None
|
output
|
str
|
Output filename. Default is basename of URL. |
None
|
quiet
|
bool
|
Suppress terminal output. Default is False. |
False
|
proxy
|
str
|
Proxy. Defaults to None. |
None
|
speed
|
float
|
Download byte size per second (e.g., 256KB/s = 256 * 1024). Defaults to None. |
None
|
use_cookies
|
bool
|
Flag to use cookies. Defaults to True. |
True
|
verify
|
bool | str
|
Either a bool, in which case it controls whether the server's TLS certificate is verified, or a string, in which case it must be a path to a CA bundle to use. Default is True.. Defaults to True. |
True
|
id
|
str
|
Google Drive's file ID. Defaults to None. |
None
|
fuzzy
|
bool
|
Fuzzy extraction of Google Drive's file Id. Defaults to False. |
False
|
resume
|
bool
|
Resume the download from existing tmp file if possible. Defaults to False. |
False
|
unzip
|
bool
|
Unzip the file. Defaults to True. |
True
|
overwrite
|
bool
|
Overwrite the file if it already exists. Defaults to False. |
False
|
subfolder
|
bool
|
Create a subfolder with the same name as the file. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The output file path. |
Source code in leafmap/common.py
5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 | |
download_file_lite(url, output=None, binary=False, overwrite=False, **kwargs)
async
¶
Download a file using Pyodide. This function is only available on JupyterLite. Call the function with await, such as await download_file_lite(url).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the file. |
required |
output
|
str
|
The local path to save the file. Defaults to None. |
None
|
binary
|
bool
|
Whether the file is binary. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite the file if it exists. Defaults to False. |
False
|
Source code in leafmap/common.py
7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 | |
download_files(urls, out_dir=None, filenames=None, quiet=False, proxy=None, speed=None, use_cookies=True, verify=True, id=None, fuzzy=False, resume=False, unzip=True, overwrite=False, subfolder=False, multi_part=False)
¶
Download files from URLs, including Google Drive shared URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urls
|
list
|
The list of urls to download. Google Drive URL is also supported. |
required |
out_dir
|
str
|
The output directory. Defaults to None. |
None
|
filenames
|
list
|
Output filename. Default is basename of URL. |
None
|
quiet
|
bool
|
Suppress terminal output. Default is False. |
False
|
proxy
|
str
|
Proxy. Defaults to None. |
None
|
speed
|
float
|
Download byte size per second (e.g., 256KB/s = 256 * 1024). Defaults to None. |
None
|
use_cookies
|
bool
|
Flag to use cookies. Defaults to True. |
True
|
verify
|
bool | str
|
Either a bool, in which case it controls whether the server's TLS certificate is verified, or a string, in which case it must be a path to a CA bundle to use. Default is True.. Defaults to True. |
True
|
id
|
str
|
Google Drive's file ID. Defaults to None. |
None
|
fuzzy
|
bool
|
Fuzzy extraction of Google Drive's file Id. Defaults to False. |
False
|
resume
|
bool
|
Resume the download from existing tmp file if possible. Defaults to False. |
False
|
unzip
|
bool
|
Unzip the file. Defaults to True. |
True
|
overwrite
|
bool
|
Overwrite the file if it already exists. Defaults to False. |
False
|
subfolder
|
bool
|
Create a subfolder with the same name as the file. Defaults to False. |
False
|
multi_part
|
bool
|
If the file is a multi-part file. Defaults to False. |
False
|
1 2 3 4 | |
Source code in leafmap/common.py
5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 | |
download_folder(url=None, id=None, output=None, quiet=False, proxy=None, speed=None, use_cookies=True, remaining_ok=False)
¶
Downloads the entire folder from URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL of the Google Drive folder. Must be of the format 'https://drive.google.com/drive/folders/{url}'. Defaults to None. |
None
|
id
|
str
|
Google Drive's folder ID. Defaults to None. |
None
|
output
|
str
|
String containing the path of the output folder. Defaults to current working directory. |
None
|
quiet
|
bool
|
Suppress terminal output. Defaults to False. |
False
|
proxy
|
str
|
Proxy. Defaults to None. |
None
|
speed
|
float
|
Download byte size per second (e.g., 256KB/s = 256 * 1024). Defaults to None. |
None
|
use_cookies
|
bool
|
Flag to use cookies. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
Optional[List[str]]
|
List of files downloaded, or None if failed. |
Source code in leafmap/common.py
5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 | |
download_from_url(url, out_file_name=None, out_dir='.', unzip=True, verbose=True)
¶
Download a file from a URL (e.g., https://github.com/opengeos/whitebox-python/raw/master/examples/testdata.zip)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The HTTP URL to download. |
required |
out_file_name
|
str
|
The output file name to use. Defaults to None. |
None
|
out_dir
|
str
|
The output directory to use. Defaults to '.'. |
'.'
|
unzip
|
bool
|
Whether to unzip the downloaded file if it is a zip file. Defaults to True. |
True
|
verbose
|
bool
|
Whether to display or not the output of the function |
True
|
Source code in leafmap/common.py
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 | |
download_google_buildings(location, out_dir=None, merge_output=None, head=None, keep_geojson=False, overwrite=False, quiet=False, **kwargs)
¶
Download Google Open Building dataset for a specific location. Check the dataset links from https://sites.research.google/open-buildings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
The location name for which to download the dataset. |
required |
out_dir
|
Optional[str]
|
The output directory to save the downloaded files. If not provided, the current working directory is used. |
None
|
merge_output
|
Optional[str]
|
Optional. The output file path for merging the downloaded files into a single GeoDataFrame. |
None
|
head
|
Optional[int]
|
Optional. The number of files to download. If not provided, all files will be downloaded. |
None
|
keep_geojson
|
bool
|
Optional. If True, the GeoJSON files will be kept after converting them to CSV files. |
False
|
overwrite
|
bool
|
Optional. If True, overwrite the existing files. |
False
|
quiet
|
bool
|
Optional. If True, suppresses the download progress messages. |
False
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the |
{}
|
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of file paths of the downloaded files. |
Source code in leafmap/common.py
12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 12310 12311 12312 12313 12314 12315 12316 12317 12318 12319 12320 12321 12322 12323 12324 12325 12326 12327 12328 12329 12330 12331 12332 12333 12334 12335 12336 12337 12338 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 12364 12365 12366 12367 12368 12369 12370 12371 12372 12373 12374 12375 12376 12377 12378 12379 12380 12381 12382 | |
download_mapillary_image(image_id, output=None, resolution='original', access_token=None, quiet=True, **kwargs)
¶
Downloads a Mapillary image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_id
|
str
|
The ID of the Mapillary image. |
required |
output
|
str
|
The output file path. Defaults to None. |
None
|
resolution
|
str
|
The resolution of the image. Can be 256, 1024, 2048, or original. Defaults to "original". |
'original'
|
access_token
|
str
|
The access token for the Mapillary API. Defaults to None. |
None
|
quiet
|
bool
|
Whether to suppress output. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the download. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 | |
download_mapillary_images(image_ids, output_dir=None, resolution='original', **kwargs)
¶
Downloads multiple Mapillary images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_ids
|
List[str]
|
A list of Mapillary image IDs. |
required |
output_dir
|
str
|
The directory to save the images. Defaults to the current working directory. |
None
|
resolution
|
str
|
The resolution of the images. Defaults to "original". |
'original'
|
**kwargs
|
Any
|
Additional keyword arguments for the download. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 | |
download_ms_buildings(location, out_dir=None, merge_output=None, head=None, quiet=False, **kwargs)
¶
Download Microsoft Buildings dataset for a specific location. Check the dataset links from https://minedbuildings.blob.core.windows.net/global-buildings/dataset-links.csv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
The location name for which to download the dataset. |
required |
out_dir
|
str
|
The output directory to save the downloaded files. If not provided, the current working directory is used. |
None
|
merge_output
|
str
|
The output file path for merging the downloaded files into a single GeoDataFrame. |
None
|
head
|
int
|
The number of files to download. If not provided, all files will be downloaded. |
None
|
quiet
|
bool
|
If True, suppresses the download progress messages. |
False
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the |
{}
|
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of file paths of the downloaded files. |
Source code in leafmap/common.py
12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 12249 12250 12251 12252 12253 12254 12255 12256 12257 12258 12259 12260 12261 12262 12263 12264 12265 12266 12267 12268 12269 12270 12271 12272 12273 12274 12275 12276 12277 12278 12279 12280 12281 12282 12283 12284 | |
download_ned(region, out_dir=None, return_url=False, download_args={}, geopandas_args={}, query={})
¶
Download the US National Elevation Datasets (NED) for a region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str | list
|
A filepath to a vector dataset or a list of bounds in the form of [minx, miny, maxx, maxy]. |
required |
out_dir
|
str
|
The directory to download the files to. Defaults to None, which uses the current working directory. |
None
|
return_url
|
bool
|
Whether to return the download URLs of the files. Defaults to False. |
False
|
download_args
|
dict
|
A dictionary of arguments to pass to the download_file function. Defaults to {}. |
{}
|
geopandas_args
|
dict
|
A dictionary of arguments to pass to the geopandas.read_file() function. Used for reading a region URL|filepath. |
{}
|
query
|
dict
|
A dictionary of arguments to pass to the The_national_map_USGS.find_details() function. See https://apps.nationalmap.gov/tnmaccess/#/product for more information. |
{}
|
Returns:
| Type | Description |
|---|---|
Union[None, List]
|
A list of the download URLs of the files if return_url is True. |
Source code in leafmap/common.py
6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 | |
download_nlcd(years, out_dir=None, quiet=False, **kwargs)
¶
Downloads NLCD (National Land Cover Database) files for the specified years.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
List[int]
|
A list of years for which to download the NLCD files. |
required |
out_dir
|
str
|
The directory where the downloaded files will be saved. Defaults to the current working directory. |
None
|
quiet
|
bool
|
If True, suppresses download progress messages. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the download_file function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
17957 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 | |
download_tnm(region=None, out_dir=None, return_url=False, download_args={}, geopandas_args={}, API={})
¶
Download the US National Elevation Datasets (NED) for a region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region
|
str | list
|
An URL|filepath to a vector dataset Or a list of bounds in the form of [minx, miny, maxx, maxy]. Alternatively you could use API parameters such as polygon or bbox. |
None
|
out_dir
|
str
|
The directory to download the files to. Defaults to None, which uses the current working directory. |
None
|
return_url
|
bool
|
Whether to return the download URLs of the files. Defaults to False. |
False
|
download_args
|
dict
|
A dictionary of arguments to pass to the download_file function. Defaults to {}. |
{}
|
geopandas_args
|
dict
|
A dictionary of arguments to pass to the geopandas.read_file() function. Used for reading a region URL|filepath. |
{}
|
API
|
dict
|
A dictionary of arguments to pass to the The_national_map_USGS.find_details() function. Exposes most of the documented API. Defaults to {} |
{}
|
Returns:
| Type | Description |
|---|---|
Union[None, List]
|
A list of the download URLs of the files if return_url is True. |
Source code in leafmap/common.py
6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 | |
edit_download_html(htmlWidget, filename, title='Click here to download: ')
¶
Downloads a file from voila. Adopted from https://github.com/voila-dashboards/voila/issues/578#issuecomment-617668058
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
htmlWidget
|
object
|
The HTML widget to display the URL. |
required |
filename
|
str
|
File path to download. |
required |
title
|
str
|
Download description. Defaults to "Click here to download: ". |
'Click here to download: '
|
Source code in leafmap/common.py
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 | |
ee_initialize(key_data=None, token_name='EE_SERVICE_ACCOUNT')
¶
Initialize the Earth Engine API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_data
|
Optional[str]
|
The key data to use for authentication. Must be a JSON string containing service account credentials, with at least a 'client_email' field (e.g., the contents of a Google service account key file). |
None
|
token_name
|
str
|
The name of the environment variable to use for authentication. |
'EE_SERVICE_ACCOUNT'
|
Source code in leafmap/common.py
20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 | |
ee_tile_url(ee_object=None, vis_params={}, asset_id=None, ee_initialize=False, project_id=None, **kwargs)
¶
Adds a Google Earth Engine tile layer to the map based on the tile layer URL from https://github.com/opengeos/ee-tile-layers/blob/main/datasets.tsv.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ee_object
|
object
|
The Earth Engine object to display. |
None
|
vis_params
|
dict
|
Visualization parameters. For example, {'min': 0, 'max': 100}. |
{}
|
asset_id
|
str
|
The ID of the Earth Engine asset. |
None
|
ee_initialize
|
bool
|
Whether to initialize the Earth Engine |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 | |
evaluate_model(df, y_col='y', y_pred_col='y_pred', metrics=None, drop_na=True, filter_nonzero=True)
¶
Evaluates the model performance on the given dataframe with customizable options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
A pandas DataFrame with columns for actual and predicted values. |
required |
y_col
|
str
|
Column name for the actual values. |
'y'
|
y_pred_col
|
str
|
Column name for the predicted values. |
'y_pred'
|
metrics
|
list
|
A list of metrics to calculate. Available options: - 'r2': R-squared - 'r': Pearson correlation coefficient - 'rmse': Root Mean Squared Error - 'mae': Mean Absolute Error - 'mape': Mean Absolute Percentage Error Defaults to all metrics if None. |
None
|
drop_na
|
bool
|
Whether to drop rows with NaN in the actual values column. |
True
|
filter_nonzero
|
bool
|
Whether to filter out rows where actual values are zero. |
True
|
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary of the selected performance metrics. |
Source code in leafmap/common.py
18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 18103 18104 18105 18106 18107 18108 18109 18110 18111 18112 18113 18114 18115 18116 18117 18118 18119 18120 18121 18122 18123 18124 18125 18126 18127 18128 18129 18130 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 | |
execute_maplibre_notebook_dir(in_dir, out_dir, delete_html=True, replace_api_key=True, recursive=False, keep_notebook=False, index_html=True, ignore_files=None)
¶
Executes Jupyter notebooks found in a specified directory, optionally replacing API keys and deleting HTML outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dir
|
str
|
The input directory containing Jupyter notebooks to be executed. |
required |
out_dir
|
str
|
The output directory where the executed notebooks and their HTML outputs will be saved. |
required |
delete_html
|
bool
|
If True, deletes any existing HTML files in the output directory before execution. Defaults to True. |
True
|
replace_api_key
|
bool
|
If True, replaces the API key in the output HTML. Defaults to True. set "MAPTILER_KEY" and "MAPTILER_KEY_PUBLIC" to your MapTiler API key and public key, respectively. |
True
|
recursive
|
bool
|
If True, searches for notebooks in the input directory recursively. Defaults to False. |
False
|
keep_notebook
|
bool
|
If True, keeps the executed notebooks in the output directory. Defaults to False. |
False
|
index_html
|
bool
|
If True, generates an index.html file in the output directory listing all files. Defaults to True. |
True
|
ignore_files
|
list
|
A list of notebook files to ignore during execution. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 16653 16654 16655 16656 16657 16658 16659 16660 16661 16662 16663 16664 16665 16666 16667 16668 | |
execute_notebook(in_file)
¶
Executes a Jupyter notebook and save output cells
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_file
|
str
|
Input Jupyter notebook. |
required |
Source code in leafmap/common.py
16556 16557 16558 16559 16560 16561 16562 16563 16564 | |
execute_notebook_dir(in_dir)
¶
Executes all Jupyter notebooks in the given directory recursively and save output cells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_dir
|
str
|
Input folder containing notebooks. |
required |
Source code in leafmap/common.py
16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 | |
explode(coords)
¶
Explode a GeoJSON geometry's coordinates object and yield coordinate tuples. As long as the input is conforming, the type of the geometry doesn't matter. From Fiona 1.4.8
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
list
|
A list of coordinates. |
required |
Yields:
| Type | Description |
|---|---|
Any
|
Coordinate tuples extracted from the input. |
Source code in leafmap/common.py
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | |
extract_archive(archive, outdir=None, **kwargs)
¶
Extracts a multipart archive.
This function uses the patoolib library to extract a multipart archive. If the patoolib library is not installed, it attempts to install it. If the archive does not end with ".zip", it appends ".zip" to the archive name. If the extraction fails (for example, if the files already exist), it skips the extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
archive
|
str
|
The path to the archive file. |
required |
outdir
|
str
|
The directory where the archive should be extracted. |
None
|
**kwargs
|
Any
|
Arbitrary keyword arguments for the patoolib.extract_archive function. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Raises:
| Type | Description |
|---|---|
Exception
|
An exception is raised if the extraction fails for reasons other than the files already existing. |
1 2 3 4 | |
Source code in leafmap/common.py
16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 16347 16348 16349 16350 16351 16352 16353 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 | |
extract_parquet_by_bbox(input_parquet, bbox, output_file, geometry='geometry', driver='PARQUET')
¶
Extract buildings that intersect with a specific bounding box in San Diego.
Uses DuckDB with spatial extension to query buildings that intersect with a bounding box and saves the results to a Parquet file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_parquet
|
str
|
Path to the input Parquet file. |
required |
bbox
|
tuple | list
|
Bounding box as (minx, miny, maxx, maxy). |
required |
output_file
|
str
|
Output file path for resulting Parquet/GeoParquet file. |
required |
geometry
|
str
|
Geometry column name. Defaults to "geometry". |
'geometry'
|
driver
|
str
|
Output driver, e.g., "PARQUET". Defaults to "PARQUET". |
'PARQUET'
|
Returns:
| Type | Description |
|---|---|
None
|
The function writes the results to the output file. |
Source code in leafmap/common.py
14822 14823 14824 14825 14826 14827 14828 14829 14830 14831 14832 14833 14834 14835 14836 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 | |
filter_bounds(data, bbox, within=False, align=True, **kwargs)
¶
Filters a GeoDataFrame or GeoSeries by a bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | GeoDataFrame
|
The input data to filter. Can be a file path or a GeoDataFrame. |
required |
bbox
|
list | GeoDataFrame
|
The bounding box to filter by. Can be a list of 4 coordinates or a file path or a GeoDataFrame. |
required |
within
|
bool
|
Whether to filter by the bounding box or the bounding box's interior. Defaults to False. |
False
|
align
|
bool
|
If True, automatically aligns GeoSeries based on their indices. If False, the order of elements is preserved. |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
The filtered data. |
Source code in leafmap/common.py
9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 | |
filter_date(data, start_date=None, end_date=None, date_field='date', date_args={}, **kwargs)
¶
Filters a DataFrame, GeoDataFrame or GeoSeries by a date range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame | GeoDataFrame
|
The input data to filter. Can be a file path or a DataFrame or GeoDataFrame. |
required |
start_date
|
str
|
The start date, e.g., 2023-01-01. Defaults to None. |
None
|
end_date
|
str
|
The end date, e.g., 2023-12-31. Defaults to None. |
None
|
date_field
|
str
|
The name of the date field. Defaults to "date". |
'date'
|
date_args
|
dict
|
Additional arguments for pd.to_datetime. Defaults to {}. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The filtered data. |
Source code in leafmap/common.py
9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 | |
filter_geom_type(data, geom_type, output=None, **kwargs)
¶
Filters a GeoDataFrame based on the geometry type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[str, dict, GeoDataFrame]
|
The GeoDataFrame to filter. |
required |
geom_type
|
str
|
The geometry type to filter by. |
required |
output
|
Optional[str]
|
The file path to save the filtered GeoDataFrame. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the GeoDataFrame.read_file method. |
{}
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The filtered GeoDataFrame. |
Source code in leafmap/common.py
19061 19062 19063 19064 19065 19066 19067 19068 19069 19070 19071 19072 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 19088 19089 19090 19091 19092 19093 19094 19095 19096 19097 19098 19099 19100 | |
find_closest_date(target_date, date_list, fmt='%Y-%m-%d')
¶
Finds the closest date string in a list of date strings to a given target date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_date
|
str
|
The reference date string to compare against. |
required |
date_list
|
List[str]
|
A list of date strings to search. |
required |
fmt
|
str
|
The date format used for parsing. Defaults to "%Y-%m-%d". |
'%Y-%m-%d'
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional[str]: The date string from |
Source code in leafmap/common.py
19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 | |
find_files(input_dir, ext=None, fullpath=True, recursive=True, include_hidden=False)
¶
Find files in a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dir
|
str
|
The input directory. |
required |
ext
|
str
|
The file extension to match. Defaults to None. |
None
|
fullpath
|
bool
|
Whether to return the full path. Defaults to True. |
True
|
recursive
|
bool
|
Whether to search recursively. Defaults to True. |
True
|
include_hidden
|
bool
|
Whether to include hidden files. Defaults to False. |
False
|
Source code in leafmap/common.py
6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 | |
flatten_dict(my_dict, parent_key=False, sep='.')
¶
Flattens a nested dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
my_dict
|
dict
|
The dictionary to flatten. |
required |
parent_key
|
bool
|
Whether to include the parent key. Defaults to False. |
False
|
sep
|
str
|
The separator to use. Defaults to '.'. |
'.'
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The flattened dictionary. |
Source code in leafmap/stac.py
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 | |
gdb_layer_names(gdb_path)
¶
Get a list of layer names in a File Geodatabase (GDB).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdb_path
|
str
|
The path to the File Geodatabase (GDB). |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of layer names in the GDB. |
Source code in leafmap/common.py
14410 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 14428 14429 14430 14431 14432 14433 14434 14435 14436 14437 | |
gdb_to_vector(gdb_path, out_dir, layers=None, filenames=None, gdal_driver='GPKG', file_extension=None, overwrite=False, quiet=False, **kwargs)
¶
Converts layers from a File Geodatabase (GDB) to a vector format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdb_path
|
str
|
The path to the File Geodatabase (GDB). |
required |
out_dir
|
str
|
The output directory to save the converted files. |
required |
layers
|
Optional[List[str]]
|
A list of layer names to convert. If None, all layers will be converted. Default is None. |
None
|
filenames
|
Optional[List[str]]
|
A list of output file names. If None, the layer names will be used as the file names. Default is None. |
None
|
gdal_driver
|
str
|
The GDAL driver name for the output vector format. Default is "GPKG". |
'GPKG'
|
file_extension
|
Optional[str]
|
The file extension for the output files. If None, it will be determined automatically based on the gdal_driver. Default is None. |
None
|
overwrite
|
bool
|
Whether to overwrite the existing output files. Default is False. |
False
|
quiet
|
bool
|
If True, suppress the log output. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in leafmap/common.py
14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 14346 14347 14348 14349 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 14367 14368 14369 14370 14371 14372 14373 14374 14375 14376 14377 14378 14379 14380 14381 14382 14383 14384 14385 14386 14387 14388 14389 14390 14391 14392 14393 14394 14395 14396 14397 14398 14399 14400 14401 14402 14403 14404 14405 14406 14407 | |
gdf_bounds(gdf, return_geom=False)
¶
Returns the bounding box of a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame. |
required |
return_geom
|
bool
|
Whether to return the bounding box as a GeoDataFrame. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
A bounding box in the form of a list (minx, miny, maxx, maxy) or GeoDataFrame. |
Source code in leafmap/common.py
4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 | |
gdf_centroid(gdf, return_geom=False)
¶
Returns the centroid of a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame. |
required |
return_geom
|
bool
|
Whether to return the bounding box as a GeoDataFrame. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
|
A bounding box in the form of a list (lon, lat) or GeoDataFrame. |
Source code in leafmap/common.py
4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 | |
gdf_geom_type(gdf, first_only=True)
¶
Returns the geometry type of a GeoDataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame. |
required |
first_only
|
bool
|
Whether to return the geometry type of the f irst feature in the GeoDataFrame. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
The geometry type of the GeoDataFrame, such as Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon. For more info, see https://shapely.readthedocs.io/en/stable/manual.html |
Source code in leafmap/common.py
4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 | |
gdf_to_bokeh(gdf)
¶
Function to convert a GeoPandas GeoDataFrame to a Bokeh ColumnDataSource object.
:param: (GeoDataFrame) gdf: GeoPandas GeoDataFrame with polygon(s) under the column name 'geometry.'
:return: ColumnDataSource for Bokeh.
Source code in leafmap/common.py
7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 | |
gdf_to_df(gdf, drop_geom=True)
¶
Converts a GeoDataFrame to a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoDataFrame. |
required |
drop_geom
|
bool
|
Whether to drop the geometry column. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
|
A pandas DataFrame containing the GeoDataFrame. |
Source code in leafmap/common.py
4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 | |
gdf_to_geojson(gdf, out_geojson=None, epsg=None, tuple_to_list=False, encoding='utf-8')
¶
Converts a GeoDataFame to GeoJSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
A GeoPandas GeoDataFrame. |
required |
out_geojson
|
str
|
File path to he output GeoJSON. Defaults to None. |
None
|
epsg
|
str
|
An EPSG string, e.g., "4326". Defaults to None. |
None
|
tuple_to_list
|
bool
|
Whether to convert tuples to lists. Defaults to False. |
False
|
encoding
|
str
|
The encoding to use for the GeoJSON. Defaults to "utf-8". |
'utf-8'
|
Raises:
| Type | Description |
|---|---|