pyinterp.RTree3DFloat32#
- class pyinterp.RTree3DFloat32(self, spheroid: pyinterp.core.geometry.geographic.Spheroid | None = None)#
Bases:
objectSpatial index for 3D point data with interpolation methods.
Create a spatial R-tree index for 3D point data with support for various interpolation methods including k-nearest neighbor search, inverse distance weighting, kriging, radial basis functions, and window functions.
- Parameters:
spheroid – Optional spheroid for geodetic coordinate conversions. If provided, input coordinates are assumed to be (lon, lat, alt) in degrees/degrees/meters, and will be converted to ECEF internally. If None, input coordinates are treated as Cartesian without any transformation. These can represent ECEF coordinates, planar coordinates (with Z=0), or any other Cartesian system. Users must ensure unit consistency across all coordinates and values. Defaults to None.
Examples
>>> import numpy as np >>> import pyinterp
Create RTree for Cartesian coordinates (e.g., planar system)
>>> coords = np.array([ ... [0.0, 0.0, 0.0], ... [1.0, 1.0, 0.0] ... ], dtype='float64') >>> values = np.array([10.5, 20.3], dtype='float64') >>> tree = pyinterp.RTree3D() >>> tree.packing(coords, values)
Query k-nearest neighbors
>>> query_coords = np.array([[0.5, 0.5, 0.0]]) >>> distances, values = tree.query(query_coords, k=2)
Create RTree with geodetic coordinates (lon, lat, alt)
>>> geodetic_coords = np.array([ ... [0.0, 45.0, 100.0], ... [1.0, 46.0, 200.0] ... ], dtype='float64') >>> tree_geodetic = pyinterp.RTree3D(spheroid=pyinterp.Spheroid()) >>> tree_geodetic.packing(geodetic_coords, values)
Initialize the RTree3D with optional spheroid for geodetic conversions.
Attributes
Get the spheroid used for geodetic conversions, or None for ECEF.
Public Methods
bounds(self)Return the bounding box containing all stored values, or None if the tree is empty.
clear(self)Remove all points from the tree.
empty(self)Check if the tree is empty.
insert(self, coordinates[, shape, writable, ...])Insert points into the tree.
inverse_distance_weighting(self, coordinates)Inverse distance weighting interpolation.
kriging(self, coordinates[, shape, writable])Kriging interpolation.
packing(self, coordinates[, shape, ...])Bulk-load points using STR packing algorithm.
query(self, coordinates[, shape, writable])Query k-nearest neighbors for multiple points.
radial_basis_function(self, coordinates[, ...])Radial basis function interpolation.
size(self)Return the number of points in the tree.
window_function(self, coordinates[, shape, ...])Window function based interpolation.
Special Methods
__getstate__(self)Get the state for pickling.
__new__(*args, **kwargs)__setstate__(self, state)Set the state for unpickling.