This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
forked from PDAL/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKG-INFO
215 lines (158 loc) · 7.09 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
Metadata-Version: 1.1
Name: PDAL
Version: 2.3.0
Summary: Point cloud data processing
Home-page: https://pdal.io
Author: Howard Butler
Author-email: [email protected]
License: BSD
Description: ================================================================================
PDAL
================================================================================
PDAL Python support allows you to process data with PDAL into `Numpy`_
arrays. It supports embedding Python in PDAL pipelines with the `readers.numpy <https://pdal.io/stages/readers.numpy.html>`__
and `filters.python <https://pdal.io/stages/filters.python.html>`__ stages, and it provides a PDAL extension module to control
Python interaction with PDAL.
Additionally, you can use it to fetch `schema`_ and `metadata`_ from
PDAL operations.
Installation
--------------------------------------------------------------------------------
PyPI
................................................................................
PDAL Python support is installable via PyPI:
.. code-block::
pip install PDAL
GitHub
................................................................................
The repository for PDAL's Python extension is available at https://github.com/PDAL/python
Python support released independently from PDAL itself as of PDAL 1.7.
Usage
--------------------------------------------------------------------------------
Simple
................................................................................
Given the following pipeline, which simply reads an `ASPRS LAS`_ file and
sorts it by the ``X`` dimension:
.. _`ASPRS LAS`: https://www.asprs.org/committee-general/laser-las-file-format-exchange-activities.html
.. code-block:: python
json = """
{
"pipeline": [
"1.2-with-color.las",
{
"type": "filters.sort",
"dimension": "X"
}
]
}"""
import pdal
pipeline = pdal.Pipeline(json)
count = pipeline.execute()
arrays = pipeline.arrays
metadata = pipeline.metadata
log = pipeline.log
Reading using Numpy Arrays
................................................................................
The following more complex scenario demonstrates the full cycling between
PDAL and Python:
* Read a small testfile from GitHub into a Numpy array
* Filters those arrays with Numpy for Intensity
* Pass the filtered array to PDAL to be filtered again
* Write the filtered array to an LAS file.
.. code-block:: python
data = "https://github.com/PDAL/PDAL/blob/master/test/data/las/1.2-with-color.las?raw=true"
json = """
{
"pipeline": [
{
"type": "readers.las",
"filename": "%s"
}
]
}"""
import pdal
import numpy as np
pipeline = pdal.Pipeline(json % data)
count = pipeline.execute()
# get the data from the first array
# [array([(637012.24, 849028.31, 431.66, 143, 1, 1, 1, 0, 1, -9., 132, 7326, 245380.78254963, 68, 77, 88),
# dtype=[('X', '<f8'), ('Y', '<f8'), ('Z', '<f8'), ('Intensity', '<u2'), ('ReturnNumber', 'u1'), ('NumberOfReturns', 'u1'), ('ScanDirectionFlag', 'u1'), ('EdgeOfFlightLine', 'u1'), ('Classification', 'u1'), ('ScanAngleRank', '<f4'), ('UserData', 'u1'), ('PointSourceId', '<u2'), ('GpsTime', '<f8'), ('Red', '<u2'), ('Green', '<u2'), ('Blue', '<u2')])
arr = pipeline.arrays[0]
print (len(arr)) # 1065 points
# Filter out entries that have intensity < 50
intensity = arr[arr['Intensity'] > 30]
print (len(intensity)) # 704 points
# Now use pdal to clamp points that have intensity
# 100 <= v < 300, and there are 387
clamp =u"""{
"pipeline":[
{
"type":"filters.range",
"limits":"Intensity[100:300)"
}
]
}"""
p = pdal.Pipeline(clamp, [intensity])
count = p.execute()
clamped = p.arrays[0]
print (count)
# Write our intensity data to an LAS file
output =u"""{
"pipeline":[
{
"type":"writers.las",
"filename":"clamped.las",
"offset_x":"auto",
"offset_y":"auto",
"offset_z":"auto",
"scale_x":0.01,
"scale_y":0.01,
"scale_z":0.01
}
]
}"""
p = pdal.Pipeline(output, [clamped])
count = p.execute()
print (count)
Accessing Mesh Data
................................................................................
Some PDAL stages (for instance ``filters.delaunay``) create TIN type mesh data.
This data can be accessed in Python using the ``Pipeline.meshes`` property, which returns ``numpy.ndarray``
of shape (1,n) where n is the number of Triangles in the mesh. If the PointView contains no mesh data, then n = 0.
Each Triangle is a tuple ``(A,B,C)`` where A, B and C are indicees into the PointView for the point that is the vertex for the Triangle.
Meshio Integration
................................................................................
The meshes property provides the face data but is not easy to use as a mesh. Therefore, we have provided optional Integration
into the `Meshio <https://github.com/nschloe/meshio>`__ library.
The ``pdal.Pipeline`` class provides the ``get_meshio(idx: int) -> meshio.Mesh`` method. This
method creates a `Mesh` object from the `PointView` array and mesh properties.
.. note:: The meshio integration requires that meshio is installed (e.g. ``pip install meshio``). If it
is not, then the method fails with an informative RuntimeError.
Simple use of the functionality could be as follows:
-- code-block:: python
import pdal
...
pl = pdal.Pipeline(pipeline)
pl.execute()
mesh = pl.get_meshio(0)
mesh.write('test.obj')
.. _`Numpy`: http://www.numpy.org/
.. _`schema`: http://www.pdal.io/dimensions.html
.. _`metadata`: http://www.pdal.io/development/metadata.html
.. image:: https://ci.appveyor.com/api/projects/status/of4kecyahpo8892d
:target: https://ci.appveyor.com/project/hobu/python/
Requirements
================================================================================
* PDAL 2.1+
* Python >=3.6
* Cython (eg :code:`pip install cython`)
* Packaging (eg :code:`pip install packaging`)
Keywords: point cloud spatial
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: GIS
Requires: Python (>=3.6)