
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "analysis_examples/distance_ops/buffer_voronoi.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_analysis_examples_distance_ops_buffer_voronoi.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_analysis_examples_distance_ops_buffer_voronoi.py:


Metric buffer and without overlap
=================================

This example demonstrates the metric buffering of a vector using :func:`~geoutils.Vector.buffer_metric` and  :func:`~geoutils.Vector.buffer_without_overlap`.

.. GENERATED FROM PYTHON SOURCE LINES 9-10

We open an example vector

.. GENERATED FROM PYTHON SOURCE LINES 10-16

.. code-block:: Python


    import geoutils as gu

    filename_vect = gu.examples.get_path("everest_rgi_outlines")
    vect = gu.Vector(filename_vect)








.. GENERATED FROM PYTHON SOURCE LINES 18-20

We buffer in metric units directly using :func:`~geoutils.Vector.buffer_metric`. Under the hood, this functionality reprojects to a local projection,
buffers, and converts back to the original CRS.

.. GENERATED FROM PYTHON SOURCE LINES 20-22

.. code-block:: Python

    vect_buff = vect.buffer_metric(buffer_size=500)








.. GENERATED FROM PYTHON SOURCE LINES 23-24

Let's plot the raster and vector

.. GENERATED FROM PYTHON SOURCE LINES 24-27

.. code-block:: Python

    ax = vect.plot()
    vect_buff.plot(ec="k", fc="none")




.. image-sg:: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_001.png
   :alt: buffer voronoi
   :srcset: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 28-30

Many buffers are overlapping. To compute a buffer without overlap, one can use :func:`~geoutils.Vector.buffer_without_overlap`.


.. GENERATED FROM PYTHON SOURCE LINES 30-34

.. code-block:: Python

    vect_buff_nolap = vect.buffer_without_overlap(buffer_size=500)
    vect.plot(ax="new")
    vect_buff_nolap.plot(ec="k", fc="none")




.. image-sg:: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_002.png
   :alt: buffer voronoi
   :srcset: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_002.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 35-36

We plot with color to see that the attributes are retained for every feature.

.. GENERATED FROM PYTHON SOURCE LINES 36-38

.. code-block:: Python

    vect_buff_nolap.plot(ax="new", column="Area")
    vect.plot(ec="k", column="Area", alpha=0.5)



.. image-sg:: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_003.png
   :alt: buffer voronoi
   :srcset: /analysis_examples/distance_ops/images/sphx_glr_buffer_voronoi_003.png
   :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_analysis_examples_distance_ops_buffer_voronoi.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: buffer_voronoi.ipynb <buffer_voronoi.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: buffer_voronoi.py <buffer_voronoi.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: buffer_voronoi.zip <buffer_voronoi.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
