Rasterize
This module implements functions to rasterize lidar point clouds.
points_to_grid(source, resolution, crs, method='max', nodata=NODATA_VAL, chunk_size=2000000)
Ingests and transforms unstructured 3D point cloud distributions into strict, geo-aligned 2D raster grids via heavily optimized spatial hashing.
This function relies on the @resolve_pc decorator to dynamically supply either a
fully instantiated PointCloud object or a memory-safe stream generator based on
the presence of a chunk_size parameter during invocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Union[str, Path, PointCloud, Iterator[PointCloud], Generator[PointCloud, None, None]]
|
The target data input. Filepaths are resolved into object streams prior to execution. |
required |
resolution
|
float
|
Granularity of the output grid defining the geographic distance each pixel represents. |
required |
crs
|
Union[str, CRS]
|
Target Coordinate Reference System for spatial alignment. |
required |
method
|
str
|
Statistical aggregator to apply when multiple points fall within identical pixel bounds. Valid arguments are 'max' (highest elevation), 'min' (lowest elevation), or 'count' (point density). Defaults to 'max'. |
'max'
|
nodata
|
float
|
Filler scalar designated for pixels containing zero point intersections. Defaults to the module-level NODATA_VAL. |
NODATA_VAL
|
chunk_size
|
int
|
Buffer limit representing the maximum number of points processed per iterative cycle. Defaults to 2,000,000. |
2000000
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the |
TypeError
|
If the resolved source fails to inherit from the expected PointCloud or Iterator signatures. |
Returns:
| Name | Type | Description |
|---|---|---|
Raster |
Raster
|
A fully populated raster object containing the processed 2D array matrix, affine transformation parameters, the designated CRS, and metadata properties. |
Source code in src/phytospatial/lidar/rasterize.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |