Skip to content
Python tools for preprocessing geodata from the Swiss Federal Statistical Office
Python TeX
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github [ci skip] added contributing guide and github issue template Jul 10, 2019
docs [ci skip] added target audience and refs to literature applications Jul 14, 2019
examples [ci skip] moved overview notebook from separate repo to examples dir Jul 18, 2019
paper [ci skip] final corrections to the paper Sep 12, 2019
swisslandstats [ci skip] Bump version: 0.7.1 → 0.7.2 Sep 5, 2019
tests default lv95 (instead of lv03) Jul 9, 2019
.bumpversion.cfg [ci skip] Bump version: 0.7.1 → 0.7.2 Sep 5, 2019
.gitignore initial commit; yapf configuration, basic class and methods; README Jul 9, 2019
.readthedocs.yml added docs + readthedocs config + readme badge Jul 9, 2019
.travis.yml simplified travis conda env Jul 9, 2019
CHANGELOG.md [ci skip] updated CHANGELOG Sep 5, 2019
CONTRIBUTING.md [ci skip] added contributing guide and github issue template Jul 10, 2019
LICENSE.txt first release Jul 9, 2019
MANIFEST.in fix: included requirements in MANIFEST Jul 9, 2019
README.md [ci skip] added Zenodo badge Sep 5, 2019
environment.yml [ci skip] moved overview notebook from separate repo to examples dir Jul 18, 2019
requirements-dev.txt added docs + readthedocs config + readme badge Jul 9, 2019
requirements-geo.txt geo requirements in a dedicated file Jul 9, 2019
requirements.txt specified lowest versions in requirements Jul 9, 2019
setup.cfg updated versioning/deployment config Jul 9, 2019
setup.py [ci skip] Bump version: 0.7.1 → 0.7.2 Sep 5, 2019

README.md

PyPI version fury.io Documentation Status Build Status Coverage Status GitHub license Binder status DOI

swisslandstats-geopy

Extended pandas-like interface for the Swiss Land Statistics datasets from the Swiss Federal Statistical Office (SFSO) (link in French).

Citation: Bosch M. 2019. "swisslandstats-geopy: Python tools for the land statistics datasets from the Swiss Federal Statistical Office". The Journal Open Source Software 4(40), 1511. https://doi.org/10.21105.joss.01511

The Swiss Land Statistics inventory by the SFSO is stored in a relational database format which allows storing the different survey periods into a single CSV file, nevertheless, libraries to process geographical raster data aree rarely capable of processing such format. Therefore, the aim of swisslandstats-geopy is to provide an extended pandas DataFrame interface to such inventory (see the "Features" section below).

The target audience of swisslandstats-geopy is researchers and developers in environmental sciences and GIS, who intend to produce repeatable and reproducible computational workflows that make use of the land use/land cover inventory provided by the SFSO.

Features

  • Automatically read CSV files from the SFSO into dataframes
  • Export categorical land use/land cover columns into numpy arrays and GeoTIFF files
  • Clip dataframes by vector geometries
  • Plot categorical land use/land cover information
import swisslandstats as sls

ldf = sls.read_csv('data/AREA_NOAS04_72_171129.csv')
ldf.plot('AS09R_4', cmap=sls.noas04_4_cmap, legend=True)

landstats

vaud_ldf = ldf.clip_by_nominatim('Vaud, Switzerland')
vaud_ldf.plot('AS09R_4', cmap=sls.noas04_4_cmap, legend=True)

landstats-vaud

See the example notebook for a more thorough overview (or click the Binder badge above to execute it interactively in your browser).

Examples of applications of the library in the academic literature include:

  • The assessment of the carbon sequestration for the canton of Vaud (see the dedicated GitHub repository with the materials necessary to reproduce the results)
  • The evaluation of the spatio-temporal patterns of LULC change in the urban agglomerations of Zurich, Bern and Lausanne (see the dedicated GitHub repository with the materials necessary to reproduce the results).

Installation

If you want to be able to clip dataframes by vector geometries, you will need geopandas (and osmnx to clip dataframes from place names e.g., "Zurich, Switzerland"). The easiest way to install such requirements is via conda as in:

conda install -c conda-forge geopandas osmnx

Then you can install swisslandstats-geopy via pip as in:

pip install swisslandstats-geopy

Important notes:

  • The cythonized geopandas can give you vast speed-ups when clipping dataframes e.g., 32.7 ms instead of 51.8 s (x1584) to clip by the dataframe by canton of Vaud. You might install it as in:
# install the cythonized geopandas
conda install -c conda-forge/label/dev geopandas

However, the cythonized geopandas is not production code yet. If other libraries of your environment depend on geopandas, it might be better to install its (slower) stable version as in conda install -c conda-forge geopandas.

  • Depending on your environment, you might get an error while loading shared libraries: libncurses.so.6. You might solve it by conda install -c conda-forge ncurses

Description of the datasets

More information can be found in the Swiss Federal Statistical Office page (in German and French)

TODO

  • Add missing colormaps
    • Automatically assign columns to cmaps when plotting
  • Exceptions for no land use/land cover columns
  • Cache colum ndarrays as class attributes?
  • Implement methods to merge DataFrames from multiple csv files
  • Conda recipe
You can’t perform that action at this time.