Add LAZ integrity check to skip corrupted files early
Validate file readability before PDAL classification. Corrupted/truncated files are detected instantly via laspy header read and skipped with a clear error message pointing to re-download, instead of wasting time on PDAL and repair attempts that will fail anyway. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -124,6 +124,29 @@ def create_csf_pipeline(input_laz, output_las):
|
||||
return _create_ground_pipeline(input_laz, output_las, 'csf')
|
||||
|
||||
|
||||
def validate_laz(laz_file):
|
||||
"""Quick integrity check for a LAZ/LAS file.
|
||||
|
||||
Reads the header with laspy to detect truncated or corrupted files
|
||||
before launching expensive PDAL processing.
|
||||
|
||||
Returns:
|
||||
True if file is readable, False otherwise.
|
||||
"""
|
||||
import laspy
|
||||
try:
|
||||
with laspy.open(str(laz_file)) as f:
|
||||
# Just read the header — fast and catches truncated files
|
||||
header = f.header
|
||||
_ = header.point_count
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f" ✗ Fichier corrompu ou incomplet: {laz_file.name}")
|
||||
logger.error(f" {e}")
|
||||
logger.error(f" → Re-télécharger depuis https://ign.fr/lidar-hd")
|
||||
return False
|
||||
|
||||
|
||||
def detect_ground_method(laz_file):
|
||||
"""Detect the best ground classification method based on point cloud statistics.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user