Skip to main content

Compute the geometric features associated with each point's neighborhood:

Project description

Point Geometric Features

python C++ license

📌 Description

The pgeof library provides utilities for fast, parallelized computing ⚡ of local geometric features for 3D point clouds ☁️ on CPU .

️List of available features ️👇
  • linearity
  • planarity
  • scattering
  • verticality (two formulations)
  • normal_x
  • normal_y
  • normal_z
  • length
  • surface
  • volume
  • curvature
  • optimal neighborhood size

pgeof allows computing features in multiple fashions: on-the-fly subset of features a la jakteristics, array of features, or multiscale features. Moreover, pgeof also offers functions for fast K-NN or radius-NN searches 🔍.

Behind the scenes, the library is a Python wrapper around C++ utilities. The overall code is not intended to be DRY nor generic, it aims at providing efficient as possible implementations for some limited scopes and usages.

🧱 Installation

From binaries

python -m pip install pgeof 

or

python -m pip install git+https://github.com/drprojects/point_geometric_features

Building from sources

pgeof depends on Eigen library, Taskflow, nanoflann and nanobind. The library adheres to PEP 517 and uses scikit-build-core as build backend. Build dependencies (nanobind, scikit-build-core, ...) are fetched at build time. C++ third party libraries are embedded as submodules.

# Clone project
git clone --recurse-submodules https://github.com/drprojects/point_geometric_features.git
cd point_geometric_features

# Build and install the package
python -m pip install .

🚀 Using Point Geometric Features

Here we summarize the very basics of pgeof usage. Users are invited to use help(pgeof) for further details on parameters.

At its core pgeof provides three functions to compute a set of features given a 3D point cloud and some precomputed neighborhoods.

import pgeof

# Compute a set of 11 predefined features per points
pgeof.compute_features(
    xyz, # The point cloud. A numpy array of shape (n, 3)
    nn, # CSR data structure see below
    nn_ptr, # CSR data structure see below
    k_min = 1 # Minimum number of neighbors to consider for features computation
    verbose = false # Basic verbose output, for debug purposes
)
# Sequence of n scales feature computation
pgeof.compute_features_multiscale(
    ...
    k_scale # array of neighborhood size
)
# Feature computation with optimal neighborhood selection as exposed in Weinmann et al., 2015
# return a set of 12 features per points (11 + the optimal neighborhood size)
pgeof.compute_features_optimal(
    ...
    k_min = 1, # Minimum number of neighbors to consider for features computation
    k_step = 1, # Step size to take when searching for the optimal neighborhood
    k_min_search = 1, # Starting size for searching the optimal neighborhood size. Should be >= k_min 
)

⚠️ Please note that for theses three functions the neighbors are expected in CSR format. This allows expressing neighborhoods of varying sizes with dense arrays (e.g. the output of a radius search).

We provide very tiny and specialized k-NN and radius-NN search routines. They rely on nanoflann C++ library and should be faster and lighter than scipy and sklearn alternatives.

Here are some examples of how to easily compute and convert typical k-NN or radius-NN neighborhoods to CSR format (nn and nn_ptr are two flat uint32 arrays):

import pgeof
import numpy as np

# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
k = 20
xyz = np.random.rand(num_points, 3).astype("float32")
knn, _ = pgeof.knn_search(xyz, xyz, k)

# Converting k-nearest neighbors to CSR format
nn_ptr = np.arange(num_points + 1) * k
nn = knn.flatten()

# You may need to convert nn/nn_ptr to uint32 arrays
nn_ptr = nn_ptr.astype("uint32")
nn = nn.astype("uint32")

features = pgeof.compute_features(xyz, nn, nn_ptr)
import pgeof
import numpy as np

# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
radius = 0.2
k = 20
xyz = np.random.rand(num_points, 3).astype("float32")
knn, _ = pgeof.radius_search(xyz, xyz, radius, k)

# Converting radius neighbors to CSR format
nn_ptr = np.r_[0, (knn >= 0).sum(axis=1).cumsum()]
nn = knn[knn >= 0]

# You may need to convert nn/nn_ptr to uint32 arrays
nn_ptr = nn_ptr.astype("uint32")
nn = nn.astype("uint32")

features = pgeof.compute_features(xyz, nn, nn_ptr)

At last, and as a by-product, we also provide a function to compute a subset of features on the fly. It is inspired by the jakteristics python package (while being less complete but faster). The list of features to compute is given as an array of EFeatureID.

