berlin_gelaendemodelle_downloader package

Submodules

berlin_gelaendemodelle_downloader.cli module

berlin_gelaendemodelle_downloader.constant module

berlin_gelaendemodelle_downloader.download module

berlin_gelaendemodelle_downloader.download.download_data(download_path: str, keep_original: bool, compress: int, file_format: tuple)[source]

Download and compress the ground level data of Berlin.

Parameters:
  • download_path (str) – path to download directory
  • keep_original (bool) – indicates to keep the original txt files or not
  • compress (int) – size of square pixels for compression
  • file_format (tuple) – file formats to save the data
Raises:

click.BadParameter – for invalid parameter combinations

berlin_gelaendemodelle_downloader.download.download_zip(zip_url: str) -> (<class 'str'>, <class 'str'>)[source]
Parameters:zip_url (str) – URL to a zip subset of the data
Returns:file name and content of the file that is included in the zip archiv
Return type:(str, list)
Raises:HTTPError – Will be raised if the zip_url responsed a not 200 code

Get list of links for subsets of data.

Returns:list of URLs to the zipped subsets
Return type:list

berlin_gelaendemodelle_downloader.file module

berlin_gelaendemodelle_downloader.file.save_files(download_path: str, file_name: str, original_content: str, data_frame: pandas.core.frame.DataFrame, file_formats: tuple, keep_original: bool) → None[source]

Saves all files that are downloaded or created to the proper directories.

Parameters:
  • download_path (str) – Path to the download directory.
  • file_name (str) – file name.
  • original_content (str) – Original download content.
  • data_frame (DataFrame) – If data were compressed, the corresponding compressed DataFrame or GeoDataFrame.
  • file_formats (tuple) – Formats to save.
  • keep_original (bool) – Flag that indicates whether to save the original files.
berlin_gelaendemodelle_downloader.file.write_file_content_as_txt(download_path: str, file_name: str, file_content: list) → None[source]

Writes the given file_content to the given path as txt file.

Parameters:
  • download_path (str) – directory
  • file_name (str) – file name
  • file_content (list) – list of lines for serialization as file

berlin_gelaendemodelle_downloader.utils module

berlin_gelaendemodelle_downloader.utils.compress_data_frame(data_frame: pandas.core.frame.DataFrame, tile_size: int) → pandas.core.frame.DataFrame[source]

Compress the given DataFrame. Uses windows of size ‘\(tile\ size \times tile\ size\)’ and calculates their mean.

Use convolution algorithm to compress the neighboring tiles. TODO: see documentation to get an intuition about the convolution implementation.

Parameters:
  • data_frame (DataFrame) – Original DataFrame
  • tile_size (int) – window size
Returns:

The compressed pandas.DataFrame

Return type:

DataFrame

berlin_gelaendemodelle_downloader.utils.create_directories(download_path: str, keep_original: bool, compress: int, file_formats: tuple) -> (<class 'str'>, <class 'str'>)[source]

Simple helper function that creates all necessary directories.

Parameters:
  • download_path (str) – download path
  • keep_original (bool) – indicates whether the original directory is necessary or not.
  • compress (int) – compression rate
  • file_formats (tuple) – indicates the file types to save.
Returns:

path for original files, path for compressed files

Return type:

str, str

berlin_gelaendemodelle_downloader.utils.data_frame_2_file_content(data_frame: pandas.core.frame.DataFrame) → list[source]

Converts the given data_frame into a list of lines as file content

Parameters:data_frame – to be serialized
Returns:list of lines for serialization as file
Return type:list
berlin_gelaendemodelle_downloader.utils.data_frame_2_geo_data_frame(data_frame: pandas.core.frame.DataFrame) → geopandas.geodataframe.GeoDataFrame[source]

Creates a GeoDataFrame from the given DataFrame

Parameters:data_frame (DataFrame) – DataFrame that is used to create a GeoDataFrame with geometric information.
Returns:Created GeoDataFrame.
Return type:GeoDataFrame
berlin_gelaendemodelle_downloader.utils.download_2_file_content(download_content: str) → list[source]

Converts the download_content into proper format.

Parameters:download_content (str) – content of download
Returns:list of lines for serialization as file
Return type:list
berlin_gelaendemodelle_downloader.utils.file_content_2_data_frame(file_content: str) → pandas.core.frame.DataFrame[source]

Create a DataFrame with the file_content

Parameters:file_content (str) – content of file
Returns:Content of file as DataFrame
Return type:DataFrame

Module contents