Soumis par Mathieu Bossaert le
La BD TOPO de l'IGN est stockée en base dans le schéma ign_bd_topo.
La commune de Montpellier compte 9014 objets dans la table bati_indifferencie. Le MNT est dans la table ign_bd_topo.mnt34.
WITH pixel_concernes AS (SELECT bati_indifferencie.id, (ST_DumpAsPolygons(ST_clip(rast, bati_indifferencie.geometrie))).val AS altitude FROM ign_bd_topo.mnt34 AS altitude JOIN ign_bd_topo.bati_indifferencie ON st_intersects(rast,geometrie) JOIN ign_bd_topo.commune ON st_intersects(commune.geometrie,bati_indifferencie.geometrie) WHERE commune.nom = 'Montpellier' ) SELECT id, avg(altitude) FROM pixel_concernes GROUP BY id