# Determining pixel size based on LiDAR point cloud density

I have a point cloud with a density of 8 points/m². I would like to generate a digital elevation model (DEM) from it, but I don't know what resolution to set as the raster pixel.

So I would like to know if there are any formulas that can be used to calculate this or the raster resolution is subjective?

The value for the raster resolution should be a bit more then 0.333 m, ca. around 0.34 meters. See below why.

## Value for 9 regularily spaced points per square meter

Consider the image below and suppose the black square is 1m x 1m. Subdividing it in 9 equally sized squares (green dotted line) and getting the centroids of each (red dots), you have 9 points per square meter. As can be seen, each point has a distance from each other correspoinding to 1/3 of the side length of the black square, thus 1/3 meters = 0.333 meters.

## Value for 8 regularily spaced points per square meter

For 8 more or less regularily distributed points, draw a regular polygon with 7 with center at the centroid of the large square and 7 sides/edges (blue dotted line). The 7 nodes (vertices) of the polygon together with it's centroid return 8 points (blue stars). As you can see, their distance from each other is slightly larger, but not much (the two stars at the bottom).

So to give an answer: set a value of like 0.35 meters for pixel resution.

## Calculating experimentally the mean distance of 8 more or less evenly distributed points

Using antother approach, I generated 500 random points for each of the 9 smaller squares, applied K-means clustering with `Number of clusters` = 8, created voronoi polygons, aggregated them based on the field `CLUSTER_ID` to get 8 more or less evently subparts (red outlined in the next screenshot) of the large square and created the centroid of each of these polygons (red star). Then I calculated the mean distance from each of these centroid to its two nearest neighbors (see below for the expression used). Result: 0.339 meters. If using the pole of inaccessability instead of the centroid, the value is 0.346 meters.

The expression used to calculate the mean distance from each of the red stars to the two nearest neighbors. The expression is applied to the aggregated voronoi polygons:

``````mean(
with_variable(
'array',
array_sort(
array_foreach(
overlay_nearest (@layer, centroid (\$geometry), limit:=8),
length (make_line (centroid (\$geometry), @element))
)
),
(@array[0] + @array[1] )/2
)
)

``````

Centroids (white=red stars in the screenshot above) and poles of inaccessability (red) from the aggregated voronoi polygons (outlined in fine red line): 8 more or less evenly distributed points: