Module functions.tools.mapping
Functions
def create_mapping_gdenr_to_canton(gdenr_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each canton code to their bfs-nr
Args
gdenr_csv
:pd.DataFrame
- df which includes the spatial statistics and bfsnr
def create_mapping_gdenr_to_gemeindegrösse(gdenr_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each commune size code to their bfs-nr
Args
gdenr_csv
:pd.DataFrame
- df which includes the spatial statistics and bfsnr
def create_mapping_gdenr_to_grossregion(gdenr_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each metropolitan area code to their bfs-nr
Args
gdenr_csv
:pd.DataFrame
- df which includes the spatial statistics and bfsnr
def create_mapping_gdenr_to_siedlungsart(gdenr_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each settlement type code to their bfs-nr
Args
gdenr_csv
:pd.DataFrame
- df which includes the spatial statistics and bfsnr
def create_mapping_gdenr_to_sprachregion(gdenr_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each language region code to their bfs-nr
Args
gdenr_csv
:pd.DataFrame
- df which includes the spatial statistics and bfsnr
def create_mapping_plz_to_gdenr(plz_csv: pandas.core.frame.DataFrame)
-
creates a json which maps each postal code to their bfs-nr
Args
plz_csv
:pd.DataFrame
- df with the mapped bfsnr <–> postal codes
def get_mapping_bfs_csv(url: str = 'https://sms.bfs.admin.ch/WcfBFSSpecificService.svc/AnonymousRest/communes/levels?useBfsCode=true&labelLanguages=de')
-
gets a file for from bfs with spatial statistical information
Args
url
:str
, optional- url to get file from.
Raises
Exception
- exception if any format issues arise
def get_mapping_plz_csv(zip_url: str = 'https://download.geonames.org/export/zip/CH.zip')
-
gets postal code - bfs nr mapping form geonames.org, unzips zip file and saves csv file
Args
zip_url
:str
, optional- url to download from. Defaults to 'https://download.geonames.org/export/zip/CH.zip'.
Raises
Exception
- exception if either zip is not in download folder or any format issues arise