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

.. only:: html

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

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

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

.. _sphx_glr_io_examples_open_save_read_pointcloud.py:


Open/save a point cloud
=======================

This example demonstrates the instantiation of a point cloud through :class:`geoutils.PointCloud` and saving with :func:`~geoutils.Vector.save`.

.. GENERATED FROM PYTHON SOURCE LINES 7-10

.. code-block:: Python


    import geoutils as gu








.. GENERATED FROM PYTHON SOURCE LINES 11-12

We open an example vector.

.. GENERATED FROM PYTHON SOURCE LINES 12-16

.. code-block:: Python

    filename_pc = gu.examples.get_path("coromandel_lidar")
    pc = gu.PointCloud(filename_pc, data_column="Z")
    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>              Z                         geometry
           0       816.078  POINT (1838933.295 5887999.962)
           1       818.823  POINT (1838930.054 5887999.966)
           2       811.059  POINT (1838933.316 5887999.967)
           3       818.151  POINT (1838928.638 5887999.961)
           4       817.599  POINT (1838926.098 5887999.995)
           ...         ...                              ...
           584343  827.438  POINT (1838913.663 5888000.872)
           584344  825.099  POINT (1838912.806 5888000.715)
           584345  825.419  POINT (1838912.889 5888001.284)
           584346  825.204   POINT (1838912.775 5888000.72)
           584347  822.421  POINT (1838911.847 5888000.565)
       
           [584348 rows x 2 columns]
      <b>crs=</b>COMPD_CS["NZGD2000 / New Zealand Transverse Mercator 2000 + NZVD2016 height",PROJCS["NZGD2000 / New Zealand Transverse Mercator 2000",GEOGCS["NZGD2000",DATUM["New_Zealand_Geodetic_Datum_2000",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6167"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4167"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",173],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",1600000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Northing",NORTH],AXIS["Easting",EAST],AUTHORITY["EPSG","2193"]],VERT_CS["NZVD2016 height",VERT_DATUM["New Zealand Vertical Datum 2016",2005,AUTHORITY["EPSG","1169"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","7839"]]]
      <b>bounds=</b>BoundingBox(left=np.float64(1838792.524), bottom=np.float64(5887910.586), right=np.float64(1838937.061), top=np.float64(5888036.092)))</span></pre>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 17-20

A point cloud is a subclass of :class:`~geoutils.Vector`, with a main attribute :attr:`~geoutils.PointCloud.data_column` pointing to the main data column
of the point cloud.
All other attributes are :ref:`inherited from Shapely and GeoPandas<vector-from-geopandas>`. See also :ref:`vector-class`.

.. GENERATED FROM PYTHON SOURCE LINES 22-26

.. note::
       A point cloud can also be instantiated with a :class:`geopandas.GeoDataFrame`, see :ref:`sphx_glr_io_examples_import_export_import_vector.py`.

We can print more info on the point cloud.

.. GENERATED FROM PYTHON SOURCE LINES 27-29

.. code-block:: Python

    pc.info()





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Filename:           /home/docs/checkouts/readthedocs.org/user_builds/adebardo-geoutils/checkouts/latest/geoutils/example_data/Coromandel_Lidar/points.laz 
    Coordinate system:  EPSG:None
    Extent:             [1838792.524, 5887910.586, 1838937.061, 5888036.092] 
    Number of features: 584348 
    Attributes:         ['Z', 'geometry']




.. GENERATED FROM PYTHON SOURCE LINES 30-31

Let's plot the point cloud main column

.. GENERATED FROM PYTHON SOURCE LINES 31-33

.. code-block:: Python

    pc.plot(cbar_title="Elevation (m)")




.. image-sg:: /io_examples/open_save/images/sphx_glr_read_pointcloud_001.png
   :alt: read pointcloud
   :srcset: /io_examples/open_save/images/sphx_glr_read_pointcloud_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 34-35

Finally, a point cloud is saved using :func:`~geoutils.Vector.save`.

.. GENERATED FROM PYTHON SOURCE LINES 35-37

.. code-block:: Python


    pc.to_file("mypc.gpkg")








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

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


.. _sphx_glr_download_io_examples_open_save_read_pointcloud.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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