-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The results of the DE census 2022 were published in June 2024. Update the processing script. Since a lot more buildings are mapped in OSM in the meantime, require buildings now, not just residential land use.
- Loading branch information
Showing
21 changed files
with
186 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
#!/bin/bash -e | ||
set -o pipefail | ||
|
||
source env.sh | ||
|
||
cd data | ||
echo ">>> Downloading Census 2011 data" | ||
wget 'https://www.zensus2011.de/SharedDocs/Downloads/DE/Pressemitteilung/DemografischeGrunddaten/csv_Bevoelkerung_100m_Gitter.zip?__blob=publicationFile&v=3' \ | ||
echo ">>> Downloading Census 2022 data" | ||
wget 'https://www.zensus2022.de/static/Zensus_Veroeffentlichung/Zensus2022_Bevoelkerungszahl.zip' \ | ||
--timestamping | ||
ln -sf csv_Bevoelkerung_100m_Gitter.zip\?* csv_Bevoelkerung_100m_Gitter.zip | ||
unzip -o csv_Bevoelkerung_100m_Gitter.zip | ||
unzip -o Zensus2022_Bevoelkerungszahl.zip | ||
|
||
echo ">>> Downloading OpenStreetMap dump for Germany" | ||
wget 'http://download.geofabrik.de/europe/germany-latest.osm.pbf' \ | ||
wget "http://download.geofabrik.de/europe/$REGION-latest.osm.pbf" \ | ||
--timestamping |
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 |
---|---|---|
@@ -1,17 +1,16 @@ | ||
#!/bin/bash -e | ||
set -o pipefail | ||
source env.sh | ||
|
||
echo ">>> Filter raw census data for inhabited cells" | ||
sed -e '/;-1\r$/d; s/[^;]*;//' data/Zensus_Bevoelkerung_100m-Gitter.csv > data/Zensus_Bevoelkerung_100m-Gitter_filtered.csv | ||
|
||
echo ">>> Import Census into PostgreSQL database '$PGDATABASE'" | ||
psql -v ON_ERROR_STOP=1 --single-transaction <<EOF | ||
DROP TABLE IF EXISTS census_germany; | ||
CREATE TABLE census_germany ( | ||
id char(30), | ||
x int8, | ||
y int8, | ||
population int8 | ||
); | ||
\COPY census_germany FROM data/Zensus_Bevoelkerung_100m-Gitter_filtered.csv (FORMAT CSV, DELIMITER ';', NULL '', HEADER) | ||
\COPY census_germany FROM data/Zensus2022_Bevoelkerungszahl_100m-Gitter.csv (FORMAT CSV, DELIMITER ';', NULL '', HEADER) | ||
EOF |
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 |
---|---|---|
@@ -1,26 +1,13 @@ | ||
#!/bin/bash -e | ||
source env.sh | ||
|
||
REGION=germany | ||
if [ data/$REGION-latest.osm.pbf -nt data/$REGION-filtered.osm.pbf ]; then | ||
echo ">>> Filter OSM data" | ||
osmium tags-filter --overwrite data/$REGION-latest.osm.pbf \ | ||
-o data/$REGION-filtered.osm.pbf -e filter_buildings.conf --progress | ||
fi | ||
|
||
echo ">>> Convert OSM dump into O5M format for filtering" | ||
osmconvert data/$REGION-latest.osm.pbf -o=data/$REGION-latest.o5m | ||
echo ">>> Filter OSM data" | ||
osmfilter data/$REGION-latest.o5m \ | ||
--keep="building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="amenity=hospital =nursing_home =prison =school" \ | ||
--keep="(amenity=social_facility and social_facility=nursing_home)" \ | ||
--keep="building:part=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="disused:building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="abandoned:building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="demolished:building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="removed:building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="razed:building=yes =house =residential =apartments =detached =terrace =semidetached_house =static_caravan =bungalow =semi =dormitory =stilt_house =terraced_house =dwelling_house =chalet =summer_cottage =flats =semi-detached =row_house =summer_house =semi_detached =townhouse =houses =farm =hospital =construction" \ | ||
--keep="landuse=residential =farmyard =allotments =brownfield =quarry =construction" \ | ||
--keep="tourism=camp_site =caravan_site" \ | ||
-o=data/$REGION-filtered.o5m | ||
echo ">>> Import filtered OSM data into PostGIS database" | ||
osm2pgsql --create --slim --cache $MEMORY --number-processes 8 \ | ||
--flat-nodes data/nodes.bin --style residential_and_buildings.lua \ | ||
--output flex --proj 3035 data/$REGION-filtered.o5m | ||
rm data/nodes.bin | ||
--flat-nodes data/nodes.bin --drop --style residential_and_buildings.lua \ | ||
--output flex data/$REGION-filtered.osm.pbf |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/building,disused:building,abandoned:building,demolished:building,removed:building,razed:building,building:part | ||
/amenity=hospital,nursing_home,prison,school,social_facility | ||
/landuse=brownfield,quarry,construction,military |
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,50 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
creationTimestamp: "2024-07-08T00:00:00Z" | ||
labels: | ||
app: unmapped-census | ||
name: unmapped-census | ||
spec: | ||
containers: | ||
- name: postgres | ||
image: docker.io/postgis/postgis:16-3.4 | ||
args: | ||
- postgres | ||
- -c | ||
- logging_collector=true | ||
env: | ||
- name: POSTGRES_PASSWORD | ||
value: postgres | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- CAP_MKNOD | ||
- CAP_NET_RAW | ||
- CAP_AUDIT_WRITE | ||
volumeMounts: | ||
- mountPath: /var/lib/postgresql/data | ||
name: postgresql-data | ||
- name: run | ||
image: unmapped_census:latest | ||
command: | ||
- ./run.sh | ||
securityContext: | ||
capabilities: | ||
drop: | ||
- CAP_MKNOD | ||
- CAP_NET_RAW | ||
- CAP_AUDIT_WRITE | ||
volumeMounts: | ||
- mountPath: /app | ||
name: app | ||
volumes: | ||
- hostPath: | ||
path: ./data/postgres | ||
type: Directory | ||
name: postgresql-data | ||
- hostPath: | ||
path: . | ||
type: Directory | ||
name: app | ||
restartPolicy: Never |
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 |
---|---|---|
@@ -1,34 +1,41 @@ | ||
osm2pgsql.srid = 3035 | ||
|
||
local srid = 3035 | ||
local tables = {} | ||
|
||
tables.landuse = osm2pgsql.define_area_table('landuse', { | ||
{ column = 'geom', type = 'geometry' }, | ||
{ column = 'geom', type = 'geometry', projection = srid }, | ||
}) | ||
|
||
tables.building = osm2pgsql.define_area_table('building', { | ||
{ column = 'geom', type = 'geometry' }, | ||
{ column = 'geom', type = 'geometry', projection = srid }, | ||
}) | ||
|
||
create_area = { geom = { create = 'area' } } | ||
|
||
local building_tags = { 'building', 'disused:building', 'abandoned:building', 'demolished:building', 'removed:building', | ||
'razed:building', 'building:part', 'amenity' } | ||
|
||
function osm2pgsql.process_way(object) | ||
if object.tags.landuse then | ||
tables.landuse:add_row(create_area) | ||
tables.landuse:insert({ geom = object.as_polygon():transform(srid) }) | ||
end | ||
if object.tags.building or object.tags['building:part'] then | ||
tables.building:add_row(create_area) | ||
for _, v in ipairs(building_tags) do | ||
if object.tags[v] then | ||
tables.building:insert({ geom = object.as_polygon():transform(srid) }) | ||
break | ||
end | ||
end | ||
end | ||
|
||
function osm2pgsql.process_relation(object) | ||
if object.tags.type == 'multipolygon' and object.tags.landuse then | ||
tables.landuse:add_row(create_area) | ||
tables.landuse:insert({ geom = object.as_multipolygon():transform(srid) }) | ||
end | ||
if object.tags.type == 'multipolygon' and | ||
(object.tags.building or object.tags['building:part']) | ||
then | ||
tables.building:add_row(create_area) | ||
if object.tags.type == 'multipolygon' then | ||
for _, v in ipairs(building_tags) do | ||
if object.tags[v] then | ||
tables.building:insert({ geom = object.as_multipolygon():transform(srid) }) | ||
break | ||
end | ||
end | ||
end | ||
end | ||
|
Oops, something went wrong.