zensus¶
The central module containing all code dealing with importing Zensus data.
-
class
ZensusMiscellaneous
(dependencies)[source]¶ Bases:
egon.data.datasets.Dataset
-
class
ZensusPopulation
(dependencies)[source]¶ Bases:
egon.data.datasets.Dataset
-
adjust_zensus_misc
()[source]¶ Delete unpopulated cells in zensus-households, -buildings and -apartments
Some unpopulated zensus cells are listed in: - egon_destatis_zensus_household_per_ha - egon_destatis_zensus_building_per_ha - egon_destatis_zensus_apartment_per_ha
This can be caused by missing population information due to privacy or other special cases (e.g. holiday homes are listed as buildings but are not permanently populated.) In the following tasks of egon-data, only data of populated cells is used.
Returns: None.
-
create_combined_zensus_table
()[source]¶ Create combined table with buildings, apartments and population per cell
Only apartment and building data with acceptable data quality (quantity_q<2) is used, all other data is dropped. For more details on data quality see Zensus docs: https://www.zensus2011.de/DE/Home/Aktuelles/DemografischeGrunddaten.html
If there’s no data on buildings or apartments for a certain cell, the value for building_count resp. apartment_count contains NULL.
-
download_and_check
(url, target_file, max_iteration=5)[source]¶ Download file from url (http) if it doesn’t exist and check afterwards. If bad zip remove file and re-download. Repeat until file is fine or reached maximum iterations.
-
filter_zensus_misc
(filename, dataset)[source]¶ This block filters lines in the source CSV file and copies the appropriate ones to the destination based on grid_id values.
Parameters: - filename (str) – Path to input csv-file
- dataset (str, optional) – Toggles between production (dataset=’Everything’) and test mode e.g. (dataset=’Schleswig-Holstein’). In production mode, data covering entire Germany is used. In the test mode a subset of this data is used for testing the workflow.
Returns: str – Path to output csv-file
-
filter_zensus_population
(filename, dataset)[source]¶ This block filters lines in the source CSV file and copies the appropriate ones to the destination based on geometry.
Parameters: - filename (str) – Path to input csv-file
- dataset (str, optional) – Toggles between production (dataset=’Everything’) and test mode e.g. (dataset=’Schleswig-Holstein’). In production mode, data covering entire Germany is used. In the test mode a subset of this data is used for testing the workflow.
Returns: str – Path to output csv-file
-
select_geom
()[source]¶ Select the union of the geometries of Schleswig-Holstein from the database, convert their projection to the one used in the CSV file, output the result to stdout as a GeoJSON string and read it into a prepared shape for filtering.
-
target
(source, dataset)[source]¶ Generate the target path corresponding to a source path.
Parameters: dataset (str) – Toggles between production (dataset=’Everything’) and test mode e.g. (dataset=’Schleswig-Holstein’). In production mode, data covering entire Germany is used. In the test mode a subset of this data is used for testing the workflow. Returns: Path – Path to target csv-file