Skip to main content

Python library for calculating geodesic distance on triangular based surface meshes

Project description

pygeodesic

Python library to compute geodesic distance over a triangular based surface mesh.

A Cython wrapper of the C++ code by Kirsanov, which is an implementation of the exact geodesic algorithm for triangular mesh first described by Mitchell, Mount and Papadimitriou in 1987.

pygeodesic is similar to other libraries on PyPi (such as gdist and tvb-gdist), but:

  • provides a wrapper of the GeodesicAlgorithmExact class
  • exposes geodesic path (not just geodesic distance)
  • licensed under MIT license similar to the orginal Kirsanov C++ code, rather than GPL

A good alternative to pygeodesic is potpourri3d, which uses the heat method and vector heat method to compute geodesic distance over surfaces and point clouds. However, this library does not currently output the geodesic path on the surface.

Requirements

A C++ compiler is required if you are not installing one of the precompiled wheels. Although pygeodesic is a Cython wrapper, Cython is not required as the cythonized C++ file is also provided.

VTK is used for visualisation in the example notebooks.

Installation

Install from PyPi:

pip install pygeodesic

Installation from source (from within folder containing setup.py):

python setup.py install

Usage

Loading pygeodesic:

import pygeodesic.geodesic as geodesic

To read the mesh files provided with the original C++ code:

filename = r'data/flat_triangular_mesh.txt'
result = geodesic.read_mesh_from_file(filename)
if result:
    points, faces = result

To calculate the geodesic distance and path between two points (the source and the target) on the mesh:

# Initialise the PyGeodesicAlgorithmExact class instance
geoalg = geodesic.PyGeodesicAlgorithmExact(points, faces)

# Define the source and target point ids with respect to the points array
sourceIndex = 25
targetIndex = 97

# Compute the geodesic distance and the path
distance, path = geoalg.geodesicDistance(sourceIndex, targetIndex)

To calculate the geodesic distances from a single point (the source point) to all other points on the mesh:

source_indices = np.array([25])
target_indices = None
distances, best_source = geoalg.geodesicDistances(source_indices, target_indices)

To calculate the geodesic distances from two source points to 3 target points:

source_indices = np.array([25,100]) 
target_indices = np.array([0,10,50])
distances, best_source = geoalg.geodesicDistances(source_indices, target_indices)

For more detail, a Jupyter notebook is provided in the examples folder to show how to use pygeodesic to compute geodesic distances and paths.

Example using the Stanford Bunny

A Jupyter notebook is provided showing how to use pygeodesic to calculate the geodesic distance and path using the Stanford Bunny as an example.

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

pygeodesic-0.1.10.tar.gz (36.3 kB view details)

Uploaded Source

Built Distributions

pygeodesic-0.1.10-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

