H3Pandas module¶
H3Pandas
¶
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
cell_area(unit='km^2')
¶
Parameters¶
unit : str, options: 'km^2', 'm^2', or 'rads^2' Unit for area result. Default: 'km^2`
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.cell_area() val h3_cell_area 881e309739fffff 5 0.695651 881e2659c3fffff 1 0.684242
Source code in vgridpandas\h3pandas\h3pandas.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
|
geo2h3_aggregate(resolution, operation='count', lat_col='lat', lon_col='lon', return_geometry=True)
¶
Adds H3 index to DataFrame, groups points with the same index
and performs operation
.
pd.DataFrame: uses lat_col
and lng_col
(default lat
and lng
)
gpd.GeoDataFrame: uses geometry
Parameters¶
resolution : int
H3 resolution
operation : Union[dict, str, Callable]
Argument passed to DataFrame's agg
method, default 'sum'
lat_col : str
Name of the latitude column (if used), default 'lat'
lon_col : str
Name of the longitude column (if used), default 'lon'
return_geometry: bool
(Optional) Whether to add a geometry
column with the hexagonal cells.
Default = True
Returns¶
(Geo)DataFrame aggregated by H3 id into which each row's point falls
See Also¶
geo_to_h3 : H3 API method upon which this function builds
Examples¶
df = pd.DataFrame({'lat': [50, 51], 'lng':[14, 15], 'val': [10, 1]}) df.h3.geo_to_h3(1) lat lng val h3_01 811e3ffffffffff 50 14 10 811e3ffffffffff 51 15 1 df.h3.geo_to_h3_aggregate(1) val geometry h3_01 811e3ffffffffff 11 POLYGON ((12.34575 50.55428, 12.67732 46.40696... df = pd.DataFrame({'lat': [50, 51], 'lng':[14, 15], 'val': [10, 1]}) df.h3.geo_to_h3_aggregate(1, operation='mean') val geometry h3_01 811e3ffffffffff 5.5 POLYGON ((12.34575 50.55428, 12.67732 46.40696... df.h3.geo_to_h3_aggregate(1, return_geometry=False) val h3_01 811e3ffffffffff 11
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
h32geo()
¶
Add geometry
with H3 hexagons to the DataFrame. Assumes H3 index.
Returns¶
GeoDataFrame with H3 geometry
Raises¶
ValueError When an invalid H3 id is encountered
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_to_geo_boundary() val geometry 881e309739fffff 5 POLYGON ((13.99527 50.00368, 13.99310 49.99929... 881e2659c3fffff 1 POLYGON ((14.99201 51.00565, 14.98973 51.00133...
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
h32latlon()
¶
Add geometry
with centroid of each H3 id to the DataFrame.
Assumes H3 index.
Returns¶
GeoDataFrame with Point geometry
Raises¶
ValueError When an invalid H3 id is encountered
See Also¶
h3_to_geo_boundary : Adds a hexagonal cell
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_to_geo() val geometry 881e309739fffff 5 POINT (14.00037 50.00055) 881e2659c3fffff 1 POINT (14.99715 51.00252)
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
h32parent(resolution=None)
¶
Parameters¶
resolution : int or None H3 resolution. If None, then returns the direct parent of each H3 cell.
See Also¶
h3_to_parent_aggregate : Extended API method that aggregates cells by their parent cell
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_to_parent(5) val h3_05 881e309739fffff 5 851e3097fffffff 881e2659c3fffff 1 851e265bfffffff
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
h32parent_aggregate(resolution, operation='sum', return_geometry=True)
¶
Assigns parent cell to each row, groups by it and performs operation
.
Assumes H3 index.
Parameters¶
resolution : int
H3 resolution
operation : Union[dict, str, Callable]
Argument passed to DataFrame's agg
method, default 'sum'
return_geometry: bool
(Optional) Whether to add a geometry
column with the hexagonal cells.
Default = True
Returns¶
(Geo)DataFrame aggregated by the parent of each H3 id
Raises¶
ValueError When an invalid H3 id is encountered
See Also¶
h3_to_parent : H3 API method upon which this function builds
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_to_parent(1) val h3_01 881e309739fffff 5 811e3ffffffffff 881e2659c3fffff 1 811e3ffffffffff df.h3.h3_to_parent_aggregate(1) val geometry h3_01 811e3ffffffffff 6 POLYGON ((12.34575 50.55428, 12.67732 46.40696... df.h3.h3_to_parent_aggregate(1, operation='mean') val geometry h3_01 811e3ffffffffff 3 POLYGON ((12.34575 50.55428, 12.67732 46.40696... df.h3.h3_to_parent_aggregate(1, return_geometry=False) val h3_01 811e3ffffffffff 6
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
h3_get_base_cell()
¶
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_get_base_cell() val h3_base_cell 881e309739fffff 5 15 881e2659c3fffff 1 15
Source code in vgridpandas\h3pandas\h3pandas.py
184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
h3_get_resolution()
¶
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_get_resolution() val h3_resolution 881e309739fffff 5 8 881e2659c3fffff 1 8
Source code in vgridpandas\h3pandas\h3pandas.py
170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
h3_is_valid()
¶
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', 'INVALID']) df.h3.h3_is_valid() val h3_is_valid 881e309739fffff 5 True INVALID 1 False
Source code in vgridpandas\h3pandas\h3pandas.py
198 199 200 201 202 203 204 205 206 207 208 209 |
|
h3_to_center_child(resolution=None)
¶
Parameters¶
resolution : int or None H3 resolution. If none, then returns the child of resolution directly below that of each H3 cell
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.h3_to_center_child() val h3_center_child 881e309739fffff 5 891e3097383ffff 881e2659c3fffff 1 891e2659c23ffff
Source code in vgridpandas\h3pandas\h3pandas.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
hex_ring(k=1, explode=False)
¶
Parameters¶
k : int the distance from the origin H3 id. Default k = 1 explode : bool If True, will explode the resulting list vertically. All other columns' values are copied. Default: False
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.hex_ring(1) val h3_hex_ring 881e309739fffff 5 [881e30973dfffff, 881e309703fffff, 881e309707f... 881e2659c3fffff 1 [881e2659ddfffff, 881e2659cbfffff, 881e2659d5f... df.h3.hex_ring(1, explode=True) val h3_hex_ring 881e2659c3fffff 1 881e2659ddfffff 881e2659c3fffff 1 881e2659cbfffff 881e2659c3fffff 1 881e2659d5fffff 881e2659c3fffff 1 881e2659c7fffff 881e2659c3fffff 1 881e265989fffff 881e2659c3fffff 1 881e2659c1fffff 881e309739fffff 5 881e30973dfffff 881e309739fffff 5 881e309703fffff 881e309739fffff 5 881e309707fffff 881e309739fffff 5 881e30973bfffff 881e309739fffff 5 881e309715fffff 881e309739fffff 5 881e309731fffff
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
k_ring(k=1, explode=False)
¶
Parameters¶
k : int the distance from the origin H3 id. Default k = 1 explode : bool If True, will explode the resulting list vertically. All other columns' values are copied. Default: False
See Also¶
k_ring_smoothing : Extended API method that distributes numeric values to the k-ring cells
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.k_ring(1) val h3_k_ring 881e309739fffff 5 [881e30973dfffff, 881e309703fffff, 881e309707f... 881e2659c3fffff 1 [881e2659ddfffff, 881e2659c3fffff, 881e2659cbf...
df.h3.k_ring(1, explode=True) val h3_k_ring 881e2659c3fffff 1 881e2659ddfffff 881e2659c3fffff 1 881e2659c3fffff 881e2659c3fffff 1 881e2659cbfffff 881e2659c3fffff 1 881e2659d5fffff 881e2659c3fffff 1 881e2659c7fffff 881e2659c3fffff 1 881e265989fffff 881e2659c3fffff 1 881e2659c1fffff 881e309739fffff 5 881e30973dfffff 881e309739fffff 5 881e309703fffff 881e309739fffff 5 881e309707fffff 881e309739fffff 5 881e30973bfffff 881e309739fffff 5 881e309715fffff 881e309739fffff 5 881e309739fffff 881e309739fffff 5 881e309731fffff
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
k_ring_smoothing(k=None, weights=None, return_geometry=True)
¶
Experimental. Creates a k-ring around each input cell and distributes the cell's values.
The values are distributed either
- uniformly (by setting k
) or
- by weighing their values using weights
.
Only numeric columns are modified.
Parameters¶
k : int
The distance from the origin H3 id
weights : Sequence[float]
Weighting of the values based on the distance from the origin.
First weight corresponds to the origin.
Values are be normalized to add up to 1.
return_geometry: bool
(Optional) Whether to add a geometry
column with the hexagonal cells.
Default = True
Returns¶
(Geo)DataFrame with smoothed values
See Also¶
k_ring : H3 API method upon which this method builds
Examples¶
df = pd.DataFrame({'val': [5, 1]}, index=['881e309739fffff', '881e2659c3fffff']) df.h3.k_ring_smoothing(1) val geometry h3_k_ring 881e265989fffff 0.142857 POLYGON ((14.99488 50.99821, 14.99260 50.99389... 881e2659c1fffff 0.142857 POLYGON ((14.97944 51.00758, 14.97717 51.00326... 881e2659c3fffff 0.142857 POLYGON ((14.99201 51.00565, 14.98973 51.00133... 881e2659c7fffff 0.142857 POLYGON ((14.98231 51.00014, 14.98004 50.99582... 881e2659cbfffff 0.142857 POLYGON ((14.98914 51.01308, 14.98687 51.00877... 881e2659d5fffff 0.142857 POLYGON ((15.00458 51.00371, 15.00230 50.99940... 881e2659ddfffff 0.142857 POLYGON ((15.00171 51.01115, 14.99943 51.00684... 881e309703fffff 0.714286 POLYGON ((13.99235 50.01119, 13.99017 50.00681... 881e309707fffff 0.714286 POLYGON ((13.98290 50.00555, 13.98072 50.00116... 881e309715fffff 0.714286 POLYGON ((14.00473 50.00932, 14.00255 50.00494... 881e309731fffff 0.714286 POLYGON ((13.99819 49.99617, 13.99602 49.99178... 881e309739fffff 0.714286 POLYGON ((13.99527 50.00368, 13.99310 49.99929... 881e30973bfffff 0.714286 POLYGON ((14.00765 50.00181, 14.00547 49.99742... 881e30973dfffff 0.714286 POLYGON ((13.98582 49.99803, 13.98364 49.99365... df.h3.k_ring_smoothing(weights=[2, 1]) val geometry h3_hex_ring 881e265989fffff 0.125 POLYGON ((14.99488 50.99821, 14.99260 50.99389... 881e2659c1fffff 0.125 POLYGON ((14.97944 51.00758, 14.97717 51.00326... 881e2659c3fffff 0.250 POLYGON ((14.99201 51.00565, 14.98973 51.00133... 881e2659c7fffff 0.125 POLYGON ((14.98231 51.00014, 14.98004 50.99582... 881e2659cbfffff 0.125 POLYGON ((14.98914 51.01308, 14.98687 51.00877... 881e2659d5fffff 0.125 POLYGON ((15.00458 51.00371, 15.00230 50.99940... 881e2659ddfffff 0.125 POLYGON ((15.00171 51.01115, 14.99943 51.00684... 881e309703fffff 0.625 POLYGON ((13.99235 50.01119, 13.99017 50.00681... 881e309707fffff 0.625 POLYGON ((13.98290 50.00555, 13.98072 50.00116... 881e309715fffff 0.625 POLYGON ((14.00473 50.00932, 14.00255 50.00494... 881e309731fffff 0.625 POLYGON ((13.99819 49.99617, 13.99602 49.99178... 881e309739fffff 1.250 POLYGON ((13.99527 50.00368, 13.99310 49.99929... 881e30973bfffff 0.625 POLYGON ((14.00765 50.00181, 14.00547 49.99742... 881e30973dfffff 0.625 POLYGON ((13.98582 49.99803, 13.98364 49.99365... df.h3.k_ring_smoothing(1, return_geometry=False) val h3_k_ring 881e265989fffff 0.142857 881e2659c1fffff 0.142857 881e2659c3fffff 0.142857 881e2659c7fffff 0.142857 881e2659cbfffff 0.142857 881e2659d5fffff 0.142857 881e2659ddfffff 0.142857 881e309703fffff 0.714286 881e309707fffff 0.714286 881e309715fffff 0.714286 881e309731fffff 0.714286 881e309739fffff 0.714286 881e30973bfffff 0.714286 881e30973dfffff 0.714286
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
latlon2h3(resolution, lat_col='lat', lng_col='lon', set_index=True)
¶
Adds H3 index to (Geo)DataFrame.
pd.DataFrame: uses lat_col
and lng_col
(default lat
and lon
)
gpd.GeoDataFrame: uses geometry
Assumes coordinates in epsg=4326.
Parameters¶
resolution : int H3 resolution lat_col : str Name of the latitude column (if used), default 'lat' lng_col : str Name of the longitude column (if used), default 'lon' set_index : bool If True, the columns with H3 ID is set as index, default 'True'
Returns¶
(Geo)DataFrame with H3 ID added
See Also¶
geo_to_h3_aggregate : Extended API method that aggregates points by H3 id
Examples¶
df = pd.DataFrame({'lat': [50, 51], 'lng':[14, 15]}) df.h3.geo_to_h3(8) lat lng h3 881e309739fffff 50 14 881e2659c3fffff 51 15
df.h3.geo_to_h3(8, set_index=False) lat lng h3 0 50 14 881e309739fffff 1 51 15 881e2659c3fffff
gdf = gpd.GeoDataFrame({'val': [5, 1]}, geometry=gpd.points_from_xy(x=[14, 15], y=(50, 51))) gdf.h3.geo_to_h3(8) val geometry h3 881e309739fffff 5 POINT (14.00000 50.00000) 881e2659c3fffff 1 POINT (15.00000 51.00000)
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
linetrace(resolution, explode=False)
¶
Experimental. An H3 cell representation of a (Multi)LineString, which permits repeated cells, but not if they are repeated in immediate sequence.
Parameters¶
resolution : int H3 resolution explode : bool If True, will explode the resulting list vertically. All other columns' values are copied. Default: False
Returns¶
(Geo)DataFrame with H3 cells with centroids within the input polygons.
Examples¶
from shapely.geometry import LineString gdf = gpd.GeoDataFrame(geometry=[LineString([[0, 0], [1, 0], [1, 1]])]) gdf.h3.linetrace(4) geometry h3_linetrace 0 LINESTRING (0.00000 0.00000, 1.00000 0.00000, ... [83754efffffffff, 83754cfffffffff, 837541fffff... # noqa E501 gdf.h3.linetrace(4, explode=True) geometry h3_linetrace 0 LINESTRING (0.00000 0.00000, 1.00000 0.00000, ... 83754efffffffff 0 LINESTRING (0.00000 0.00000, 1.00000 0.00000, ... 83754cfffffffff 0 LINESTRING (0.00000 0.00000, 1.00000 0.00000, ... 837541fffffffff
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
polyfill(resolution, explode=False)
¶
Parameters¶
resolution : int H3 resolution explode : bool If True, will explode the resulting list vertically. All other columns' values are copied. Default: False
See Also¶
polyfill_resample : Extended API method that distributes the polygon's values to the H3 cells contained in it
Examples¶
from shapely.geometry import box gdf = gpd.GeoDataFrame(geometry=[box(0, 0, 1, 1)]) gdf.h3.polyfill(4) geometry h3 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... [84754e3ffffffff, 84754c7ffffffff, 84754c5ffff... # noqa E501 gdf.h3.polyfill(4, explode=True) geometry h3 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754e3ffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754c7ffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754c5ffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754ebffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754edffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754e1ffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 84754e9ffffffff 0 POLYGON ((1.00000 0.00000, 1.00000 1.00000, 0.... 8475413ffffffff
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|
polyfill_resample(resolution, return_geometry=True)
¶
Experimental. Currently essentially polyfill(..., explode=True) that sets the H3 index and adds the H3 cell geometry.
Parameters¶
resolution : int
H3 resolution
return_geometry: bool
(Optional) Whether to add a geometry
column with the hexagonal cells.
Default = True
Returns¶
(Geo)DataFrame with H3 cells with centroids within the input polygons.
See Also¶
polyfill : H3 API method upon which this method builds
Examples¶
from shapely.geometry import box gdf = gpd.GeoDataFrame(geometry=[box(0, 0, 1, 1)]) gdf.h3.polyfill_resample(4) index geometry h3 84754e3ffffffff 0 POLYGON ((0.33404 -0.11975, 0.42911 0.07901, 0... 84754c7ffffffff 0 POLYGON ((0.92140 -0.03115, 1.01693 0.16862, 0... 84754c5ffffffff 0 POLYGON ((0.91569 0.33807, 1.01106 0.53747, 0.... 84754ebffffffff 0 POLYGON ((0.62438 0.10878, 0.71960 0.30787, 0.... 84754edffffffff 0 POLYGON ((0.32478 0.61394, 0.41951 0.81195, 0.... 84754e1ffffffff 0 POLYGON ((0.32940 0.24775, 0.42430 0.44615, 0.... 84754e9ffffffff 0 POLYGON ((0.61922 0.47649, 0.71427 0.67520, 0.... 8475413ffffffff 0 POLYGON ((0.91001 0.70597, 1.00521 0.90497, 0....
Source code in vgridpandas\h3pandas\h3pandas.py
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 |
|