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:
Jacquin Antoine
2026-05-10 11:34:41 +02:00
parent f03b3873bd
commit c3a8fe7b79
2 changed files with 28 additions and 8 deletions

View File

@ -324,8 +324,10 @@ def tif_to_png(tif_file, vis_dir, resolution):
# Apply colormap
data, cmap, title, legend_label, description, is_rgb_result = _apply_colormap(data, tif_file)
# Create figure
fig_width = 20
# Create figure — adapt width to data resolution for sharp rendering
# At high res (5000+px wide), we need a larger figure to avoid downsampling artifacts
fig_width = max(20, width / 150)
fig_width = min(fig_width, 40) # cap at 40 inches
map_aspect = height / width
fig = plt.figure(figsize=(fig_width, fig_width * map_aspect * 0.7 + 2.5),
facecolor='white')
@ -335,9 +337,11 @@ def tif_to_png(tif_file, vis_dir, resolution):
ax = fig.add_subplot(gs[0])
if is_rgb:
im = ax.imshow(data, aspect='equal', origin='upper')
im = ax.imshow(data, aspect='equal', origin='upper',
interpolation='bilinear')
else:
im = ax.imshow(data, cmap=cmap, aspect='equal', origin='upper')
im = ax.imshow(data, cmap=cmap, aspect='equal', origin='upper',
interpolation='bilinear')
ax.set_title(f"{title}\n{description}", fontsize=15, fontweight='bold', pad=10)
@ -450,9 +454,10 @@ def tif_to_png(tif_file, vis_dir, resolution):
fig.patch.set_facecolor('white')
# Save as PNG then convert to WebP
# Save as PNG then convert to WebP — use higher DPI for large data
save_dpi = 200 if width > 3000 else 150
png_temp = vis_dir / f"{tif_file.stem}_temp.png"
plt.savefig(png_temp, dpi=150, bbox_inches='tight', pad_inches=0.15,
plt.savefig(png_temp, dpi=save_dpi, bbox_inches='tight', pad_inches=0.15,
facecolor='white', format='png')
plt.close()