Skip to main content

Modelling terrains with Delaunay triangulation

Project description

PyPI docs GitHub license

startinpy

A library for modelling and processing 2.5D terrains using a (2D) Delaunay triangulation. The triangulation is computed in 2D, but the z-elevation of the vertices are kept.

The underlying code is written in Rust (so it's rather fast) and robust arithmetic is used (so it shouldn't crash). startinpy uses the startin Rust library and adds several utilities and functions, for instance NumPy support for input/output, exporting to several formats, and easy-of-use.

startinpy allows you to:

  1. insert incrementally points
  2. delete vertices (useful for simplification, interpolation, and other operations)
  3. interpolate with several methods: TIN, natural neighbours, IDW, Laplace, etc.
  4. use other useful terrain Python libraries that are also NumPy-based, eg laspy, rasterio, meshio
  5. output the TIN to several formats: OBJ, PLY, GeoJSON, and CityJSON
  6. store extra attributes with the vertices (the ones from LAS/LAZ)

Documentation

https://startinpy.rtfd.io

Installation

pip

To install the latest release: pip install startinpy

(watch out: this does not work with Linux currently, it installs an old version!)

If you want to compile it yourself

  1. install latest Rust
  2. install maturin
  3. maturin build --release
  4. cd ./target/wheels/
  5. pip install [name-wheel].whl will install it to your local Python

Development

  1. install Rust (v1.39+)
  2. install maturin
  3. maturin develop
  4. move to another folder, and import startinpy shouldn't return any error

Examples

The folder ./demo contains a few examples.

import startinpy
import numpy as np
import laspy

las = laspy.read("../data/small.laz")
pts = np.vstack((las.x, las.y, las.z)).transpose()

dt = startinpy.DT()
dt.insert(pts)

#-- remove vertex #4
try:
    dt.remove(4)
except Exception as e:
    print(e)

print("# vertices:", dt.number_of_vertices())
print("# triangles:", dt.number_of_triangles())

#-- print the vertices forming the convex hull, in CCW-order
print("CH: ", dt.convex_hull())

#-- fetch all the incident triangles (CCW-ordered) to the vertex #235
vi = 235
one_random_pt = dt.points[vi]
print("one random point:", one_random_pt)
print(dt.incident_triangles_to_vertex(vi))

#-- interpolate at a location with the linear in TIN method
zhat = dt.interpolate({"method": "TIN"}, [[85718.5, 447211.6]])
print("result: ", zhat[0])

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

startinpy-0.11.0-cp312-none-win_amd64.whl (337.1 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

startinpy-0.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (508.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

startinpy-0.11.0-cp312-cp312-macosx_11_0_arm64.whl (379.7 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

startinpy-0.11.0-cp311-none-win_amd64.whl (335.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

startinpy-0.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (509.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

startinpy-0.11.0-cp311-cp311-macosx_11_0_arm64.whl (381.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

startinpy-0.11.0-cp310-none-win_amd64.whl (335.1 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

startinpy-0.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (509.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

startinpy-0.11.0-cp310-cp310-macosx_11_0_arm64.whl (381.1 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

startinpy-0.11.0-cp39-none-win_amd64.whl (335.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

startinpy-0.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (509.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

startinpy-0.11.0-cp39-cp39-macosx_11_0_arm64.whl (381.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

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