pygeodesic-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pygeodesic-0.1.10-cp312-cp312-macosx_11_0_arm64.whl (252.3 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

pygeodesic-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl (258.1 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

pygeodesic-0.1.10-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

pygeodesic-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pygeodesic-0.1.10-cp311-cp311-macosx_11_0_arm64.whl (252.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pygeodesic-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl (259.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pygeodesic-0.1.10-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

pygeodesic-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pygeodesic-0.1.10-cp310-cp310-macosx_11_0_arm64.whl (253.1 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pygeodesic-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl (258.8 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pygeodesic-0.1.10-cp39-cp39-win_amd64.whl (1.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

pygeodesic-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (877.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pygeodesic-0.1.10-cp39-cp39-macosx_11_0_arm64.whl (143.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pygeodesic-0.1.10-cp39-cp39-macosx_10_9_x86_64.whl (149.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file pygeodesic-0.1.10.tar.gz.

File metadata

  • Download URL: pygeodesic-0.1.10.tar.gz
  • Upload date:
  • Size: 36.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.9

File hashes

Hashes for pygeodesic-0.1.10.tar.gz
Algorithm Hash digest
SHA256 5628a0395e85e9dc3272fc5d66b3d8c5ce6f7fad19437f509aebfaac6dcedccf
MD5 d55233fb06782c0559f1e1cf872f54af
BLAKE2b-256 1f54ac94c497a8f15315ffbfb95720b6325debabc21a7e708a1661cfd9c3820c

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4f7ee8f149868fd680291b0c72a6655905ddd6bd998897295420cc6b29501e02
MD5 21c811a0b3bc2564972bd1d90c18c19d
BLAKE2b-256 efc285e37b11037dae871c0ef76956ecafde916f31285e7cf11dab2a08ae33cc

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8623995ef63ae802378b7dfc6b0fa71f5e069d27d9e5b4c9cc1abfa7db52c80c
MD5 a3107bf2bf73148b4294fce1db895e34
BLAKE2b-256 5e967d8bddd303dc7a996062ad64467d7b9f008ea6a70f6ab370d49c2bc544f7

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c209b0840c9a2b610d4f99f7240b7870819721feaa2927ebb26eaf2fdd862ef6
MD5 1775eecb99531418ee75f4c09ebdba54
BLAKE2b-256 88e34fd54cd30c3bdf622b8cb42e6d0b96ca05d16269922d71b24563c5de1ffc

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0bc2aaf761fe1fbfe35254716dc357e17123a6f0ac5a8fbe02e0b95adeb9a627
MD5 e196d6565bb0eee2cb7e728919716cc4
BLAKE2b-256 25725f347f06bc72b3fbf032ab5dda232cb1e2c911fd828d85cd308ded8ff237

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 57860eb8a2ae0dabb8ee131ccd6b88dc06aed489cc2c0279f0f978a592039d88
MD5 76ca6b473285499320fc19bece59e033
BLAKE2b-256 85ef16bea4271e1b8e61dba305151f2bd57da180ee9539692f77ac91e1cf2025

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03145ba694112348a77d7585f495910f64b67db38b011dd46f660f0647d5e21b
MD5 96f2e213d19523585e7bc0f083c57a10
BLAKE2b-256 b6ab5fb8f03a4d168043791281d4783e838a572e5fef7ae79ec86acb1ea6df68

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 82e45719dd6dcea866cfb88016f8ed6940164808e7a977a82413d445ff776e67
MD5 860d5f03a7dddee78658a2a787b1ad89
BLAKE2b-256 b2f6328310f0ed85b49601a89e6ee743f5ba56252be77982171985c2e3e98da9

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74a4e095b306d73d3a0c0d63ef1625db6a8c04ffc856a73d211c27f0fddf4c34
MD5 6693f2c623dd2b3cc50033d4e366daec
BLAKE2b-256 45aaffc788c69ea4fb4bc39a4ab67411e9cf8a48b18e6ccff6b7d91e4e9a6268

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b99a732f5e1da022aed0fe4151b7ed88786947e44cc4ca8b1c06e77553f85761
MD5 68efbcf0d62952035263f91ae9e5afb1
BLAKE2b-256 2a9bafbbe0aa89ae1f18b24f956894243120090f066878f2a9fcc370a5380c46

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 83b77e6f1f3be58181f413747d4cfd396f0cf6dc323fdc135d2fd64343df778e
MD5 e7b3e735815817ee6a6bffa75ab965f8
BLAKE2b-256 3a55bfb3280542af200da1681ed4a1409682bdd9954fd46cebf3d4f775c0f91e

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c830fd15abdb0b62254a87bd37e56134986d7ab2c8a6c95427f80c47e58a5af
MD5 0c560c5e212501f36c6cc0295984cbc8
BLAKE2b-256 a21fc66e9dfa0a304bc537551990e8183604812ff5175311fbbad5341d615ab9

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 071df6bf79a3ac4101ee84239311bbdaeafbc5700ff60bc814134399f912a36f
MD5 b0e07ce392b31da7b12421b3d5e4c05b
BLAKE2b-256 5246417eaec200ac4d604e6398dd5c73c9582c65730c1be2aa59f128a48cc7d1

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a94b9e48c789eedc03743b32a595fae281af7f99a38ba09a0aee473997fc36d1
MD5 bc4be1ae38e59b1664ade5d40b108067
BLAKE2b-256 1827450a043de6e69c4ccfc99eabb008e651cd7e8339d3c321fa10660a9d2a1e

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bd869611e60cd8db1a0a30ba817512c568c5d33a9d028e8376208c1aec5e91a
MD5 710b6eac2de142737a56dc0114d78352
BLAKE2b-256 36ca499cea594365eda1e21b26c9ae10f9855e6fb6aa35322f0c7667c484b645

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ae3344579f825ab961fa97d2b8a1e36952015c731e2b7b65e7102d4d5108296
MD5 e52aefb6be9acb97d3e02b021ecdfb36
BLAKE2b-256 dd66f1d4f3de6d2a1cccee541d73a0d82c8e107266512c73478ffa092fa5a727

See more details on using hashes here.

File details

Details for the file pygeodesic-0.1.10-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pygeodesic-0.1.10-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 12a9b55220eecaaa14cdc5f66a654694d313f1448dcaf778f35e42a3ecceac68
MD5 70d6d9e3809dfc382c8a473bb0fe8458
BLAKE2b-256 ed6fc5a7f20d9c5ca2a80885d3a00f8d3ada4238fbae33cd88ac9a115e53da97

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