.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/100_pointset_basics.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_100_pointset_basics.py: PointSetIO Basics ================= This example demonstrates the basic usage of the PointSetIO class. .. GENERATED FROM PYTHON SOURCE LINES 8-19 .. code-block:: Python import tempfile from pathlib import Path import pandas as pd import geopandas as gpd import pyvista as pv from omf_io.pointset import PointSetIO from omf_io.reader import OMFReader .. GENERATED FROM PYTHON SOURCE LINES 20-23 Load a PointSet --------------- Load a point set from a OMF file .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: Python pointset_io: PointSetIO = PointSetIO.from_omf(omf_input=Path('../assets/copper_deposit.omf'), pointset_name='collar') pointset_io.data.head(10) .. raw:: html
holeid holeid_color
x y z
445198.219 494110.594 3057.757537 WP001 (61, 255, 61)
445196.625 494109.656 3054.265408 WP002 (255, 255, 96)
445260.563 493860.719 3009.038328 WP003 (255, 25, 25)
445203.344 493720.656 3033.777664 WP004 (255, 132, 193)
445291.563 493566.219 2957.434730 WP005 (158, 255, 61)
445294.031 493886.813 2970.848677 WP006 (255, 175, 96)
445296.594 493890.250 2974.079767 WP007 (255, 168, 168)
445460.813 493321.156 2979.143623 WP008 (96, 96, 255)
445452.313 493402.188 2980.300987 WP009 (61, 61, 255)
445427.219 493523.688 2978.657715 WP010 (255, 193, 132)


.. GENERATED FROM PYTHON SOURCE LINES 30-33 Demonstrate conversions ----------------------- Exercise the PointSetIO class with various conversions .. GENERATED FROM PYTHON SOURCE LINES 35-37 CSV file ~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 37-46 .. code-block:: Python point_data: pd.DataFrame = pointset_io.data.head(10) out_filepath: Path = Path(tempfile.gettempdir()) / 'pointset_data.csv' csv_filepath: Path = PointSetIO(data=point_data).to_csv(out_filepath) # read and print the csv csv_point_data = pd.read_csv(csv_filepath) csv_point_data .. raw:: html
x y z holeid holeid_color
0 445198.219 494110.594 3057.757537 WP001 (61, 255, 61)
1 445196.625 494109.656 3054.265408 WP002 (255, 255, 96)
2 445260.563 493860.719 3009.038328 WP003 (255, 25, 25)
3 445203.344 493720.656 3033.777664 WP004 (255, 132, 193)
4 445291.563 493566.219 2957.434730 WP005 (158, 255, 61)
5 445294.031 493886.813 2970.848677 WP006 (255, 175, 96)
6 445296.594 493890.250 2974.079767 WP007 (255, 168, 168)
7 445460.813 493321.156 2979.143623 WP008 (96, 96, 255)
8 445452.313 493402.188 2980.300987 WP009 (61, 61, 255)
9 445427.219 493523.688 2978.657715 WP010 (255, 193, 132)


.. GENERATED FROM PYTHON SOURCE LINES 47-49 Pandas DataFrame object ~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 49-53 .. code-block:: Python df: pd.DataFrame = PointSetIO(data=point_data).to_pandas() df .. raw:: html
holeid holeid_color
x y z
445198.219 494110.594 3057.757537 WP001 (61, 255, 61)
445196.625 494109.656 3054.265408 WP002 (255, 255, 96)
445260.563 493860.719 3009.038328 WP003 (255, 25, 25)
445203.344 493720.656 3033.777664 WP004 (255, 132, 193)
445291.563 493566.219 2957.434730 WP005 (158, 255, 61)
445294.031 493886.813 2970.848677 WP006 (255, 175, 96)
445296.594 493890.250 2974.079767 WP007 (255, 168, 168)
445460.813 493321.156 2979.143623 WP008 (96, 96, 255)
445452.313 493402.188 2980.300987 WP009 (61, 61, 255)
445427.219 493523.688 2978.657715 WP010 (255, 193, 132)


.. GENERATED FROM PYTHON SOURCE LINES 54-56 GeoPandas geodataframe object ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 56-60 .. code-block:: Python gdf: gpd.geodataframe = PointSetIO(data=point_data).to_geopandas() gdf .. raw:: html
holeid holeid_color geometry
0 WP001 (61, 255, 61) POINT Z (445198.219 494110.594 3057.758)
1 WP002 (255, 255, 96) POINT Z (445196.625 494109.656 3054.265)
2 WP003 (255, 25, 25) POINT Z (445260.563 493860.719 3009.038)
3 WP004 (255, 132, 193) POINT Z (445203.344 493720.656 3033.778)
4 WP005 (158, 255, 61) POINT Z (445291.563 493566.219 2957.435)
5 WP006 (255, 175, 96) POINT Z (445294.031 493886.813 2970.849)
6 WP007 (255, 168, 168) POINT Z (445296.594 493890.25 2974.08)
7 WP008 (96, 96, 255) POINT Z (445460.813 493321.156 2979.144)
8 WP009 (61, 61, 255) POINT Z (445452.313 493402.188 2980.301)
9 WP010 (255, 193, 132) POINT Z (445427.219 493523.688 2978.658)


.. GENERATED FROM PYTHON SOURCE LINES 61-63 PLY file ~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 63-71 .. code-block:: Python ply_filepath: Path = PointSetIO(data=point_data).to_ply(out_filepath.with_suffix('.ply'), binary=False) # read and print the PLY using file.open with ply_filepath.open('r') as f: ply_data = f.readlines() print(''.join(ply_data)) .. rst-class:: sphx-glr-script-out .. code-block:: none ply format ascii 1.0 element vertex 10 property float x property float y property float z property object holeid property object holeid_color end_header 445198.219 494110.594 3057.757537 WP001 (61, 255, 61) 445196.625 494109.656 3054.265408 WP002 (255, 255, 96) 445260.563 493860.719 3009.038328 WP003 (255, 25, 25) 445203.344 493720.656 3033.777664 WP004 (255, 132, 193) 445291.563 493566.219 2957.43473 WP005 (158, 255, 61) 445294.031 493886.813 2970.848677 WP006 (255, 175, 96) 445296.594 493890.25 2974.079767 WP007 (255, 168, 168) 445460.813 493321.156 2979.143623 WP008 (96, 96, 255) 445452.313 493402.188 2980.300987 WP009 (61, 61, 255) 445427.219 493523.688 2978.657715 WP010 (255, 193, 132) .. GENERATED FROM PYTHON SOURCE LINES 72-74 PyVista Polydata object ~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 74-78 .. code-block:: Python poly: pv.PolyData = PointSetIO(data=point_data).to_pyvista() poly.point_data .. rst-class:: sphx-glr-script-out .. code-block:: none pyvista DataSetAttributes Association : POINT Active Scalars : None Active Vectors : None Active Texture : None Active Normals : None Contains arrays : holeid ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 100_pointset_basics.py <100_pointset_basics.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_