Note
Go to the end to download the full example code
Open/save a vector#
This example demonstrates the instantiation of a vector through geoutils.Vector
and saving with save()
.
import geoutils as gu
We open an example vector.
filename_vect = gu.examples.get_path("everest_rgi_outlines")
vect = gu.Vector(filename_vect)
vect
A vector is composed of a single main attribute: a ds
geodataframe.
All other attributes are inherited from Shapely and GeoPandas. See also The georeferenced vector (Vector).
Note
A vector can also be instantiated with a geopandas.GeoDataFrame
, see From/to GeoPandas.
We can print more info on the vector.
"Filename: /home/docs/checkouts/readthedocs.org/user_builds/geoutils/checkouts/latest/examples/data/Everest_Landsat/15_rgi60_glacier_outlines.gpkg \nCoordinate System: EPSG:4326\nExtent: [86.70393205700003, 27.847778695000045, 87.11409458600008, 28.14549759700003] \nNumber of features: 86 \nAttributes: ['RGIId', 'GLIMSId', 'BgnDate', 'EndDate', 'CenLon', 'CenLat', 'O1Region', 'O2Region', 'Area', 'Zmin', 'Zmax', 'Zmed', 'Slope', 'Aspect', 'Lmax', 'Status', 'Connect', 'Form', 'TermType', 'Surging', 'Linkages', 'Name', 'geometry']"
Let’s plot by vector area
vect.plot(column="Area", cbar_title="Area (km²)")
Finally, a vector is saved using save()
.
vect.save("myvector.gpkg")
Total running time of the script: (0 minutes 0.243 seconds)