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

.. only:: html

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

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

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

.. _sphx_glr_handling_examples_raster_point_topoints.py:


Raster to regular points
========================

This example demonstrates the conversion of a raster regular-grid values to a point cloud using :func:`geoutils.Raster.to_points`.

.. GENERATED FROM PYTHON SOURCE LINES 9-10

We open a raster.

.. GENERATED FROM PYTHON SOURCE LINES 10-17

.. code-block:: Python


    import geoutils as gu

    filename_rast = gu.examples.get_path("exploradores_aster_dem")
    rast = gu.Raster(filename_rast)
    rast = rast.crop([rast.bounds.left, rast.bounds.bottom, rast.bounds.left + 500, rast.bounds.bottom + 500])








.. GENERATED FROM PYTHON SOURCE LINES 19-20

Let's plot the raster.

.. GENERATED FROM PYTHON SOURCE LINES 20-22

.. code-block:: Python

    rast.plot(cmap="terrain")




.. image-sg:: /handling_examples/raster_point/images/sphx_glr_topoints_001.png
   :alt: topoints
   :srcset: /handling_examples/raster_point/images/sphx_glr_topoints_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 23-24

We convert the raster to points. By default, this returns a vector with column geometry burned.

.. GENERATED FROM PYTHON SOURCE LINES 24-28

.. code-block:: Python


    pc = rast.to_pointcloud()
    pc






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <pre><span style="white-space: pre-wrap"><b><em>PointCloud</em></b>(
      <b>ds=</b>              b1                geometry
           0    2787.605957  POINT (627175 4834055)
           1    2791.827393  POINT (627205 4834055)
           2    2796.588623  POINT (627235 4834055)
           3    2802.831299  POINT (627265 4834055)
           4    2809.177734  POINT (627295 4834055)
           ..           ...                     ...
           284  2765.868408  POINT (627535 4833575)
           285  2768.098389  POINT (627565 4833575)
           286  2770.859375  POINT (627595 4833575)
           287  2773.972168  POINT (627625 4833575)
           288  2777.362305  POINT (627655 4833575)
       
           [289 rows x 2 columns]
      <b>crs=</b>PROJCS["WGS 84 / UTM zone 18S",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-75],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32718"]]
      <b>bounds=</b>BoundingBox(left=np.float64(627175.0), bottom=np.float64(4833575.0), right=np.float64(627655.0), top=np.float64(4834055.0)))</span></pre>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 29-30

We plot the point vector.

.. GENERATED FROM PYTHON SOURCE LINES 30-32

.. code-block:: Python


    pc.plot(ax="new", cmap="terrain", legend=True)



.. image-sg:: /handling_examples/raster_point/images/sphx_glr_topoints_002.png
   :alt: topoints
   :srcset: /handling_examples/raster_point/images/sphx_glr_topoints_002.png
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_handling_examples_raster_point_topoints.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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