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')
|
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):
|
def detect_ground_method(laz_file):
|
||||||
"""Detect the best ground classification method based on point cloud statistics.
|
"""Detect the best ground classification method based on point cloud statistics.
|
||||||
|
|
||||||
|
|||||||
@ -272,6 +272,11 @@ class LidarArchaeoPipeline:
|
|||||||
logger.info(f"FICHIER : {basename}")
|
logger.info(f"FICHIER : {basename}")
|
||||||
logger.info("=" * 60)
|
logger.info("=" * 60)
|
||||||
|
|
||||||
|
# Validate file integrity before any processing
|
||||||
|
from .dtm import validate_laz
|
||||||
|
if not validate_laz(laz_file):
|
||||||
|
return False
|
||||||
|
|
||||||
# Skip ground classification + DTM if DTM already exists with matching resolution
|
# Skip ground classification + DTM if DTM already exists with matching resolution
|
||||||
# --force only affects visualizations/PDF, not classification/DTM
|
# --force only affects visualizations/PDF, not classification/DTM
|
||||||
# Use --force-classification to force reclassification
|
# Use --force-classification to force reclassification
|
||||||
|
|||||||
Reference in New Issue
Block a user