import pgeof
from pgeof import EFeatureID
import numpy as np

# Generate a random synthetic point cloud and k-nearest neighbors
num_points = 10000
radius = 0.2
k = 20
xyz = np.random.rand(num_points, 3)

# Compute verticality and curvature
features = pgeof.compute_features_selected(xyz, radius, k, [EFeatureID.Verticality, EFeatureID.Curvature])

Known limitations

Some functions only accept float scalar types and uint32 index types, and we avoid implicit cast / conversions. This could be a limitation in some situations (e.g. point clouds with double coordinates or involving very large big integer indices). Some C++ functions could be templated / to accept other types without conversion. For now, this feature is not enabled everywhere, to reduce compilation time and enhance code readability. Please let us know if you need this feature !

By convention, our normal vectors are forced to be oriented towards positive Z values. We make this design choice in order to return consistently-oriented normals.

Testing

Some basic tests and benchmarks are provided in the tests directory. Tests can be run in a clean and reproducible environments via tox (tox run and tox run -e bench).

💳 Credits

This implementation was largely inspired from Superpoint Graph. The main modifications here allow:

  • parallel computation on all points' local neighborhoods, with neighborhoods of varying sizes
  • more geometric features
  • optimal neighborhood search from this paper
  • some corrections on geometric features computation

Some heavy refactoring (port to nanobind, test, benchmarks), packaging, speed optimization, feature addition (NN search, on the fly feature computation...) were funded by:

Centre of Wildfire Research of Swansea University (UK) in collaboration with the Research Institute of Biodiversity (CSIC, Spain) and the Department of Mining Exploitation of the University of Oviedo (Spain).

Funding provided by the UK NERC project (NE/T001194/1):

'Advancing 3D Fuel Mapping for Wildfire Behaviour and Risk Mitigation Modelling'

and by the Spanish Knowledge Generation project (PID2021-126790NB-I00):

‘Advancing carbon emission estimations from wildfires applying artificial intelligence to 3D terrestrial point clouds’.

License

Point Geometric Features is licensed under the MIT License.

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

pgeof-0.2.0.tar.gz (69.0 MB view details)

Uploaded Source

Built Distributions

pgeof-0.2.0-cp312-cp312-win_amd64.whl (166.3 kB view details)

Uploaded CPython 3.12 Windows x86-64

