Note
Go to the end to download the full example code.
Gridding points to raster#
This example demonstrates the gridding of a point cloud into a raster using gridding().
We open an example point cloud, an elevation dataset in New Zealand.
import geoutils as gu
filename_pc = gu.examples.get_path("coromandel_lidar")
pc = gu.PointCloud(filename_pc, data_column="Z")
# Plot the point cloud
pc.plot(cmap="terrain", cbar_title="Elevation (m)")

We generate grid coordinates to interpolate to, alternatively we could pass a raster to use as reference.
import numpy as np
grid_coords = (np.linspace(pc.bounds.left, pc.bounds.right, 100), np.linspace(pc.bounds.bottom, pc.bounds.top, 100))
We then perform the interpolation
Finally, we plot the resulting raster
rast.plot(ax="new", cmap="terrain", cbar_title="Elevation (m)")

Total running time of the script: (0 minutes 49.525 seconds)