Skip to content

Commit

Permalink
Merge branch 'features/#587-update-osm-residential-buildings' into co…
Browse files Browse the repository at this point in the history
…ntinuous-integration/run-everything-over-the-weekend-v2
  • Loading branch information
nesnoj committed Feb 22, 2022
2 parents 3c03f4b + 0ba8243 commit 77e1e0f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
7 changes: 5 additions & 2 deletions src/egon/data/datasets/osm_buildings_streets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
Resulting table: `openstreetmap.osm_amenities_shops_filtered`
* Create a mapping table for building's osm IDs to the Zensus cells the
building's centroid is located in.
Resulting table: `boundaries.egon_map_zensus_buildings_filtered`
Resulting tables:
* `boundaries.egon_map_zensus_buildings_filtered` (filtered)
* `boundaries.egon_map_zensus_buildings_residential` (residential only)
* Enrich each building by number of apartments from Zensus table
`society.egon_destatis_zensus_apartment_building_population_per_ha`
by splitting up the cell's sum equally to the buildings. In some cases, a
Expand Down Expand Up @@ -77,7 +79,8 @@ def preprocessing():
sql_scripts = [
"osm_amenities_shops_preprocessing.sql",
"osm_buildings_filter.sql",
"osm_buildings_zensus_mapping.sql",
"osm_buildings_filtered_zensus_mapping.sql",
"osm_buildings_residential_zensus_mapping.sql",
"osm_buildings_temp_tables.sql",
]
for script in sql_scripts:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Original Autor: IsGut (johnrobert@t-online.de)
* Adapted by: nesnoj (jonathan.amme@rl-institut.de)
*/

----------------------------------------------------------------
-- Create mapping table of filtered buildings to zensus cells --
----------------------------------------------------------------
-- Only selecting buildings wihtin the purged census cells
-- purged of cells with unpopulated areas
-- https://github.com/openego/eGon-data/blob/59195926e41c8bd6d1ca8426957b97f33ef27bcc/src/egon/data/importing/zensus/__init__.py#L418-L449
drop table if exists boundaries.egon_map_zensus_buildings_filtered;
CREATE TABLE boundaries.egon_map_zensus_buildings_filtered as
select * from (
select
bld.id,
zensus.grid_id,
zensus.zensus_population_id as cell_id
from openstreetmap.osm_buildings_filtered bld
left join society.egon_destatis_zensus_apartment_building_population_per_ha zensus
on ST_Within(bld.geom_point, zensus.geom)
) bld2
where bld2.id is not null and bld2.grid_id is not null;
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@
* Adapted by: nesnoj (jonathan.amme@rl-institut.de)
*/

----------------------------------------------------------------
-- Create mapping table of filtered buildings to zensus cells --
----------------------------------------------------------------
-- Only selecting buildings wihtin the purged census cells
-- purged of cells with unpopulated areas
-- https://github.com/openego/eGon-data/blob/59195926e41c8bd6d1ca8426957b97f33ef27bcc/src/egon/data/importing/zensus/__init__.py#L418-L449
drop table if exists boundaries.egon_map_zensus_buildings_filtered;
CREATE TABLE boundaries.egon_map_zensus_buildings_filtered as
select * from (
select
bld.id,
zensus.grid_id,
zensus.zensus_population_id as cell_id
from openstreetmap.osm_buildings_filtered bld
left join society.egon_destatis_zensus_apartment_building_population_per_ha zensus
on ST_Within(bld.geom_point, zensus.geom)
) bld2
where bld2.id is not null and bld2.grid_id is not null;

-------------------------------------------------------------------
-- Create mapping table of residential buildings to zensus cells --
-------------------------------------------------------------------
Expand Down

0 comments on commit 77e1e0f

Please sign in to comment.