-
Notifications
You must be signed in to change notification settings - Fork 7
/
python.html
371 lines (310 loc) · 18.5 KB
/
python.html
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python — pdal.io</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/pdal.css" type="text/css" />
<link rel="stylesheet" href="_static/breathe.css" type="text/css" />
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="canonical" href="https://pdal.io/python.html"/>
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="author" title="About these documents" href="about.html" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="copyright" title="Copyright" href="copyright.html" />
<link rel="next" title="Java" href="java.html" />
<link rel="prev" title="Types" href="types.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> PDAL
</a>
<div class="version">
2.4.3
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="about.html">About</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="download.html">Download</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="apps/index.html">Applications</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="community.html">Community</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="pipeline.html">Pipeline</a></li>
<li class="toctree-l1"><a class="reference internal" href="stages/stages.html">Stages</a></li>
<li class="toctree-l1"><a class="reference internal" href="stages/readers.html">Readers</a></li>
<li class="toctree-l1"><a class="reference internal" href="stages/writers.html">Writers</a></li>
<li class="toctree-l1"><a class="reference internal" href="stages/filters.html">Filters</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="dimensions.html">Dimensions</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="types.html">Types</a></li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Python</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#versions">Versions</a></li>
<li class="toctree-l2"><a class="reference internal" href="#embed">Embed</a></li>
<li class="toctree-l2"><a class="reference internal" href="#extend">Extend</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#installation">Installation</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#installation-using-pip">Installation Using pip</a></li>
<li class="toctree-l4"><a class="reference internal" href="#installation-from-source">Installation from Source</a></li>
<li class="toctree-l4"><a class="reference internal" href="#install-using-conda">Install using Conda</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="java.html">Java</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="tutorial/index.html">Tutorials</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="workshop/index.html">Workshop</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="development/index.html">Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="project/index.html">Project</a></li>
<li class="toctree-l1"><a class="reference internal" href="api/index.html">API</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="copyright.html">License</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="references.html">References</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">PDAL</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html"> Documentation </a> »</li>
<li>Python</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/PDAL/PDAL/edit//master/doc/python.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<div class="rst-breadcrumbs-buttons" role="navigation" aria-label="breadcrumb navigation">
<a href="java.html" class="btn btn-neutral float-right" title="Java" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="types.html" class="btn btn-neutral float-left" title="Types" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="python">
<span id="id1"></span><h1>Python<a class="headerlink" href="#python" title="Permalink to this heading"></a></h1>
<p id="index-0">PDAL provides Python support in two significant ways. First it <a class="reference external" href="https://docs.python.org/3/extending/embedding.html">embeds</a> Python
to allow you to write Python programs that interact with data using
<a class="reference internal" href="stages/filters.python.html#filters-python"><span class="std std-ref">filters.python</span></a> filter. Second, it <a class="reference external" href="https://docs.python.org/3/extending/extending.html">extends</a> Python by providing an
extension that Python programmers can use to leverage PDAL capabilities in
their own applications.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>PDAL’s Python story always revolves around <a class="reference external" href="http://www.numpy.org/">Numpy</a> support. PDAL’s
data is provided to both the filters ands the extension as
Numpy arrays.</p>
</div>
<section id="versions">
<h2>Versions<a class="headerlink" href="#versions" title="Permalink to this heading"></a></h2>
<p>PDAL supports both Python 3.5+. <a class="reference internal" href="project/integration.html#integration"><span class="std std-ref">Continuous Integration</span></a> tests Python
Linux, OSX, and Windows.</p>
</section>
<section id="embed">
<h2>Embed<a class="headerlink" href="#embed" title="Permalink to this heading"></a></h2>
<p id="index-1">PDAL allows users to embed Python functions inline with other <a class="reference internal" href="pipeline.html#pipeline"><span class="std std-ref">Pipeline</span></a>
processing operations. The purpose of this capability is to allow users to
write small programs that implement interesting actions without requiring a
full C++ development activity of building a PDAL stage to implement it. A
Python filter is an opportunity to interactively and iteratively prototype a
data operation without strong considerations of performance or generality. If
something works well enough, maybe one takes on the effort to formalize it, but
that isn’t necessary. PDAL’s embed of Python allows you to be as grimy as you
need to get the job done.</p>
<figure class="align-default" id="id2">
<img alt="_images/python-pdal-pipeline.png" src="_images/python-pdal-pipeline.png" />
<figcaption>
<p><span class="caption-text">Embedding a Python function to take Z values read from a
<a class="reference internal" href="stages/readers.las.html#readers-las"><span class="std std-ref">readers.las</span></a> and then output them to a <a class="reference internal" href="stages/writers.bpf.html#writers-bpf"><span class="std std-ref">writers.bpf</span></a>.</span><a class="headerlink" href="#id2" title="Permalink to this image"></a></p>
</figcaption>
</figure>
</section>
<section id="extend">
<h2>Extend<a class="headerlink" href="#extend" title="Permalink to this heading"></a></h2>
<p id="index-2">PDAL provides a Python <a class="reference external" href="https://pypi.python.org/pypi/PDAL">extension</a>
that gives users access to executing
<a class="reference internal" href="pipeline.html#pipeline"><span class="std std-ref">pipeline</span></a> instantiations and capturing the results
as <a class="reference external" href="http://www.numpy.org/">Numpy</a> arrays.
This mode of operation is useful if you are looking to have PDAL simply act as
your data format and processing handler.</p>
<p>Python extension users are expected to construct their own PDAL
<a class="reference internal" href="pipeline.html#pipeline"><span class="std std-ref">pipeline</span></a>
using Python’s <code class="docutils literal notranslate"><span class="pre">json</span></code> library, or whatever other libraries they wish to
manipulate JSON. They then feed it into the extension and get back the
results as <a class="reference external" href="http://www.numpy.org/">Numpy</a> arrays:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">json</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2">[</span>
<span class="s2"> "1.2-with-color.las",</span>
<span class="s2"> {</span>
<span class="s2"> "type": "filters.sort",</span>
<span class="s2"> "dimension": "X"</span>
<span class="s2"> }</span>
<span class="s2">]</span>
<span class="s2">"""</span>
<span class="kn">import</span> <span class="nn">pdal</span>
<span class="n">pipeline</span> <span class="o">=</span> <span class="n">pdal</span><span class="o">.</span><span class="n">Pipeline</span><span class="p">(</span><span class="n">json</span><span class="p">)</span>
<span class="n">count</span> <span class="o">=</span> <span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
<span class="n">arrays</span> <span class="o">=</span> <span class="n">pipeline</span><span class="o">.</span><span class="n">arrays</span>
<span class="n">metadata</span> <span class="o">=</span> <span class="n">pipeline</span><span class="o">.</span><span class="n">metadata</span>
<span class="n">log</span> <span class="o">=</span> <span class="n">pipeline</span><span class="o">.</span><span class="n">log</span>
</pre></div>
</div>
<section id="installation">
<h3>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h3>
<p id="index-3">The PDAL Python extension requires a working
<a class="reference internal" href="download.html#download"><span class="std std-ref">PDAL installation</span></a>. Unless you choose the Conda installation
method, make sure that you a current, working version of PDAL before
installing the extension.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Previous to PDAL 2.1, Python support was spread across the embedded
stages (<a class="reference internal" href="stages/readers.numpy.html#readers-numpy"><span class="std std-ref">readers.numpy</span></a> and <a class="reference internal" href="stages/filters.python.html#filters-python"><span class="std std-ref">filters.python</span></a>) which were installed
by PDAL itself and the PDAL extension that was installed from PyPI.
As of PDAL 2.1 and PDAL/python 2.3, both the embedded stages and the
extension are installed from PyPI.</p>
</div>
<section id="installation-using-pip">
<h4>Installation Using pip<a class="headerlink" href="#installation-using-pip" title="Permalink to this heading"></a></h4>
<p id="index-4">As administrator, you can install PDAL using pip:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">PDAL</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>To install pip please read
<a class="reference external" href="https://pip.pypa.io/en/stable/installing/">here</a></p>
</div>
</section>
<section id="installation-from-source">
<h4>Installation from Source<a class="headerlink" href="#installation-from-source" title="Permalink to this heading"></a></h4>
<p id="index-5">PDAL Python support is hosted in a separate repository than PDAL itself at
<a class="reference external" href="https://github.com/PDAL/python">GitHub</a>. If you have a working PDAL
installation and a working Python installation, you can install the extension
using the following procedure on Unix. The procedure on Windows is similar</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ git clone https://github.com/PDAL/python pdalextension
$ cd pdalextension
$ pip install .
</pre></div>
</div>
</section>
<section id="install-using-conda">
<h4>Install using Conda<a class="headerlink" href="#install-using-conda" title="Permalink to this heading"></a></h4>
<p id="index-6">The PDAL Python support can also be installed using the <a class="reference external" href="https://conda.io/docs/">Conda</a>
package manager. An advantage of using Conda to install the extension is
that Conda will install PDAL. We recommend installing PDAL and the PDAL
Python extension in an environment other than the base environment. To
install in an existing environment, use the following</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">install</span> <span class="o">-</span><span class="n">n</span> <span class="o"><</span><span class="n">environment</span> <span class="n">name</span><span class="o">></span> <span class="o">-</span><span class="n">c</span> <span class="n">conda</span><span class="o">-</span><span class="n">forge</span> <span class="n">python</span><span class="o">-</span><span class="n">pdal</span>
</pre></div>
</div>
<p>Use the following command to install PDAL and the PDAL Python extension
into a new environment and activate that environment</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">create</span> <span class="o">-</span><span class="n">n</span> <span class="o"><</span><span class="n">environment</span> <span class="n">name</span><span class="o">></span> <span class="o">-</span><span class="n">c</span> <span class="n">conda</span><span class="o">-</span><span class="n">forge</span> <span class="n">python</span><span class="o">-</span><span class="n">pdal</span>
<span class="n">conda</span> <span class="n">activate</span> <span class="o"><</span><span class="n">environment</span> <span class="n">name</span><span class="o">></span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The official <code class="docutils literal notranslate"><span class="pre">pdal</span></code> and <code class="docutils literal notranslate"><span class="pre">python-pdal</span></code> packages reside in the
conda-forge channel, which can be added via <code class="docutils literal notranslate"><span class="pre">conda</span> <span class="pre">config</span></code> or manually
specified with the <code class="docutils literal notranslate"><span class="pre">-c</span></code> option, as shown in the examples above.</p>
</div>
</section>
</section>
</section>
</section>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="java.html" class="btn btn-neutral float-right" title="Java" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="types.html" class="btn btn-neutral float-left" title="Types" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<div class="info">
<a class="logo-link" href="https://hobu.co">
<div class="hobu-logo"></div>
</a>
<div class="copyright">
© 2022
<a href="https://github.com/abellgithub">Andrew Bell</a>,
<a href="https://github.com/chambbj">Brad Chambers</a>,
<a href="http://github.com/hobu">Howard Butler</a>,
and
<a href="https://github.com/PDAL/PDAL/graphs/contributors">others</a>.
Last updated on Aug 17, 2022.
</div>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
<div class="footer">
<div class="container">
© 2022
<a href="http://github.com/hobu">Howard Butler</a>,
<a href="http://github.com/mpgerlek">Michael Gerlek</a>,
and
<a href="https://github.com/PDAL/PDAL/graphs/contributors">others</a>,
Last updated
on Aug 17, 2022.
</div>
</div>
</body>
</html>