Skip to main content

Point cloud data processing

Project description

PDAL Python support allows you to process data with PDAL into Numpy arrays. It supports embedding Python in PDAL pipelines with the readers.numpy and filters.python 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:

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:

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.

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)
https://ci.appveyor.com/api/projects/status/of4kecyahpo8892d

Requirements

  • PDAL 2.1+

  • Python >=3.6

  • Cython (eg pip install cython)

  • Packaging (eg pip install packaging)

Changes

2.3.0

  • PDAL Python support 2.3.0 requires PDAL 2.1+. Older PDAL base libraries likely will not work.

  • Python support built using scikit-build

  • readers.numpy and filters.python are installed along with the extension.

  • Pipeline can take in a list of arrays that are passed to readers.numpy

  • readers.numpy now supports functions that return arrays. See https://pdal.io/stages/readers.numpy.html for more detail.

2.0.0

  • PDAL Python extension is now in its own repository on its own release schedule at https://github.com/PDAL/python

  • Extension now builds and works under PDAL OSGeo4W64 on Windows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PDAL-2.3.0.tar.gz (216.9 kB view details)

Uploaded Source

Built Distribution

PDAL-2.3.0-cp38-cp38-macosx_10_15_x86_64.whl (267.0 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file PDAL-2.3.0.tar.gz.

File metadata

  • Download URL: PDAL-2.3.0.tar.gz
  • Upload date:
  • Size: 216.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for PDAL-2.3.0.tar.gz
Algorithm Hash digest
SHA256 ccefdb0037ab17f256fc7d7f50f07d2f74b60be1bf8f05dcc7d3beea456a71ac
MD5 a1662e85cfceb287397a2b2842058218
BLAKE2b-256 31de74430c73a84bfcc32097f94186edb08edeee5c9387988ff0b147617d94f4

See more details on using hashes here.

File details

Details for the file PDAL-2.3.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: PDAL-2.3.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 267.0 kB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200325 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.8.2

File hashes

Hashes for PDAL-2.3.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9f09918cb996d84be67ffbb3d8f910644ac16618140b27f35a04ce6ff2ba8f04
MD5 8a0ba39b89312140889768db436b48a5
BLAKE2b-256 49a3354c7bb577f6cb953839ee7c7d82c179fbcf10f67049078d4df2adb3ad78

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page