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.
- Automatically read CSV files from the SFSO into dataframes
- Export categorical land use/land cover columns into
- 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)
vaud_ldf = ldf.clip_by_nominatim('Vaud, Switzerland') vaud_ldf.plot('AS09R_4', cmap=sls.noas04_4_cmap, legend=True)
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).
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
- 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)
- Standard nomenclature
NOAS04with 72 base categories that combine information on land cover and land use
- Land cover nomenclature
NOLC04with 27 categories of land cover
- Land use nomenclature
NOLU04with 46 categories of land use
- 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