Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
Add an examples section to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Jun 8, 2018
1 parent c3f9f8f commit fb11032
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
==================
Examples
==================


Filtering
---------

This example shows how you can extract points from a file and write them into a new one.
We use the classification field to filter points, but this can work with the other fields.

.. code-block:: python
import pylas
las = pylas.read('pylastests/simple.las')
new_file = pylas.create()
new_file.points = las.points[las.classification == 1]
new_file.write('extracted_points.las')
Creating from scratch
---------------------

This example shows how you can create a new LAS file from scratch.

.. code-block:: python
import pylas
import numpy as np
las = pylas.create()
array = np.linspace(0.0, 15.0, 10000)
las.x = array
las.y = array
las.z = array
las.write('diagonal.las')
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ User Guide
intro
installation
basic
examples

API Documentation
=================
Expand Down
1 change: 1 addition & 0 deletions pylastests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_extraction(file):
# automatic promotion of point format
new.points = file.points[file.classification == 2]
assert new.points_data.point_format_id == 3
assert new.header.point_format_id == 3

assert len(new.points) == sum(file.classification == 2)
assert np.alltrue(new.classification == 2)
Expand Down

0 comments on commit fb11032

Please sign in to comment.