Amélioration du rendu: interpolation DTM et affichage haute résolution
- DTM: interpolation des NaN avec rasterio.fill.fillnodata après binned_statistic_2d — comble les trous entre les cellules sans données - Rendering: interpolation='bilinear' sur imshow pour lisser le sous-échantillonnage des données haute résolution - Rendering: fig_width adaptatif (20-40 pouces) selon la taille des données - Rendering: DPI 200 pour les images > 3000px de large Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@ -285,10 +285,25 @@ def create_dtm_fast(las_file, basename, dtm_dir, resolution):
|
||||
dtm = stat.statistic.T
|
||||
dtm = dtm[::-1, :] # Flip Y so north is at top
|
||||
|
||||
# No interpolation: keep NaN for zones without LiDAR data
|
||||
# Interpolate NaN gaps using distance-weighted nearest-neighbor fill
|
||||
nan_count = np.count_nonzero(np.isnan(dtm))
|
||||
if nan_count > 0:
|
||||
logger.info(f" {nan_count:,} pixels sans données (conservés en NaN)")
|
||||
total = dtm.size
|
||||
nan_pct = 100.0 * nan_count / total
|
||||
logger.info(f" {nan_count:,} pixels sans données ({nan_pct:.1f}%) — interpolation...")
|
||||
|
||||
from rasterio.fill import fillnodata
|
||||
# rasterio.fill.fillnodata uses GDAL's interpolation:
|
||||
# fills gaps from surrounding valid pixels with distance weighting
|
||||
dtm_filled = fillnodata(dtm.astype(np.float32), mask=~np.isnan(dtm),
|
||||
max_search_distance=max(width, height) // 4)
|
||||
dtm = dtm_filled.astype(np.float64)
|
||||
|
||||
remaining = np.count_nonzero(np.isnan(dtm))
|
||||
if remaining > 0:
|
||||
logger.warning(f" {remaining:,} pixels encore sans données après interpolation")
|
||||
else:
|
||||
logger.info(f" ✓ Interpolation terminée — tous les trous comblés")
|
||||
|
||||
# Save as GeoTIFF
|
||||
output_tif = dtm_dir / f"{basename}_dtm.tif"
|
||||
|
||||
Reference in New Issue
Block a user