Skip to content

Compute continous cartograms (anamorphic maps) from geopandas.GeoDataFrames

License

Notifications You must be signed in to change notification settings

austromorph/python-cartogram

Repository files navigation

Compute continous cartograms (anamorphic maps)

This is a Python package to compute cartograms from geopandas.GeoDataFrames, using the algorithm presented in Dougenik et al. (1985). It is the ‘sister project’ and Python implementation of our QGIS plugin which continues to be available.

Installation

cartogram is available from the PyPi package repository, install it, for instance, using pip:

pip install cartogram

Quick start

Input data

You will need a polygon data set in any format readable by geopandas that features a numeric attribute column to use as the relative target values to base the cartogram distortion on.

If you want to have a quick try-out, see the population data for Austrian provinces in the tests/data directory of this repository.

Cartogram creation

import cartogram
import geopandas

df = geopandas.read_file("input-data.gpkg")
c = cartogram.Cartogram(df, column="population")

c.to_file("output-data.gpkg")

Documentation

Find more detailed examples and an API reference at https://python-cartogram.readthedocs.io/.

About

Compute continous cartograms (anamorphic maps) from geopandas.GeoDataFrames

Resources

License

Stars

Watchers

Forks

Languages