Note
Go to the end to download the full example code
Metric buffer and without overlap#
This example demonstrates the metric buffering of a vector using buffer_metric()
and buffer_without_overlap()
.
We open an example vector
import geoutils as gu
filename_vect = gu.examples.get_path("everest_rgi_outlines")
vect = gu.Vector(filename_vect)
We buffer in metric units directly using buffer_metric()
. Under the hood, this functionality reprojects to a local projection,
buffers, and converts back to the original CRS.
vect_buff = vect.buffer_metric(buffer_size=500)
Let’s plot the raster and vector
ax = vect.plot()
vect_buff.plot(ec="k", fc="none")
Many buffers are overlapping. To compute a buffer without overlap, one can use buffer_without_overlap()
.
vect_buff_nolap = vect.buffer_without_overlap(buffer_size=500)
vect.plot(ax="new")
vect_buff_nolap.plot(ec="k", fc="none")
We plot with color to see that the attributes are retained for every feature.
vect_buff_nolap.plot(ax="new", column="Area")
vect.plot(ec="k", column="Area", alpha=0.5)
Total running time of the script: (0 minutes 11.604 seconds)