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 is 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:
insert points incrementally
delete vertices (useful for simplification, interpolation, and other operations)
interpolate with several methods: TIN, natural neighbours, IDW, Laplace, etc.
use other useful terrain Python libraries that are also NumPy-based, eg laspy, rasterio, and meshio
output the TIN to several formats: OBJ, PLY, GeoJSON, and CityJSON
store extra attributes for the vertices (eg the ones from LAS/LAZ)
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])
Table of content¶
- Installation
- How startinpy works
- Examples
- Extra attributes
- API
DTDT.adjacent_triangles_to_triangle()DT.adjacent_vertices_to_vertex()DT.area2d_triangle()DT.area3d_triangle()DT.attributesDT.closest_point()DT.collect_garbage()DT.convex_hull()DT.duplicates_handlingDT.get_attributes_schema()DT.get_bbox()DT.get_point()DT.get_vertex_attributes()DT.has_garbage()DT.incident_triangles_to_vertex()DT.insert()DT.insert_one_pt()DT.interpolate()DT.is_finite()DT.is_inside_convex_hull()DT.is_triangle()DT.is_vertex_convex_hull()DT.is_vertex_removed()DT.jump_and_walkDT.locate()DT.normal_triangle()DT.normal_vertex()DT.number_of_triangles()DT.number_of_vertices()DT.pointsDT.remove()DT.set_attributes_schema()DT.set_vertex_attributes()DT.snap_toleranceDT.trianglesDT.update_vertex_z_value()DT.vertical_exaggeration()DT.volume_triangle()DT.write_cityjson()DT.write_geojson()DT.write_obj()DT.write_ply()
- Issues? Bugs? Questions?