-2

I am working with LAS files containing LiDAR point cloud data and a shapefile defining polygons. The goal is to compare the classification values of points within the polygons between two LAS files and report any changes.

I attempted to analyze LAS files using Python, comparing classification values within polygons defined by a shapefile. I expected to see accurate classification change counts for each shape. However, the process seemed to encounter issues as the reported counts were consistently zero, even though there were points within the polygons.

After careful debugging, I realized that the bounding polygons were not being constructed accurately due to the presence of shapes with more than four vertices. I adjusted the method to create the bounding polygons, ensuring they encompassed all vertices, and validated their geometry (but the result is still zero).

This part of the code does not work correctly

Loop through each row (shape) in the shapefile
for index, row in shapefile.iterrows():
shape_index = index  # Use the index as the shape identifier

print(f"Processing shape index: {shape_index}")

# Get the shape's geometry
shape_geometry = row.geometry

# Calculate the bounding polygon using the envelope method
bounding_polygon = shape_geometry.envelope

# Filter points within the bounding polygon and based on classification values
filtered_indices = [
    i for i, point in enumerate(points_new)
    if bounding_polygon.contains(Point(point['point']['X'], point['point']['Y']))
       and classifications_new[i] in {1, 2, 3, 4, 5, 6, 7, 9, 17}
]

print(f"Number of points within bounding polygon: {len(filtered_indices)}")
NK_96
  • 1
  • 1

0 Answers0