SPB Git

Repository Public

report-heights.sql 3.3 KB 38 lines sql

1-- =============================================================================2-- SP BOUCHER | SOURCE FILE3-- =============================================================================4-- Project      : KA Maps Engine5-- File         : server/pipeline/sql/report-heights.sql6-- Author       : Simon-Pierre Boucher | https://spboucher.ai7-- Contact      : support@spboucher.ai8-- Copyright    : (c) 2026 Simon-Pierre Boucher9-- License      : None specified (no license file in this repository)10-- =============================================================================11-- END OF SP BOUCHER SOURCE HEADER12-- =============================================================================1314-- Rapport de véracité des hauteurs (search_path = <schéma OSM>). Sortie texte, lue par 04-osm-import.sh qui15-- l'écrit dans /var/log/kamaps/heights-<version>.txt. Voir sql/enrich-heights.sql pour les règles.16\pset format unaligned17\pset fieldsep '\t'18\pset tuples_only on19\echo '== répartition (hs, origine de la hauteur, origine de l''empreinte, bâtiments)'20SELECT hs, coalesce(hsrc, '-'), src, count(*) FROM building GROUP BY 1, 2, 3 ORDER BY 1, 2, 3;21\echo '== classement des valeurs LiDAR appariées (mesure | bloc | rejet)'22SELECT coalesce(hlc, 'sans polygone LiDAR'), count(*) FROM building GROUP BY 1 ORDER BY 2 DESC;23\echo '== concordance LiDAR / height OSM (bâtiments à hauteur OSM explicite et polygone LiDAR classé « mesure ») : n, biais moyen (m), écart absolu médian, 90e centile, à ±2 m, à ±5 m, au-delà de 15 m'24SELECT count(*), round(avg(hl - h / 10.0)::numeric, 2), round((percentile_cont(0.5) WITHIN GROUP (ORDER BY abs(hl - h / 10.0)))::numeric, 2),25       round((percentile_cont(0.9) WITHIN GROUP (ORDER BY abs(hl - h / 10.0)))::numeric, 2),26       count(*) FILTER (WHERE abs(hl - h / 10.0) <= 2), count(*) FILTER (WHERE abs(hl - h / 10.0) <= 5), count(*) FILTER (WHERE abs(hl - h / 10.0) > 15)27  FROM building WHERE hsrc = 'osm' AND hlc = 'mesure';28\echo '== concordance LiDAR / étages OSM (hauteur LiDAR retenue comme mesure, étages connus) : n, biais moyen de lidar − (étages×3,1+1), écart absolu médian, 90e centile'29SELECT count(*), round(avg(hl - (levels * 3.1 + 1))::numeric, 2), round((percentile_cont(0.5) WITHIN GROUP (ORDER BY abs(hl - (levels * 3.1 + 1))))::numeric, 2),30       round((percentile_cont(0.9) WITHIN GROUP (ORDER BY abs(hl - (levels * 3.1 + 1))))::numeric, 2)31  FROM building WHERE hsrc = 'nrcan' AND levels IS NOT NULL;32\echo '== désaccords de plus de 15 m entre height OSM et LiDAR classé « mesure » (h OSM, LiDAR, nom, lon, lat)'33SELECT h / 10.0, round(hl::numeric, 1), coalesce(name, '?'), round(ST_X(ST_Transform(ST_Centroid(geom), 4326))::numeric, 4), round(ST_Y(ST_Transform(ST_Centroid(geom), 4326))::numeric, 4)34  FROM building WHERE hsrc = 'osm' AND hlc = 'mesure' AND abs(hl - h / 10.0) > 15 ORDER BY abs(hl - h / 10.0) DESC LIMIT 60;35\echo '== les 200 bâtiments les plus hauts (h m, hs, origine hauteur, origine empreinte, nom, lon, lat, année du levé, LiDAR apparié m)'36SELECT h / 10.0, hs, coalesce(hsrc, '-'), src, coalesce(name, '?'), round(ST_X(ST_Transform(ST_Centroid(geom), 4326))::numeric, 4), round(ST_Y(ST_Transform(ST_Centroid(geom), 4326))::numeric, 4), coalesce(hy::text, '-'), coalesce(round(hl::numeric, 1)::text, '-')37  FROM building ORDER BY h DESC, osm_id LIMIT 200;38
Files main
Menu

Theme