Skip to content

hugoledoux/startinpy

Repository files navigation

PyPI docs GitHub license

startinpy

Python bindings for startin, a Delaunay triangulator for the modelling of terrains.

Installation

pip

To install the latest release: pip install startinpy

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

Documentation

https://startinpy.rtfd.io

Examples

import startinpy
import numpy as np

#-- generate 100 points randomly in the plane
rng = np.random.default_rng()
pts = rng.random((100, 3))
pts = pts * 100

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("CH: ", dt.convex_hull())

print(dt.is_triangle([4, 12, 6]) )
print(dt.is_triangle([5, 12, 6]) )

print("--- /Points ---")
for each in dt.points:
    print(each)
print("--- Points/ ---")

alltr = dt.triangles
print(alltr[3])

zhat = dt.interpolate({"method": "TIN"}, [[55.2, 33.1]])
print("result: ", zhat[0])

It can read LAS/LAZ and output GeoJSON files too:

import startinpy
t = startinpy.DT()
t.read_las("/home/elvis/myfile.laz")
print("# vertices:", t.number_of_vertices())
print("# triangles:", t.number_of_triangles())
t.write_geojson("/home/elvis/output.geojson")