SpatialFrame
SpatialFrame
Source code in src\spatial_polars\spatialframe.py
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 |
|
write_spatial(path, layer=None, driver=None, geometry_name='geometry', geometry_type=None, crs=None, encoding=None, append=False, dataset_metadata=None, layer_metadata=None, metadata=None, dataset_options=None, layer_options=None)
Writes the dataframe to a format supported by pyogrio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | BytesIO
|
path to output file on writeable file system or an io.BytesIO object to allow writing to memory NOTE: support for writing to memory is limited to specific drivers. |
required |
layer
|
Optional[str]
|
layer name to create. If writing to memory and layer name is not provided, it layer name will be set to a UUID4 value. |
None
|
driver
|
Optional[str]
|
The OGR format driver used to write the vector file. By default attempts to infer driver from path. Must be provided to write to memory. |
None
|
geometry_name
|
str
|
The name of the column in the dataframe that will be written as the geometry field. |
'geometry'
|
geometry_type
|
Optional[str]
|
The geometry type of the written layer. Currently, this needs to be specified explicitly when creating a new layer with geometries. Possible values are: “Unknown”, “Point”, “LineString”, “Polygon”, “MultiPoint”, “MultiLineString”, “MultiPolygon” “GeometryCollection”, “Point Z”, “LineString Z”, “Polygon Z”, “MultiPoint Z”, “MultiLineString Z”, “MultiPolygon Z” or “GeometryCollection Z”. This parameter does not modify the geometry, but it will try to force the layer type of the output file to this value. Use this parameter with caution because using a wrong layer geometry type may result in errors when writing the file, may be ignored by the driver, or may result in invalid files. |
None
|
crs
|
Optional[str]
|
WKT-encoded CRS of the geometries to be written. If left as None, the CRS from the geometry column's struct will be used. |
None
|
encoding
|
Optional[str]
|
Only used for the .dbf file of ESRI Shapefiles. If not specified, uses the default locale. |
None
|
append
|
bool
|
If True, the data source specified by path already exists, and the driver supports appending to an existing data source, will cause the data to be appended to the existing records in the data source. Not supported for writing to in-memory files. NOTE: append support is limited to specific drivers and GDAL versions. |
False
|
dataset_metadata
|
Optional[dict]
|
Metadata to be stored at the dataset level in the output file; limited to drivers that support writing metadata, such as GPKG, and silently ignored otherwise. Keys and values must be strings. |
None
|
layer_metadata
|
Optional[dict]
|
Metadata to be stored at the layer level in the output file; limited to drivers that support writing metadata, such as GPKG, and silently ignored otherwise. Keys and values must be strings. |
None
|
metadata
|
Optional[dict]
|
alias of layer_metadata. |
None
|
dataset_options
|
Optional[dict]
|
Dataset creation options (format specific) passed to OGR. Specify as a key-value dictionary. |
None
|
layer_options
|
Optional[dict]
|
Layer creation options (format specific) passed to OGR. Specify as a key-value dictionary. |
None
|
Examples:
Writing a shapefile
>>> from spatial_polars import read_spatial
>>> my_shapefile = r"c:\data\roads.shp"
>>> df = read_spatial(my_shapefile)
>>> df.spatial.write_spatial(r"C:\data\roads_2.shp")
Writing a geopackage
Source code in src\spatial_polars\spatialframe.py
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 |
|
write_geoparquet(path, geometry_name='geometry', crs=None, write_bbox=False, write_geometry_types=None)
Writes the dataframe to a geoparquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
path to output file on writeable file system. |
required |
geometry_name
|
str
|
The name of the column in the dataframe that will be written as the geometry field. |
'geometry'
|
crs
|
Optional[str]
|
WKT-encoded CRS of the geometries to be written. If left as None, the CRS from the geometry column's struct will be used. |
None
|
write_bbox
|
bool
|
May be computationally expensive for large input. |
False
|
write_geometry_types
|
Optional[bool]
|
May be computationally expensive for large input. |
None
|
Note
Any rows with null geometries will be discarded.
Examples:
>>> from spatial_polars import read_spatial
>>> my_shapefile = r"c:\data\roads.shp"
>>> df = read_spatial(my_shapefile)
>>> df.spatial.write_geoparquet(r"c:\data\roads.parquet")
Source code in src\spatial_polars\spatialframe.py
to_geoarrow(geometry_name='geometry')
Converts the dataframe to geoarrow table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the column in the dataframe that will be written as the geometry field. |
'geometry'
|
Note
Any rows with null geometries will be discarded.
Examples:
>>> from spatial_polars import read_spatial
>>> my_shapefile = r"c:\data\roads.shp"
>>> df = read_spatial(my_shapefile)
>>> df.spatial.to_geoarrow()
pyarrow.Table
osm_id: large_string
code: int32
fclass: large_string
name: large_string
ref: large_string
oneway: large_string
maxspeed: int32
layer: int64
bridge: large_string
tunnel: large_string
geometry: extension<geoarrow.linestring<LinestringType>>
osm_id: [["4265057","4265058","4267607","4271616","4275365",...,"4372351","4372353","4374903","4374905","4374906"],["4375793","4376011","4377106","4377123","4377209",...,"4493766","4493790","4500373","4500375","4516633"],...,["1370367863","1370367864","1370367868","1370367873","1370367874",...,"1370383552","1370383553","1370383554","1370383556","1370383557"],["1370383558","1370383559","1370383560","1370383561","1370383562",...,"1370383592","1370383593","1370383594","1370383595","1370398885"]]
code: [[5114,5114,5114,5115,5122,...,5122,5152,5141,5122,5141],[5111,5111,5131,5131,5115,...,5114,5111,5152,5152,5111],...,[5153,5153,5153,5153,5153,...,5153,5153,5153,5141,5141],[5141,5153,5153,5153,5153,...,5153,5153,5153,5153,5141]]
fclass: [["secondary","secondary","secondary","tertiary","residential",...,"residential","cycleway","service","residential","service"],["motorway","motorway","motorway_link","motorway_link","tertiary",...,"secondary","motorway","cycleway","cycleway","motorway"],...,["footway","footway","footway","footway","footway",...,"footway","footway","footway","service","service"],["service","footway","footway","footway","footway",...,"footway","footway","footway","footway","service"]]
name: [["55th Street","Fairview Avenue","31st Street","59th Street","61st Street",...,"Fairmount Avenue",null,null,"Mochel Drive",null],["Kennedy Expressway","Kennedy Expressway",null,null,"59th Street",...,"Midwest Road","Ronald Reagan Memorial Tollway","Main Trail",null,"Borman Expressway"],...,[null,null,null,null,null,...,null,null,null,null,null],[null,null,null,null,null,...,null,null,null,null,null]]
ref: [[null,null,null,null,null,...,null,null,null,null,null],["I 190","I 190",null,null,null,...,null,"I 88;IL 110",null,null,"I 80;I 94;US 6"],...,[null,null,null,null,null,...,null,null,null,null,null],[null,null,null,null,null,...,null,null,null,null,null]]
oneway: [["F","B","B","B","B",...,"B","B","B","F","F"],["F","F","F","F","B",...,"B","F","B","B","F"],...,["B","B","B","B","B",...,"B","B","B","B","B"],["B","B","B","B","B",...,"B","B","B","B","B"]]
maxspeed: [[0,0,72,0,0,...,0,0,0,0,0],[0,0,0,0,0,...,0,96,0,0,88],...,[0,0,0,0,0,...,0,0,0,0,0],[0,0,0,0,0,...,0,0,0,0,0]]
layer: [[0,0,0,0,0,...,0,0,0,0,0],[0,0,0,0,0,...,0,0,0,0,0],...,[0,0,0,0,0,...,0,0,0,0,0],[0,0,0,0,0,...,0,0,0,0,0]]
bridge: [["F","F","F","F","F",...,"F","F","F","F","F"],["F","F","F","F","F",...,"F","F","F","F","F"],...,["F","F","F","F","F",...,"F","F","F","F","F"],["F","F","F","F","F",...,"F","F","F","F","F"]]
tunnel: [["F","F","F","F","F",...,"F","F","F","F","F"],["F","F","F","F","F",...,"F","F","F","F","F"],...,["F","F","F","F","F",...,"F","F","F","F","F"],["F","F","F","F","F",...,"F","F","F","F","F"]]
Source code in src\spatial_polars\spatialframe.py
join(other, how='inner', predicate='intersects', distance=None, on='geometry', left_on=None, right_on=None, suffix='_right', maintain_order='none')
Joins two SpatialFrames based on a spatial predicate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
DataFrame
|
SpatialFrame to join with. |
required |
how
|
Literal['left', 'right', 'full', 'inner', 'semi', 'anti']
|
Join strategy.
|
'inner'
|
predicate
|
Literal['intersects', 'within', 'contains', 'overlaps', 'crosses', 'touches', 'covers', 'covered_by', 'contains_properly', 'dwithin']
|
The predicate to use for testing geometries from the tree that are within the input geometry's bounding box. * intersects Joins rows in the left frame to the right frame if they share any portion of space.
|
'intersects'
|
distance
|
Optional[float]
|
Distances around each input geometry to join for the |
None
|
on
|
str
|
Name of the geometry columns in both SpatialFrames. |
'geometry'
|
left_on
|
Optional[str]
|
Name of the geometry column in the left SpatialFrame for the spatial join. |
None
|
right_on
|
Optional[str]
|
Name of the geometry column in the right SpatialFrame for the spatial join. |
None
|
suffix
|
str
|
Suffix to append to columns with a duplicate name. |
'_right'
|
maintain_order
|
Literal['none', 'left', 'right', 'left_right', 'right_left']
|
Which DataFrame row order to preserve, if any. Do not rely on any observed ordering without explicitly setting this parameter, as your code may break in a future release. Not specifying any ordering can improve performance Supported for inner, left, right and full joins
|
'none'
|
Note
Spatial joins only take into account x/y coodrdinates, any Z values present in the geometries are ignored.
Examples:
Spatial join roads that intersect rails
>>> import polars as pl
>>> from spatial_polars import scan_spatial
>>> zipped_data = r"C:\data\illinois-latest-free.shp.zip"
>>> roads_df, rails_df = pl.collect_all([
>>> scan_spatial(zipped_data, "gis_osm_roads_free_1").select("name", "geometry"),
>>> scan_spatial(zipped_data, "gis_osm_railways_free_1").select("name", "geometry")
>>> ],
>>> engine="streaming"
>>> )
>>> roads_rails_df = roads_df.spatial.join(
>>> rails_df,
>>> suffix="_rail"
>>> )
>>> roads_rails_df
shape: (43_772, 4)
┌─────────────────┬──────────────────────────┬──────────────────────────┬──────────────────────────┐
│ name ┆ geometry ┆ name_rail ┆ geometry_rail │
│ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ struct[2] ┆ str ┆ struct[2] │
╞═════════════════╪══════════════════════════╪══════════════════════════╪══════════════════════════╡
│ Kingery Highway ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00Y │
│ ┆ x02\x0… ┆ ┆ \x00\x… │
│ Kingery Highway ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00] │
│ ┆ x02\x0… ┆ ┆ \x00\x… │
│ Kingery Highway ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00[ │
│ ┆ x02\x0… ┆ ┆ \x00\x… │
│ Kingery Highway ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00Y │
│ ┆ x02\x0… ┆ ┆ \x00\x… │
│ Kingery Highway ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00] │
│ ┆ x02\x0… ┆ ┆ \x00\x… │
│ … ┆ … ┆ … ┆ … │
│ null ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00\ │
│ ┆ x02\x0… ┆ ┆ x02\x0… │
│ null ┆ {b"\x01\x02\x00\x00\x00\ ┆ BNSF Chicago Subdivision ┆ {b"\x01\x02\x00\x00\x00\ │
│ ┆ x02\x0… ┆ ┆ x02\x0… │
│ null ┆ {b"\x01\x02\x00\x00\x00\ ┆ UP Kenosha Subdivision ┆ {b"\x01\x02\x00\x00\x00\ │
│ ┆ x02\x0… ┆ ┆ x02\x0… │
│ null ┆ {b"\x01\x02\x00\x00\x00\ ┆ UP Kenosha Subdivision ┆ {b"\x01\x02\x00\x00\x00\ │
│ ┆ x02\x0… ┆ ┆ x02\x0… │
│ null ┆ {b"\x01\x02\x00\x00\x00\ ┆ Matteson Subdivision ┆ {b"\x01\x02\x00\x00\x00\ │
│ ┆ x16\x0… ┆ ┆ x1f\x0… │
└─────────────────┴──────────────────────────┴──────────────────────────┴──────────────────────────┘
Source code in src\spatial_polars\spatialframe.py
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 |
|
join_nearest(other, how='inner', max_distance=None, return_distance=False, exclusive=False, all_matches=True, on='geometry', left_on=None, right_on=None, suffix='_right', maintain_order='none')
Joins two dataframes based on a spatial distance .
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
DataFrame
|
SpatialFrame to join with. |
required |
how
|
Literal['left', 'inner']
|
Join strategy.
|
'inner'
|
max_distance
|
Optional[float]
|
The maximum distance to search around an input feature. |
None
|
on
|
str
|
Name of the geometry columns in both SpatialFrames. |
'geometry'
|
left_on
|
Optional[str]
|
Name of the geometry column in the left SpatialFrame for the spatial join. |
None
|
right_on
|
Optional[str]
|
Name of the geometry column in the right SpatialFrame for the spatial join. |
None
|
suffix
|
str
|
Suffix to append to columns with a duplicate name. |
'_right'
|
maintain_order
|
Literal['none', 'left', 'right', 'left_right', 'right_left']
|
Which DataFrame row order to preserve, if any. Do not rely on any observed ordering without explicitly setting this parameter, as your code may break in a future release. Not specifying any ordering can improve performance Supported for inner, left, right and full joins
|
'none'
|
Note
Spatial joins only take into account x/y coodrdinates, any Z values present in the geometries are ignored.
Source code in src\spatial_polars\spatialframe.py
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 |
|
viz(geometry_name='geometry', scatterplot_kwargs=None, path_kwargs=None, polygon_kwargs=None, map_kwargs=None)
Visualizes the dataframe as a layer in a Lonboard map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the column in the dataframe that will be use to visualize the features on the Lonboard map. |
'geometry'
|
scatterplot_kwargs
|
Optional[ScatterplotLayerKwargs]
|
a dict of parameters to pass down to all generated ScatterplotLayers. |
None
|
path_kwargs
|
Optional[PathLayerKwargs]
|
a dict of parameters to pass down to all generated PathLayers. |
None
|
polygon_kwargs
|
Optional[PolygonLayerKwargs]
|
a dict of parameters to pass down to all generated PolygonLayers. |
None
|
map_kwargs
|
Optional[MapKwargs]
|
a dict of parameters to pass down to the generated Map. |
None
|
Note
Any rows with null geometries will be discarded.
Examples:
>>> from spatial_polars import read_spatial
>>> my_shapefile = r"c:\data\roads.shp"
>>> df = read_spatial(my_shapefile)
>>> df.spatial.viz()
Source code in src\spatial_polars\spatialframe.py
to_scatterplotlayer(geometry_name='geometry', filled=True, fill_color=None, fill_cmap_col=None, fill_cmap_type=None, fill_cmap=None, fill_alpha=None, fill_normalize_cmap_col=True, stroked=True, line_color=None, line_cmap_col=None, line_cmap_type=None, line_cmap=None, line_alpha=None, line_normalize_cmap_col=True, line_width=1, line_width_min_pixels=1, line_width_max_pixels=None, line_width_scale=1, line_width_units='meters', radius=1, radius_max_pixels=None, radius_min_pixels=0, radius_scale=1, radius_units='meters', auto_highlight=False, highlight_color=[0, 0, 128, 128], opacity=1, pickable=True, visible=True, antialiasing=True, billboard=False)
Makes a Lonboard ScatterplotLayer from the SpatialFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the column in the SpatialFrame that will be used for the geometries of the points in the layer. |
'geometry'
|
filled
|
bool
|
Draw the filled area of points. |
True
|
fill_color
|
Union[List, Tuple, None]
|
The filled color of each object in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied. |
None
|
fill_cmap_col
|
Optional[str]
|
The name of the column in the SpatialFrame that will be used to vary the color of the points in the layer. Only applicable if |
None
|
fill_cmap_type
|
Union[Literal['categorical', 'continuous'], None]
|
The type of color map to use. Only applicable if |
None
|
fill_cmap
|
Optional[Union[Palette, Colormap, dict]]
|
If |
None
|
fill_alpha
|
Union[float, int, NDArray[floating], None]
|
The value which will be provided to the alpha chanel of the color for color map. Only applicable if |
None
|
fill_normalize_cmap_col
|
bool
|
If |
True
|
stroked
|
bool
|
The filled color of each object in the format of |
True
|
line_color
|
Union[List, Tuple, None]
|
The outline color of each object in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied. |
None
|
line_cmap_col
|
Optional[str]
|
The name of the column in the SpatialFrame that will be used to vary the color of the point outlines in the layer. Only applicable if |
None
|
line_cmap_type
|
Union[Literal['categorical', 'continuous'], None]
|
The type of color map to use. Only applicable if |
None
|
line_cmap
|
Optional[Union[Palette, Colormap, dict]]
|
If |
None
|
line_alpha
|
Union[float, int, NDArray[floating], None]
|
The value which will be provided to the alpha chanel of the color for color map. Only applicable if |
None
|
line_normalize_cmap_col
|
bool
|
If |
True
|
line_width
|
Union[float, int, NDArray[floating], str, None]
|
The width of each path, in units specified by |
1
|
line_width_min_pixels
|
float
|
The minimum path width in pixels. This prop can be used to prevent the path from getting too thin when zoomed out. |
1
|
line_width_max_pixels
|
Optional[float]
|
The maximum path width in pixels. This prop can be used to prevent the path from getting too thick when zoomed in. |
None
|
line_width_scale
|
float
|
The path width multiplier that multiplied to all paths. |
1
|
line_width_units
|
Literal['meters', 'common', 'pixels']
|
The units of the line width, one of 'meters', 'common', and 'pixels'. See unit system. |
'meters'
|
radius
|
Union[float, int, NDArray[floating], str, None]
|
The radius of each object, in units specified by radius_units (default 'meters'). If a string is provided, the values from the SpatialFrame in the column with the name will be used. If a number is provided, it is used as the width for all points. If an array is provided, each value in the array will be used as the width for the path at the same row index. |
1
|
radius_max_pixels
|
Optional[float]
|
The maximum radius in pixels. This can be used to prevent the circle from getting too big when zoomed in. |
None
|
radius_min_pixels
|
float
|
The minimum radius in pixels. This can be used to prevent the circle from getting too small when zoomed out. |
0
|
radius_scale
|
float
|
A global radius multiplier for all points. |
1
|
radius_units
|
Literal['meters', 'common', 'pixels']
|
The units of the radius, one of 'meters', 'common', and 'pixels' |
'meters'
|
auto_highlight
|
bool
|
When |
False
|
highlight_color
|
RGBA color to blend with the highlighted object (the hovered over object if |
[0, 0, 128, 128]
|
|
opacity
|
float
|
The opacity of the layer. |
1
|
pickable
|
bool
|
Whether the layer responds to mouse pointer picking events.
This must be set to |
True
|
visible
|
bool
|
Whether the layer is visible.
Under most circumstances, using the |
True
|
antialiasing
|
bool
|
If True, circles are rendered with smoothed edges. If False, circles are rendered with rough edges. Antialiasing can cause artifacts on edges of overlapping circles. |
True
|
billboard
|
bool
|
If True, rendered circles always face the camera. If False circles face up (i.e. are parallel with the ground plane). |
False
|
Note
Implementation varies slightly from Lonboard for the setting of color and width to make it easy to use from the SpatialFrame.
Source code in src\spatial_polars\spatialframe.py
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 |
|
to_pathlayer(geometry_name='geometry', color=None, cmap_col=None, cmap_type=None, cmap=None, alpha=None, normalize_cmap_col=True, width=1, auto_highlight=False, billboard=False, cap_rounded=False, highlight_color=[0, 0, 128, 128], joint_rounded=False, miter_limit=4, opacity=1, pickable=True, visible=True, width_min_pixels=1, width_max_pixels=None, width_scale=1, width_units='meters')
Makes a Lonboard PathLayer from the SpatialFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the column in the SpatialFrame that will be used for the geometries of the paths in the layer. |
'geometry'
|
color
|
Union[List, Tuple, None]
|
The color for every path in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied. |
None
|
cmap_col
|
Optional[str]
|
The name of the column in the SpatialFrame that will be used to vary the color of the paths in the layer. Only applicable if |
None
|
cmap_type
|
Union[Literal['categorical', 'continuous'], None]
|
The type of color map to use. Only applicable if |
None
|
cmap
|
Optional[Union[Palette, Colormap, dict]]
|
If |
None
|
alpha
|
Union[float, int, NDArray[floating], None]
|
The value which will be provided to the alpha chanel of the color for color map. Only applicable if |
None
|
normalize_cmap_col
|
bool
|
If |
True
|
width
|
Union[float, int, NDArray[floating], str, None]
|
The width of each path, in units specified by |
1
|
pickable
|
bool
|
Whether the layer responds to mouse pointer picking events.
This must be set to |
True
|
auto_highlight
|
bool
|
When |
False
|
highlight_color
|
RGBA color to blend with the highlighted object (the hovered over object if |
[0, 0, 128, 128]
|
|
billboard
|
bool
|
If |
False
|
cap_rounded
|
bool
|
Type of caps. If |
False
|
joint_rounded
|
bool
|
Type of joint. If |
False
|
miter_limit
|
float
|
The maximum extent of a joint in ratio to the stroke width. Only works if jointRounded is |
4
|
opacity
|
float
|
The opacity of the layer. |
1
|
visible
|
bool
|
Whether the layer is visible.
Under most circumstances, using the |
True
|
width_min_pixels
|
float
|
The minimum path width in pixels. This prop can be used to prevent the path from getting too thin when zoomed out. |
1
|
width_max_pixels
|
Optional[float]
|
The maximum path width in pixels. This prop can be used to prevent the path from getting too thick when zoomed in. |
None
|
width_scale
|
float
|
The path width multiplier that multiplied to all paths. |
1
|
width_units
|
Literal['meters', 'common', 'pixels']
|
The units of the line width, one of 'meters', 'common', and 'pixels'. See unit system. |
'meters'
|
Note
Implementation varies slightly from Lonboard for the setting of color and width to make it easy to use from the SpatialFrame.
Source code in src\spatial_polars\spatialframe.py
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 |
|
to_polygonlayer(geometry_name='geometry', filled=True, fill_color=None, fill_cmap_col=None, fill_cmap_type=None, fill_cmap=None, fill_alpha=None, fill_normalize_cmap_col=True, stroked=True, line_color=None, line_cmap_col=None, line_cmap_type=None, line_cmap=None, line_alpha=None, line_normalize_cmap_col=True, line_width=1, line_joint_rounded=False, line_miter_limit=4, line_width_min_pixels=1, line_width_max_pixels=None, line_width_scale=1, line_width_units='meters', elevation=None, elevation_scale=1, auto_highlight=False, highlight_color=[0, 0, 128, 128], opacity=1, pickable=True, visible=True, wireframe=False)
Makes a Lonboard PolygonLayer from the SpatialFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geometry_name
|
str
|
The name of the column in the SpatialFrame that will be used for the geometries of the polygons in the layer. |
'geometry'
|
filled
|
bool
|
Whether to draw a filled polygon (solid fill). Note that only the area between the outer polygon and any holes will be filled. |
True
|
fill_color
|
Union[List, Tuple, None]
|
The fill color for every polygon in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied. |
None
|
fill_cmap_col
|
Optional[str]
|
The name of the column in the SpatialFrame that will be used to vary the color of the polygons in the layer. Only applicable if |
None
|
fill_cmap_type
|
Union[Literal['categorical', 'continuous'], None]
|
The type of color map to use. Only applicable if |
None
|
fill_cmap
|
Optional[Union[Palette, Colormap, dict]]
|
If |
None
|
fill_alpha
|
Union[float, int, NDArray[floating], None]
|
The value which will be provided to the alpha chanel of the color for color map. Only applicable if |
None
|
fill_normalize_cmap_col
|
bool
|
If |
True
|
stroked
|
bool
|
Whether to draw an outline around the polygon (solid fill). Note that both the outer polygon as well the outlines of any holes will be drawn. |
True
|
line_color
|
Union[List, Tuple, None]
|
The color for every polygon outline in the format of [r, g, b, [a]]. Each channel is a number between 0-255 and a is 255 if not supplied. |
None
|
line_cmap_col
|
Optional[str]
|
The name of the column in the SpatialFrame that will be used to vary the color of the polygon outlines in the layer. Only applicable if |
None
|
line_cmap_type
|
Union[Literal['categorical', 'continuous'], None]
|
The type of color map to use. Only applicable if |
None
|
line_cmap
|
Optional[Union[Palette, Colormap, dict]]
|
If |
None
|
line_alpha
|
Union[float, int, NDArray[floating], None]
|
The value which will be provided to the alpha chanel of the color for color map. Only applicable if |
None
|
line_normalize_cmap_col
|
bool
|
If |
True
|
line_width
|
Union[float, int, NDArray[floating], str, None]
|
The width of each path, in units specified by |
1
|
line_joint_rounded
|
bool
|
Type of joint. If |
False
|
line_miter_limit
|
float
|
The maximum extent of a joint in ratio to the stroke width. Only works if jointRounded is |
4
|
line_width_min_pixels
|
float
|
The minimum path width in pixels. This prop can be used to prevent the path from getting too thin when zoomed out. |
1
|
line_width_max_pixels
|
Optional[float]
|
The maximum path width in pixels. This prop can be used to prevent the path from getting too thick when zoomed in. |
None
|
line_width_scale
|
float
|
The path width multiplier that multiplied to all paths. |
1
|
line_width_units
|
Literal['meters', 'common', 'pixels']
|
The units of the line width, one of 'meters', 'common', and 'pixels'. See unit system. |
'meters'
|
elevation
|
Union[float, int, NDArray[floating], str, None]
|
The elevation to extrude each polygon with, in meters. Only applies if extruded=True. If a number is provided, it is used as the width for all polygons. If an array is provided, each value in the array will be used as the width for the polygon at the same row index. If a string is provided it will be used as a column name in the frame to use for the elevation.
Providing a value to elevation will set |
None
|
elevation_scale
|
float
|
Elevation multiplier. The final elevation is calculated by elevation_scale * elevation(d). |
1
|
auto_highlight
|
bool
|
When |
False
|
highlight_color
|
RGBA color to blend with the highlighted object (the hovered over object if |
[0, 0, 128, 128]
|
|
opacity
|
float
|
The opacity of the layer. |
1
|
pickable
|
bool
|
Whether the layer responds to mouse pointer picking events.
This must be set to |
True
|
visible
|
bool
|
Whether the layer is visible.
Under most circumstances, using the |
True
|
wireframe
|
bool
|
Whether to generate a line wireframe of the polygon. The outline will have "horizontal" lines closing the top and bottom polygons and a vertical line (a "strut") for each vertex on the polygon. |
False
|
Note
Implementation varies slightly from Lonboard for the setting of color and width to make it easy to use from the SpatialFrame.
Source code in src\spatial_polars\spatialframe.py
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 |
|
from_point_coords(df, x_col, y_col, z_col=None, crs=4326)
staticmethod
Creates a SpatialFrame from a polars DataFrame with x/y/(z) columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_col
|
str
|
The name of the column in the DataFrame which holds the X coordinates. |
required |
y_col
|
str
|
The name of the column in the DataFrame which holds the Y coordinates. |
required |
z_col
|
Optional[str]
|
The name of the column in the DataFrame which holds the Z coordinates. |
None
|
crs
|
Any
|
A crs representation that can be provided to pyproj.CRS.from_user_input to produce a CRS. PROJ string Dictionary of PROJ parameters PROJ keyword arguments for parameters JSON string with PROJ parameters CRS WKT string An authority string [i.e. ‘epsg:4326’] An EPSG integer code [i.e. 4326] A tuple of (“auth_name”: “auth_code”) [i.e (‘epsg’, ‘4326’)] An object with a to_wkt method. A pyproj.crs.CRS class |
4326
|
Examples:
Creating a SpatialFrame from a polars df with a columns of coordinates of points .
>>> import polars as pl
>>> from spatial_polars import SpatialFrame
>>> df = pl.DataFrame({
>>> "Place":["Gateway Arch", "Monks Mound"],
>>> "x":[-90.18497, -90.06211],
>>> "y":[38.62456, 38.66072],
>>> "z":[0,0]
>>> })
>>> s_df = SpatialFrame.from_point_coords(df, "x", "y", "z")
>>> s_df
shape: (2, 2)
┌──────────────┬─────────────────────────────────┐
│ Place ┆ geometry │
│ --- ┆ --- │
│ str ┆ struct[2] │
╞══════════════╪═════════════════════════════════╡
│ Gateway Arch ┆ {b"\x01\x01\x00\x00\x80o/i\x8c… │
│ Monks Mound ┆ {b"\x01\x01\x00\x00\x80K\xb08\… │
└──────────────┴─────────────────────────────────┘
Source code in src\spatial_polars\spatialframe.py
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 |
|
from_WKB(df, wkb_col, crs=4326)
staticmethod
Creates a SpatialFrame from a polars DataFrame with a column of WKB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wkb_col
|
str
|
The name of the column in the DataFrame which holds geometry WKB. |
required |
crs
|
Any
|
A crs representation that can be provided to pyproj.CRS.from_user_input to produce a CRS. PROJ string Dictionary of PROJ parameters PROJ keyword arguments for parameters JSON string with PROJ parameters CRS WKT string An authority string [i.e. 'epsg:4326'] An EPSG integer code [i.e. 4326] A tuple of (“auth_name”: “auth_code”) [i.e ('epsg', '4326')] An object with a to_wkt method. A pyproj.crs.CRS class |
4326
|
Examples:
Creating a SpatialFrame from a polars df with a column of WKB.
>>> import polars as pl
>>> import shapely
>>> from spatial_polars import SpatialFrame
>>> arch_wkb = shapely.Point(-90.18497, 38.62456).wkb
>>> monks_mound_wkb = shapely.Point(-90.06211, 38.66072).wkb
>>> df = pl.DataFrame({
>>> "Place":["Gateway Arch", "Monks Mound"],
>>> "wkb":[arch_wkb, monks_mound_wkb],
>>> })
>>> s_df = SpatialFrame.from_WKB(df, "wkb")
>>> s_df
shape: (2, 2)
┌──────────────┬─────────────────────────────────┐
│ Place ┆ geometry │
│ --- ┆ --- │
│ str ┆ struct[2] │
╞══════════════╪═════════════════════════════════╡
│ Gateway Arch ┆ {b"\x01\x01\x00\x00\x80o/i\x8c… │
│ Monks Mound ┆ {b"\x01\x01\x00\x00\x80K\xb08\… │
└──────────────┴─────────────────────────────────┘
Source code in src\spatial_polars\spatialframe.py
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 |
|
from_WKT(df, wkt_col, crs=4326)
staticmethod
Creates a SpatialFrame from a polars DataFrame with a column of WKT.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wkt_col
|
str
|
The name of the column in the DataFrame which holds geometry WKT. |
required |
crs
|
Any
|
A crs representation that can be provided to pyproj.CRS.from_user_input to produce a CRS. PROJ string Dictionary of PROJ parameters PROJ keyword arguments for parameters JSON string with PROJ parameters CRS WKT string An authority string [i.e. ‘epsg:4326’] An EPSG integer code [i.e. 4326] A tuple of (“auth_name”: “auth_code”) [i.e (‘epsg’, ‘4326’)] An object with a to_wkt method. A pyproj.crs.CRS class |
4326
|
Examples:
Creating a SpatialFrame from a polars df with a column of WKT.
>>> import polars as pl
>>> import shapely
>>> from spatial_polars import SpatialFrame
>>> arch_wkt = shapely.Point(-90.18497, 38.62456).wkt
>>> monks_mound_wkt = shapely.Point(-90.06211, 38.66072).wkt
>>> df = pl.DataFrame({
>>> "Place":["Gateway Arch", "Monks Mound"],
>>> "wkt":[arch_wkt, monks_mound_wkt],
>>> })
>>> s_df = SpatialFrame.from_WKT(df, "wkt")
>>> s_df
shape: (2, 2)
┌──────────────┬─────────────────────────────────┐
│ Place ┆ geometry │
│ --- ┆ --- │
│ str ┆ struct[2] │
╞══════════════╪═════════════════════════════════╡
│ Gateway Arch ┆ {b"\x01\x01\x00\x00\x80o/i\x8c… │
│ Monks Mound ┆ {b"\x01\x01\x00\x00\x80K\xb08\… │
└──────────────┴─────────────────────────────────┘
Source code in src\spatial_polars\spatialframe.py
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 |
|