⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂

From/to GeoPandas

From/to GeoPandas#

This example demonstrates importing or exporting a geopandas.GeoDataFrame from and to a Vector.

A vector can be imported from a geopandas.GeoDataFrame simply by instantiating Vector.

import geopandas as gpd

import geoutils as gu

filename_vect = gu.examples.get_path("exploradores_rgi_outlines")
ds = gpd.read_file(filename_vect)
vect = gu.Vector(ds)
vect
Vector(
  ds=             RGIId  ...                                           geometry
       0   RGI60-17.08409  ...  MULTIPOLYGON (((-73.11803 -46.64900, -73.11829...
       1   RGI60-17.08414  ...  MULTIPOLYGON (((-73.10885 -46.64261, -73.10886...
       2   RGI60-17.08421  ...  MULTIPOLYGON (((-73.11682 -46.63879, -73.11678...
       3   RGI60-17.08422  ...  MULTIPOLYGON (((-73.10885 -46.64261, -73.10924...
       4   RGI60-17.08440  ...  MULTIPOLYGON (((-73.13223 -46.60028, -73.13225...
       5   RGI60-17.08444  ...  MULTIPOLYGON (((-73.06497 -46.59154, -73.06456...
       6   RGI60-17.08461  ...  MULTIPOLYGON (((-73.11366 -46.58218, -73.11259...
       7   RGI60-17.08470  ...  MULTIPOLYGON (((-73.06988 -46.57715, -73.06988...
       8   RGI60-17.08481  ...  MULTIPOLYGON (((-73.10740 -46.56410, -73.10700...
       9   RGI60-17.08503  ...  MULTIPOLYGON (((-73.13354 -46.55352, -73.13340...
       10  RGI60-17.08517  ...  MULTIPOLYGON (((-73.11662 -46.54876, -73.11676...
       11  RGI60-17.08519  ...  MULTIPOLYGON (((-73.12973 -46.54177, -73.12953...
       12  RGI60-17.08523  ...  MULTIPOLYGON (((-73.08150 -46.54548, -73.08151...
       13  RGI60-17.08531  ...  MULTIPOLYGON (((-73.06693 -46.54848, -73.06715...
       14  RGI60-17.08558  ...  MULTIPOLYGON (((-73.09498 -46.51290, -73.09496...
       15  RGI60-17.08613  ...  MULTIPOLYGON (((-73.26343 -46.48548, -73.26342...
       16  RGI60-17.08618  ...  MULTIPOLYGON (((-73.26768 -46.48257, -73.26798...
       17  RGI60-17.08626  ...  MULTIPOLYGON (((-73.27852 -46.47776, -73.27857...
       18  RGI60-17.08631  ...  MULTIPOLYGON (((-73.25453 -46.48264, -73.25492...
       19  RGI60-17.08639  ...  MULTIPOLYGON (((-73.35668 -46.47795, -73.35670...
       20  RGI60-17.08642  ...  MULTIPOLYGON (((-73.26943 -46.48095, -73.26939...
       21  RGI60-17.08643  ...  MULTIPOLYGON (((-73.14301 -46.46434, -73.14303...
       22  RGI60-17.08646  ...  MULTIPOLYGON (((-73.34771 -46.46459, -73.34769...
       23  RGI60-17.08651  ...  MULTIPOLYGON (((-73.12796 -46.45651, -73.12799...
       24  RGI60-17.08658  ...  MULTIPOLYGON (((-73.12474 -46.45528, -73.12476...
       25  RGI60-17.08663  ...  MULTIPOLYGON (((-73.16107 -46.44905, -73.16106...
       26  RGI60-17.08664  ...  MULTIPOLYGON (((-73.33401 -46.45251, -73.33440...
       27  RGI60-17.08668  ...  MULTIPOLYGON (((-73.15723 -46.44710, -73.15690...
       28  RGI60-17.08673  ...  MULTIPOLYGON (((-73.39064 -46.44468, -73.39045...
       29  RGI60-17.08703  ...  MULTIPOLYGON (((-73.38584 -46.45433, -73.38580...
       30  RGI60-17.15808  ...  MULTIPOLYGON (((-73.79749 -46.66563, -73.79788...
       31  RGI60-17.15809  ...  MULTIPOLYGON (((-73.35278 -46.60069, -73.35277...
       32  RGI60-17.15815  ...  MULTIPOLYGON (((-73.56531 -46.54740, -73.56492...
       33  RGI60-17.15821  ...  MULTIPOLYGON (((-73.41283 -46.50246, -73.41283...
       34  RGI60-17.15822  ...  MULTIPOLYGON (((-73.40283 -46.49692, -73.40284...
       35  RGI60-17.15825  ...  MULTIPOLYGON (((-73.31737 -46.54240, -73.31698...
       36  RGI60-17.15826  ...  MULTIPOLYGON (((-73.30579 -46.52468, -73.30657...
       37  RGI60-17.15827  ...  MULTIPOLYGON (((-73.27290 -46.51339, -73.27289...
       38  RGI60-17.15828  ...  MULTIPOLYGON (((-73.25946 -46.51777, -73.25946...
       39  RGI60-17.15829  ...  MULTIPOLYGON (((-73.25347 -46.52173, -73.25386...
       40  RGI60-17.15830  ...  MULTIPOLYGON (((-73.24741 -46.52785, -73.24742...
       41  RGI60-17.15831  ...  MULTIPOLYGON (((-73.21109 -46.59721, -73.21070...
       42  RGI60-17.15832  ...  MULTIPOLYGON (((-73.19973 -46.58543, -73.19973...
       43  RGI60-17.15833  ...  MULTIPOLYGON (((-73.22511 -46.63577, -73.22785...
       44  RGI60-17.15834  ...  MULTIPOLYGON (((-73.22215 -46.66623, -73.22213...
       45  RGI60-17.15835  ...  MULTIPOLYGON (((-73.24759 -46.65583, -73.24720...
       46  RGI60-17.15836  ...  MULTIPOLYGON (((-73.30945 -46.70913, -73.30945...

       [47 rows x 23 columns]
  crs=EPSG:4326
  bounds=BoundingBox(left=-73.85175999999996, bottom=-46.83761999999996, right=-73.05486243399997, top=-46.431213112999956))


We plot the vector.

vect.plot(column="RGIId")
import vector

To export, the geopandas.GeoDataFrame is always stored as an attribute as Vector is composed from it. See Composition from Rasterio and GeoPandas.

RGIId GLIMSId BgnDate EndDate CenLon CenLat O1Region O2Region Area Zmin Zmax Zmed Slope Aspect Lmax Status Connect Form TermType Surging Linkages Name geometry
0 RGI60-17.08409 G286876E46647S 20009999 20030531 -73.1236 -46.6473 17 1 0.520 1182 1889 1528 36.1 196 797 0 0 0 0 9 9 None MULTIPOLYGON (((-73.11803 -46.64900, -73.11829...
1 RGI60-17.08414 G286891E46646S 20009999 20030531 -73.1091 -46.6458 17 1 1.342 1181 1934 1490 27.9 152 1381 0 0 0 0 9 9 None MULTIPOLYGON (((-73.10885 -46.64261, -73.10886...
2 RGI60-17.08421 G286879E46639S 20009999 20030531 -73.1212 -46.6385 17 1 0.530 1443 1935 1748 29.4 302 977 0 0 0 0 9 9 None MULTIPOLYGON (((-73.11682 -46.63879, -73.11678...
3 RGI60-17.08422 G286891E46638S 20009999 20030531 -73.1089 -46.6378 17 1 0.924 1354 1932 1598 25.6 89 1264 0 0 0 0 9 9 None MULTIPOLYGON (((-73.10885 -46.64261, -73.10924...
4 RGI60-17.08440 G286866E46604S 20009999 20030531 -73.1340 -46.6040 17 1 0.156 1124 1476 1346 28.3 156 524 0 0 0 0 9 9 None MULTIPOLYGON (((-73.13223 -46.60028, -73.13225...
5 RGI60-17.08444 G286927E46605S 20009999 20030531 -73.0726 -46.6047 17 1 3.895 967 2040 1625 18.3 219 3499 0 0 0 0 9 9 None MULTIPOLYGON (((-73.06497 -46.59154, -73.06456...
6 RGI60-17.08461 G286886E46584S 20009999 20030531 -73.1144 -46.5838 17 1 0.087 1405 1671 1526 37.5 232 361 0 0 0 0 9 9 None MULTIPOLYGON (((-73.11366 -46.58218, -73.11259...
7 RGI60-17.08470 G286905E46592S 20009999 20030531 -73.0947 -46.5923 17 1 9.866 741 2134 1498 19.2 199 5967 0 0 0 2 9 9 None MULTIPOLYGON (((-73.06988 -46.57715, -73.06988...
8 RGI60-17.08481 G286896E46574S 20009999 20030531 -73.1036 -46.5743 17 1 2.200 1006 2086 1675 33.2 278 1890 0 0 0 0 9 9 None MULTIPOLYGON (((-73.10740 -46.56410, -73.10700...
9 RGI60-17.08503 G286874E46559S 20009999 20030531 -73.1262 -46.5587 17 1 1.919 1003 1640 1296 21.1 202 1885 0 0 1 0 9 9 None MULTIPOLYGON (((-73.13354 -46.55352, -73.13340...
10 RGI60-17.08517 G286877E46552S 20009999 20030531 -73.1227 -46.5517 17 1 2.252 995 1777 1283 27.5 32 1271 0 0 1 0 9 9 None MULTIPOLYGON (((-73.11662 -46.54876, -73.11676...
11 RGI60-17.08519 G286862E46546S 20009999 20030531 -73.1381 -46.5463 17 1 0.596 1166 1608 1318 17.3 326 813 0 0 0 0 9 9 None MULTIPOLYGON (((-73.12973 -46.54177, -73.12953...
12 RGI60-17.08523 G286917E46559S 20009999 20030531 -73.0834 -46.5588 17 1 5.487 800 2139 1357 28.7 308 2465 0 0 0 0 9 9 None MULTIPOLYGON (((-73.08150 -46.54548, -73.08151...
13 RGI60-17.08531 G286925E46542S 20009999 20030531 -73.0746 -46.5418 17 1 2.191 948 1898 1254 18.0 62 2125 0 0 0 0 9 9 None MULTIPOLYGON (((-73.06693 -46.54848, -73.06715...
14 RGI60-17.08558 G286902E46514S 20009999 20030531 -73.0980 -46.5142 17 1 0.094 1251 1335 1298 17.7 154 236 0 0 0 0 9 9 None MULTIPOLYGON (((-73.09498 -46.51290, -73.09496...
15 RGI60-17.08613 G286738E46487S 20009999 20030531 -73.2620 -46.4874 17 1 0.036 1275 1441 1355 31.9 139 396 0 0 0 0 9 9 None MULTIPOLYGON (((-73.26343 -46.48548, -73.26342...
16 RGI60-17.08618 G286734E46482S 20009999 20030531 -73.2661 -46.4821 17 1 0.109 1361 1486 1420 15.7 0 355 0 0 0 0 9 9 None MULTIPOLYGON (((-73.26768 -46.48257, -73.26798...
17 RGI60-17.08626 G286720E46478S 20009999 20030531 -73.2801 -46.4777 17 1 0.109 1373 1500 1471 19.9 71 215 0 0 0 0 9 9 None MULTIPOLYGON (((-73.27852 -46.47776, -73.27857...
18 RGI60-17.08631 G286750E46481S 20009999 20030531 -73.2499 -46.4810 17 1 0.506 1227 1499 1371 26.3 141 499 0 0 0 0 9 9 None MULTIPOLYGON (((-73.25453 -46.48264, -73.25492...
19 RGI60-17.08639 G286646E46474S 20009999 20030531 -73.3538 -46.4741 17 1 0.234 1074 1425 1315 35.8 130 316 0 0 0 0 9 9 None MULTIPOLYGON (((-73.35668 -46.47795, -73.35670...
20 RGI60-17.08642 G286734E46476S 20009999 20030531 -73.2656 -46.4758 17 1 1.587 1136 1486 1243 12.3 344 1935 0 0 0 0 9 9 None MULTIPOLYGON (((-73.26943 -46.48095, -73.26939...
21 RGI60-17.08643 G286854E46466S 20009999 20030531 -73.1460 -46.4663 17 1 0.210 1243 1461 1402 21.3 145 451 0 0 0 0 9 9 None MULTIPOLYGON (((-73.14301 -46.46434, -73.14303...
22 RGI60-17.08646 G286650E46467S 20009999 20030531 -73.3498 -46.4665 17 1 0.118 1170 1378 1313 31.0 102 293 0 0 0 0 9 9 None MULTIPOLYGON (((-73.34771 -46.46459, -73.34769...
23 RGI60-17.08651 G286871E46459S 20009999 20030531 -73.1288 -46.4589 17 1 0.187 1245 1409 1359 22.0 165 379 0 0 0 0 9 9 None MULTIPOLYGON (((-73.12796 -46.45651, -73.12799...
24 RGI60-17.08658 G286874E46454S 20009999 20030531 -73.1264 -46.4541 17 1 0.030 1216 1337 1293 28.3 87 180 0 0 0 0 9 9 None MULTIPOLYGON (((-73.12474 -46.45528, -73.12476...
25 RGI60-17.08663 G286838E46450S 20009999 20030531 -73.1619 -46.4501 17 1 0.038 1310 1425 1372 23.5 182 250 0 0 0 0 9 9 None MULTIPOLYGON (((-73.16107 -46.44905, -73.16106...
26 RGI60-17.08664 G286661E46457S 20009999 20030531 -73.3390 -46.4568 17 1 0.197 1189 1391 1316 32.1 131 325 0 0 0 0 9 9 None MULTIPOLYGON (((-73.33401 -46.45251, -73.33440...
27 RGI60-17.08668 G286843E46450S 20009999 20030531 -73.1569 -46.4498 17 1 0.123 1136 1461 1308 32.4 139 526 0 0 0 0 9 9 None MULTIPOLYGON (((-73.15723 -46.44710, -73.15690...
28 RGI60-17.08673 G286610E46451S 20009999 20030531 -73.3900 -46.4507 17 1 0.681 790 1398 1118 38.9 196 864 0 0 0 0 9 9 None MULTIPOLYGON (((-73.39064 -46.44468, -73.39045...
29 RGI60-17.08703 G286615E46454S 20009999 20030531 -73.3851 -46.4538 17 1 1.322 940 1392 1259 23.3 116 995 0 0 0 0 9 9 None MULTIPOLYGON (((-73.38584 -46.45433, -73.38580...
30 RGI60-17.15808 G286520E46720S 20011103 -9999999 -73.4800 -46.7200 17 1 721.950 43 3861 1345 6.1 265 53509 0 0 0 1 9 9 San Rafael MULTIPOLYGON (((-73.79749 -46.66563, -73.79788...
31 RGI60-17.15809 G286570E46600S 20011103 -9999999 -73.4300 -46.6000 17 1 126.949 23 3975 1138 14.5 287 17716 0 0 0 2 9 9 Gualas MULTIPOLYGON (((-73.35278 -46.60069, -73.35277...
32 RGI60-17.15815 G286550E46560S 20011103 -9999999 -73.4500 -46.5600 17 1 71.511 47 3389 1415 16.3 302 22268 0 0 0 2 9 9 Reichert MULTIPOLYGON (((-73.56531 -46.54740, -73.56492...
33 RGI60-17.15821 G286530E46483S 20011103 -9999999 -73.4700 -46.4830 17 1 7.013 289 1884 1386 21.2 53 6261 0 0 0 2 9 9 Verde MULTIPOLYGON (((-73.41283 -46.50246, -73.41283...
34 RGI60-17.15822 G286287E46621S 20011103 -9999999 -73.7130 -46.6210 17 1 1.453 846 1493 1242 33.7 124 735 0 0 0 0 9 9 None MULTIPOLYGON (((-73.40283 -46.49692, -73.40284...
35 RGI60-17.15825 G286620E46550S 20011103 -9999999 -73.3800 -46.5500 17 1 65.501 218 3949 1214 22.9 24 17953 0 0 0 2 9 9 Grosse MULTIPOLYGON (((-73.31737 -46.54240, -73.31698...
36 RGI60-17.15826 G286735E46710S 20011103 -9999999 -73.2650 -46.7100 17 1 0.442 1218 1563 1411 31.7 78 466 0 0 0 0 9 9 None MULTIPOLYGON (((-73.30579 -46.52468, -73.30657...
37 RGI60-17.15827 G286705E46538S 20011103 -9999999 -73.2950 -46.5380 17 1 4.470 1210 2123 1612 28.4 350 1574 0 0 0 0 9 9 None MULTIPOLYGON (((-73.27290 -46.51339, -73.27289...
38 RGI60-17.15828 G286731E46517S 20011103 -9999999 -73.2690 -46.5170 17 1 1.624 1186 1741 1448 20.3 39 2221 0 0 0 0 9 9 None MULTIPOLYGON (((-73.25946 -46.51777, -73.25946...
39 RGI60-17.15829 G286746E46519S 20011103 -9999999 -73.2540 -46.5190 17 1 0.891 1111 1739 1473 30.9 96 937 0 0 0 0 9 9 None MULTIPOLYGON (((-73.25347 -46.52173, -73.25386...
40 RGI60-17.15830 G286735E46710S 20011103 -9999999 -73.2650 -46.7100 17 1 0.180 796 1519 1278 40.3 150 736 0 0 0 0 9 9 None MULTIPOLYGON (((-73.24741 -46.52785, -73.24742...
41 RGI60-17.15831 G286716E46597S 20011103 -9999999 -73.2840 -46.5970 17 1 85.788 158 3735 1688 17.9 54 19749 0 0 0 0 9 9 Exploradores MULTIPOLYGON (((-73.21109 -46.59721, -73.21070...
42 RGI60-17.15832 G286735E46710S 20011103 -9999999 -73.2650 -46.7100 17 1 1.025 904 1827 1274 36.9 118 560 0 0 0 0 9 9 None MULTIPOLYGON (((-73.19973 -46.58543, -73.19973...
43 RGI60-17.15833 G286767E46628S 20011103 -9999999 -73.2330 -46.6280 17 1 13.403 340 2601 710 19.1 68 10501 0 0 0 0 9 9 Bayo MULTIPOLYGON (((-73.22511 -46.63577, -73.22785...
44 RGI60-17.15834 G286765E46650S 20011103 -9999999 -73.2350 -46.6500 17 1 10.522 510 2450 1368 21.7 113 7012 0 0 0 0 9 9 U-6 MULTIPOLYGON (((-73.22215 -46.66623, -73.22213...
45 RGI60-17.15835 G286735E46710S 20011103 -9999999 -73.2650 -46.7100 17 1 7.632 775 1700 1446 27.4 231 1184 0 0 0 0 9 9 None MULTIPOLYGON (((-73.24759 -46.65583, -73.24720...
46 RGI60-17.15836 G286697E46659S 20011103 -9999999 -73.3030 -46.6590 17 1 41.513 380 3311 1625 25.1 123 13262 0 0 0 2 9 9 Fiero MULTIPOLYGON (((-73.30945 -46.70913, -73.30945...


Total running time of the script: (0 minutes 0.442 seconds)

Gallery generated by Sphinx-Gallery