vg250

The central module containing all code dealing with VG250 data.

This module either directly contains the code dealing with importing VG250 data, or it re-exports everything needed to handle it. Please refrain from importing code from any modules below this one, because it might lead to unwanted behaviour.

If you have to import code from a module below this one because the code isn’t exported from this module, please file a bug, so we can fix this.

class Vg250(dependencies)[source]

Bases: Dataset

file_table_map = {'VG250_GEM.shp': 'vg250_gem', 'VG250_KRS.shp': 'vg250_krs', 'VG250_LAN.shp': 'vg250_lan', 'VG250_RBZ.shp': 'vg250_rbz', 'VG250_STA.shp': 'vg250_sta', 'VG250_VWG.shp': 'vg250_vwg'}

Obtains and processes VG250 data and writes it to database.

Original data is downloaded using download_files() function and written to database using to_postgres() function.

Dependencies

No dependencies

Resulting tables
filename = 'https://daten.gdz.bkg.bund.de/produkte/vg/vg250_ebenen_0101/2020/vg250_01-01.geo84.shape.ebenen.zip'
name: str = 'VG250'
sources: DatasetSources = DatasetSources(tables={}, files={'vg250_zip': 'vg250/vg250_01-01.geo84.shape.ebenen.zip'}, urls={'vg250_zip': 'https://daten.gdz.bkg.bund.de/produkte/vg/vg250_ebenen_0101/2020/vg250_01-01.geo84.shape.ebenen.zip'})

The sources used by the datasets. Could be tables, files and urls

targets: DatasetTargets = DatasetTargets(tables={'vg250_sta': 'boundaries.vg250_sta', 'vg250_lan': 'boundaries.vg250_lan', 'vg250_rbz': 'boundaries.vg250_rbz', 'vg250_krs': 'boundaries.vg250_krs', 'vg250_vwg': 'boundaries.vg250_vwg', 'vg250_gem': 'boundaries.vg250_gem'}, files={'vg250_zip': 'vg250/vg250_01-01.geo84.shape.ebenen.zip'})

The targets created by the datasets. Could be tables and files

version: str = 'https://daten.gdz.bkg.bund.de/produkte/vg/vg250_ebenen_0101/2020/vg250_01-01.geo84.shape.ebenen.zip-0.0.9'

The Dataset’s version. Can be anything from a simple semantic versioning string like “2.1.3”, to a more complex string, like for example “2021-01-01.schleswig-holstein.0” for OpenStreetMap data. Note that the latter encodes the Dataset’s date, region and a sequential number in case the data changes without the date or region changing, for example due to implementation changes.

add_metadata()[source]

Writes metadata JSON string into table comment.

cleaning_and_preperation()[source]

Creates tables and MViews with cleaned and corrected geometry data.

The following table is created:
  • boundaries.vg250_gem_clean where municipalities (Gemeinden) that are fragmented are cleaned from ringholes

The following MViews are created:
  • boundaries.vg250_gem_hole

  • boundaries.vg250_gem_valid

  • boundaries.vg250_krs_area

  • boundaries.vg250_lan_union

  • boundaries.vg250_sta_bbox

  • boundaries.vg250_sta_invalid_geometry

  • boundaries.vg250_sta_tiny_buffer

  • boundaries.vg250_sta_union

download_files()[source]

Download VG250 (Verwaltungsgebiete) shape files.

Data is downloaded from source specified in datasets.yml in section vg250/original_data/source/url and saved to file specified in vg250/original_data/target/file.

nuts_mview()[source]

Creates MView boundaries.vg250_lan_nuts_id.

to_postgres()[source]

Writes original VG250 data to database.

Creates schema boundaries if it does not yet exist. Newly creates all tables specified as keys in datasets.yml in section vg250/processed/file_table_map.

vg250_metadata_resources_fields()[source]

Returns metadata string for VG250 tables.