Skip to content

Commit

Permalink
Improve docs api
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoledoux committed Jul 5, 2024
1 parent 58a2fa8 commit eb0d447
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ for i in range(band1.shape[0]):
x = t[2] + (j * t[0]) + (t[0] / 2)
y = t[5] + (i * t[4]) + (t[4] / 2)
z = band1[i][j]
#-- skip no_data + select randomly only 1% of the points
if (z != d.nodatavals) and (random.randint(0, 100) == 5):
pts.append([x, y, z])
dt = startinpy.DT()
Expand Down Expand Up @@ -193,6 +194,8 @@ def main():
centres = np.asarray(centres)
print("Interpolating at {} locations".format(centres.shape[0]))
zhat = dt.interpolate({"method": "TIN"}, centres)
# zhat = dt.interpolate({"method": "Laplace"}, centres)
# zhat = dt.interpolate({"method": "IDW", "radius": 20, "power": 2.0}, centres, strict=True)

#-- save to a GeoTIFF with rasterio
write_rasterio('grid.tiff', zhat.reshape((deltay, deltax)), (bbox[0], bbox[1]), cellsize)
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,14 +919,17 @@ impl DT {
}
}

/// Interpolate with 5 different methods:
/// Estimate the z-value with 5 different spatial interpolation methods:
///
/// 1. **IDW**: inverse distance weighing
/// 2. **Laplace**: a faster NNI with almost the same results
/// 3. **NN**: nearest neighbour
/// 4. **NNI**: natural neighbour interpolation
/// 5. **TIN**: linear interpolation in TIN
///
/// The interpolation does not modify the triangulation, it only returns an estimation for
/// the z-values at the xy-location provided as argument.
///
/// :param interpolant: a JSON/dict Python object with a `"method": "IDW"` (or others). IDW has 2 more params: "power" and "radius"
/// :param locations: an array of [x, y] locations where the function should interpolate
/// :param strict: (default=False) if the interpolation cannot find a value (because outside convex hull or search radius too small) then strict==True will stop at the first error and return that error. If strict==False then numpy.nan is returned.
Expand Down

0 comments on commit eb0d447

Please sign in to comment.