pgeof-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl (523.9 kB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

pgeof-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (216.4 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pgeof-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (141.1 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pgeof-0.2.0-cp311-cp311-win_amd64.whl (167.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

pgeof-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl (525.3 kB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pgeof-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (218.2 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pgeof-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (141.9 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pgeof-0.2.0-cp310-cp310-win_amd64.whl (167.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

pgeof-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl (525.3 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pgeof-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (218.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pgeof-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (142.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pgeof-0.2.0-cp39-cp39-win_amd64.whl (167.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

pgeof-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl (525.5 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pgeof-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (218.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pgeof-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (142.2 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

File details

Details for the file pgeof-0.2.0.tar.gz.

File metadata

  • Download URL: pgeof-0.2.0.tar.gz
  • Upload date:
  • Size: 69.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for pgeof-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9b564e9f8179cf6ad469d39b8797f717720b97c3a3fd9d6beba127424bd7573a
MD5 3d25c7053b533903e89ecce4d743db74
BLAKE2b-256 bbdfab0013b54b38c2c7cd0d502cf93331b0e0174fddd0ed38d32c942f22924a

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pgeof-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 166.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for pgeof-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8a0e07ff8d45f5d73cd7f3c2bd39832feba6b856ca420326aab32257cf805af0
MD5 b0ebf9f1af2a86841d4a8285654a56a5
BLAKE2b-256 518b3124cd0d6818ddbd9379ddedf251b107e31c1ebda8a1646562bc434e35ac

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 371c062eea4887d07617efe0771aadc942de947873a865f1b170bd7dc31b2bfb
MD5 0100decd7921ecd6f1aa9d536c943b8e
BLAKE2b-256 6b549fd573f44c1371e8107c63766e72b7f6efaa790eb58120bcaf0e3cd8ccbc

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63adcbefcd3b2ffd167e8d0c8da018a46edbe992885fd484fe7bb3dac49a9e34
MD5 6cc6cbc92316d03463acbd36c46fd8a4
BLAKE2b-256 7008ced943801d151fcf1feb6f0170d47748d0817a23ded2822228750bdfbfe4

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20afc0c8e48f936a4617817606e4103c09d112f5cf3eed6d672ba06126755b8e
MD5 cc4facc14242592fa76ecc9a8b90542c
BLAKE2b-256 f0dda04a79d06519224b8699544b924ebf05cba71bf1fb3faf53d0814a70ce95

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pgeof-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 167.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for pgeof-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c6227c5f8df6b851af83f708f3af9022a67113cdc4840d91a66c7e3bbf312e50
MD5 edbd685549d410ae5efa9a6e73ec3b7e
BLAKE2b-256 167a2d6143e082e062e41b0d9eed0c6a8567c7460c9089adc14e46f06bd3af27

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 3a5e1dbd56070fa50fea75fa9551430829592d353f2004a007995b4a5aa26119
MD5 e3ff29000979aab388a9ff28b1a38a9c
BLAKE2b-256 7add214dc03d57fa94f8da34d1a548ee4396fba202f28e8f07114028478c976b

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 59c8a7661d4ffb8f04b1ae7b315e63cfc97579561b9041a6486556336d441f31
MD5 64adb5dbbff2409ead9f25149f2fc547
BLAKE2b-256 42e1c89c454bf297975d0d1328574d92ba93c3377607dc0d2e35b7fc4c74b6e7

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 618e62676687ee903e30529de8630e278e68fda68cfb0f37802d0e29b2401e1b
MD5 da2bd44d45f0d1799b4c109b0a252ae7
BLAKE2b-256 9cbed69539e563d2886df30b92e805471e4a8b278743441f2f4b5c79ae17cbb2

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pgeof-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 167.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for pgeof-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 af6348f63e29e0f07444a2d7cf1f639c8fc7af0dcfda704333b9ab3c399122a2
MD5 55afaaceaa6758139ee6080eb439bd8c
BLAKE2b-256 d5491d91dbe765b729a8cd2424902f28c5a674d61a50ca03883d7a8ea87a8247

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 eb965b093b4fc3f5eeb0c8eda6321bc53c47766b26c66abd2211759a21e6f49b
MD5 56721b9c8f311280e81f3f416ef0dc92
BLAKE2b-256 1a32f2bce6fdeb0f4ea269d9fe8f334e4f25cbe735091eff8afef068df9af25b

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb59b9df1a320df9fe8e35ad009ee4693dc1526f3d16141686b4f6f921bd4116
MD5 2b5a19b0d02f71ed84ea216bd880dc22
BLAKE2b-256 631a9807b07939363d35b2527ca140f014d16f1315b42345267b3e062b86009e

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cfcafabd579d32784910265cf90ba1fba315b18ad205087c5bb47d2ceecb3aeb
MD5 b4cc9b1942da9e64322b4eeebb588cba
BLAKE2b-256 125fff11362d40bed8dce871b6115a9724894b65ed1f4507f524bf0aa3f3843c

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pgeof-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 167.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for pgeof-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2d3f5767f4716a7caf3f99c824f4f31ce0da24f7c3af9d7d54c177d13768a356
MD5 6f668cb66a2948e2b19ee103a21d55ce
BLAKE2b-256 18d46769e1c7393e920438b007c7bd37698d4ff9ea99305ee6d82ad6e5e0b021

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 ec09254792dcfe48fa365406b3a045d9e674cf5a8cc76377c1d674f44d042ef4
MD5 eff93d98676448f46c765ec9fa63c1e2
BLAKE2b-256 b81372c562a3652526ea342363fc3b55235a7f46dc97df34625960368a41e48e

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ae130a5e192f4b387a1b55e99dc0fac957473f1540527be502cffa4e50418205
MD5 565370e82dd72adc6659a39d4a057e33
BLAKE2b-256 bf25a2130f691f109c60cc2c7b67823e0fe60f7df7cd316689e03c4567ba66bb

See more details on using hashes here.

Provenance

File details

Details for the file pgeof-0.2.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pgeof-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72a4eed3a5c87adbbc81ef4792e68c0c3c6f6dae7fd0804c0b66535d1ad7fc42
MD5 697033405d61d4c9267ec8d3593b19c7
BLAKE2b-256 6d1825412c0501a5bdc48a8ff08854c44db370bee1def4df80d443c9c689bd0b

See more details on using hashes here.

Provenance

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