-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes/#350 osm bld load assignment
- Loading branch information
Showing
6 changed files
with
277 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/egon/data/datasets/osm_buildings_streets/osm_buildings_extend_residential.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Original Autor: nesnoj (jonathan.amme@rl-institut.de) | ||
*/ | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Extend residential buildings by finding census cells with population but -- | ||
-- no residential buildings before in osm_buildings_filter_residential.sql . -- | ||
-- Mark commercial, retail, office, hotel buildings as residential in those -- | ||
-- cells. -- | ||
-------------------------------------------------------------------------------- | ||
|
||
INSERT INTO openstreetmap.osm_buildings_residential | ||
SELECT * | ||
FROM openstreetmap.osm_buildings_filtered | ||
WHERE id IN ( | ||
SELECT id FROM ( | ||
-- get buildings from filtered table in census cells (by centroid) | ||
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) | ||
WHERE building in ('commercial', 'retail', 'office', 'hotel') | ||
AND zensus.zensus_population_id in ( | ||
-- census cell ids which have population but no res. buildings | ||
SELECT zensus.zensus_population_id | ||
FROM society.egon_destatis_zensus_apartment_building_population_per_ha zensus | ||
LEFT OUTER JOIN openstreetmap.osm_buildings_residential bld | ||
ON ST_Intersects(bld.geom_building, zensus.geom) | ||
WHERE bld.id IS NULL | ||
) | ||
) bld2 | ||
WHERE bld2.id IS NOT NULL AND bld2.grid_id IS NOT NULL | ||
) | ||
; |
Oops, something went wrong.