Skip to content
Snippets Groups Projects
Commit 20a2cc59 authored by benoit-cty's avatar benoit-cty
Browse files

p20_ -> p21_

parent 3d239532
No related branches found
No related tags found
1 merge request!54Mise à jour de DataCirco
Pipeline #20092 failed
......@@ -94,14 +94,14 @@ class GetLogement:
"""
select
st_asgeojson((st_dump(st_intersection(i.wkb_geometry,c.wkb_geometry))).geom)::json as geojson,
round(100*(p20_log::numeric-p20_maison::numeric)/p20_log::numeric,1) as pct_logement_collectifs,
round(100 * P20_RP_PROP::numeric / P20_RP::numeric,1) as pct_proprietaires,
p20_log::numeric as nb_logements,
p20_maison as nb_logements_individuels,
p20_RP::numeric as nb_residences_principales,
p20_RP_prop::numeric as nb_rp_prop,
P20_LOGVAC::numeric as nb_logements_vacants,
P20_RSECOCC::numeric as nb_residences_secondaires_ou_occ
round(100*(p21_log::numeric-p21_maison::numeric)/p21_log::numeric,1) as pct_logement_collectifs,
round(100 * p21_RP_PROP::numeric / p21_RP::numeric,1) as pct_proprietaires,
p21_log::numeric as nb_logements,
p21_maison as nb_logements_individuels,
p21_RP::numeric as nb_residences_principales,
p21_RP_prop::numeric as nb_rp_prop,
p21_LOGVAC::numeric as nb_logements_vacants,
p21_RSECOCC::numeric as nb_residences_secondaires_ou_occ
from zone_circo c
join iris_ge i on (st_intersects(c.wkb_geometry, i.wkb_geometry))
join insee_logement_2021 p on (p.iris=i.code_iris)
......@@ -163,20 +163,20 @@ class GetLogement:
# à l'échelle de la circonscription :
utilitaires.db_exec(
self.db.mogrify(
f"""SELECT SUM(p20_log::numeric*st_area(st_intersection(iris.wkb_geometry, circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RSECOCC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RPMAISON::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RPAPPART::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_PROP::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_LOC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_GRAT::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_LOGVAC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM((P20_RP_ACH19::numeric + P20_RP_ACH45::numeric + P20_RP_ACH70::numeric + P20_RP_ACH90::numeric)*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography))
f"""SELECT SUM(p21_log::numeric*st_area(st_intersection(iris.wkb_geometry, circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RSECOCC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RPMAISON::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RPAPPART::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_PROP::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_LOC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_GRAT::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_LOGVAC::numeric*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM((p21_RP_ACH19::numeric + p21_RP_ACH45::numeric + p21_RP_ACH70::numeric + p21_RP_ACH90::numeric)*st_area(st_intersection(iris.wkb_geometry,circo.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography))
FROM insee_logement_2021 AS log
JOIN iris_ge AS iris ON iris.code_iris = log.iris
JOIN zone_circo AS circo ON st_intersects(iris.wkb_geometry, circo.wkb_geometry)
WHERE log.P20_RSECOCC IS NOT NULL AND circo.ref = '{self.circo}';"""
WHERE log.p21_RSECOCC IS NOT NULL AND circo.ref = '{self.circo}';"""
)
)
valeurs_circo = [float(i) for i in self.db.fetchone()]
......@@ -184,20 +184,20 @@ class GetLogement:
# à l'échelle du dépatrtement :
utilitaires.db_exec(
self.db.mogrify(
f"""SELECT SUM(p20_log::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RSECOCC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RPMAISON::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RPAPPART::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_PROP::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_LOC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_RP_GRAT::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(P20_LOGVAC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM((P20_RP_ACH19::numeric + P20_RP_ACH45::numeric + P20_RP_ACH70::numeric + P20_RP_ACH90::numeric)*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography))
f"""SELECT SUM(p21_log::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RSECOCC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RPMAISON::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RPAPPART::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_PROP::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_LOC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_RP_GRAT::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM(p21_LOGVAC::numeric*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography)),
SUM((p21_RP_ACH19::numeric + p21_RP_ACH45::numeric + p21_RP_ACH70::numeric + p21_RP_ACH90::numeric)*st_area(st_intersection(iris.wkb_geometry, dep.wkb_geometry)::geography)/st_area(iris.wkb_geometry::geography))
FROM insee_logement_2021 AS log
JOIN iris_ge AS iris ON iris.code_iris = log.iris
JOIN ign_departement AS dep ON st_intersects(iris.wkb_geometry, dep.wkb_geometry)
WHERE log.P20_RSECOCC IS NOT NULL AND dep.insee_dep = '{self.dept}';"""
WHERE log.p21_RSECOCC IS NOT NULL AND dep.insee_dep = '{self.dept}';"""
)
)
valeurs_dept = [float(i) for i in self.db.fetchone()]
......@@ -205,16 +205,16 @@ class GetLogement:
# à l'échelle nationale
utilitaires.db_exec(
self.db.mogrify(
"""SELECT SUM(p20_log::numeric),
SUM(P20_RP::numeric),
SUM(P20_RSECOCC::numeric),
SUM(P20_RPMAISON::numeric),
SUM(P20_RPAPPART::numeric),
SUM(P20_RP_PROP::numeric),
SUM(P20_RP_LOC::numeric),
SUM(P20_RP_GRAT::numeric),
SUM(P20_LOGVAC::numeric),
SUM((P20_RP_ACH19::numeric + P20_RP_ACH45::numeric + P20_RP_ACH70::numeric + P20_RP_ACH90::numeric))
"""SELECT SUM(p21_log::numeric),
SUM(p21_RP::numeric),
SUM(p21_RSECOCC::numeric),
SUM(p21_RPMAISON::numeric),
SUM(p21_RPAPPART::numeric),
SUM(p21_RP_PROP::numeric),
SUM(p21_RP_LOC::numeric),
SUM(p21_RP_GRAT::numeric),
SUM(p21_LOGVAC::numeric),
SUM((p21_RP_ACH19::numeric + p21_RP_ACH45::numeric + p21_RP_ACH70::numeric + p21_RP_ACH90::numeric))
FROM insee_logement_2021 AS log
JOIN iris_ge AS iris ON iris.code_iris = log.iris
JOIN ign_departement AS dep ON st_intersects(iris.wkb_geometry, dep.wkb_geometry);"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment