brycefrank / pyfor

Tools for analyzing aerial point clouds of forest data.
MIT License
93 stars 19 forks source link

Failed rasterization #79

Open Vicent-Ribas opened 12 months ago

Vicent-Ribas commented 12 months ago

Hello,

Thank you for putting this together. I am running a script to generate percentile 95th output of a LAS file. This is my code:

print("Computing rasterization of the prepared las file. Requires laspy 1.7") tile = pyfor.cloud.Cloud(lasin) tile.crs = src grid = tile.grid(cell_size=20) # this function utilizes Z as the variable pct95ht = pyfor.metrics.grid_percentile (grid, 95) pct95ht.write(rstat)

It works most of the times, but it is the second time I get this error:

File "myfile.py", line 130, in rasterdomht pct95ht = pyfor.metrics.grid_percentile (grid, 95) File "mypath\pyfor\metrics.py", line 77, in grid_percentile return grid.raster(lambda z: np.percentile(z, percentile), "z") File "mypath\pyfor\rasterizer.py", line 55, in raster array[bin_summary["bins_y"], bin_summary["bins_x"]] = bin_summary[dim] IndexError: index 78 is out of bounds for axis 1 with size 78

I have Python 3.8.1 in a Conda environment.

Thank you!

Vicent-Ribas commented 12 months ago

I believe this has something to do with the bug report https://github.com/pandas-dev/pandas/issues/35275, but I would have expected that the .reset_index() when the .agg function is called would prevent this to happen. However, I've found that only sometimes I get this error, with no explanation so far...