Skip to main content

Make smoothed maps from a geo layer

Project description

Make smoothed maps in your python environnement

Build Status Version Coveralls

More or less a python port of Stewart method from R SpatialPositon package (https://github.com/Groupe-ElementR/SpatialPosition/).

Allow to set a desired number of class and choose discretization method or directly set some custom breaks values.

Input/output can be a path to a geographic layer (GeoJSON, shp, etc.) or a GeoDataFrame.

Requires:

  • Numpy

  • GeoPandas

  • SciPy

  • Matplotlib

Documentation on the method :

Please refer to https://github.com/Groupe-ElementR/SpatialPosition/ documentation.

Usage example:

One-shot functionnality

>>> result = quick_stewart('nuts3_data.geojson',
                           "pop1999",
                           span=65000,
                           beta=3,
                           resolution=48000,
                           mask='nuts3_data.geojson',
                           nb_class=10,
                           user_defined_breaks=None,
                           output="geojson")

Object-oriented API, allowing to easily redraw contours with new breaks values or new interpolation functionnality

>>> StePot = SmoothStewart('nuts3_data.geojson', "pop1999",
                       span=65000, beta=3,
                       resolution=60000,
                       mask='nuts3_data.geojson')
>>> res = StePot.render(nb_class=8, func_grid="matplotlib",
                        disc_func="jenks", output="GeoDataFrame")
>>> res.plot(cmap="YlOrRd", linewidth=0.1)
png

The long part of the computation is done during the initialization of SmoothStewart instance (i.e. actually computing potentials). Some convenience methods allows to tweak and re-export the few last steps :

Allow to quickly redraw polygons with a new classification method (or with new interpolation functionnality) Availables classification methods are: “equal_interval”, “prog_geom”, “jenks”, “percentiles” and “head-tail-breaks”

>>> StePot.change_interp_grid_shape((164, 112))

>>> res = StePot.render(nb_class=6, func_grid="scipy",
                        disc_func="percentiles", output="GeoDataFrame")

Allow to set custom break values (highly recommended after a first rendering or having take a look at the distibution):

>>> my_breaks = [0, 1697631, 3395263, 5092894, 6790526,
                 8488157, 10185789, 11883420, 13581052]

>>> res = StePot.render(nb_class=6, user_defined_breaks=my_breaks,
                        output="GeoDataFrame")

Installation:

From PyPI :

$ pip install smoomapy

From github :

$ git clone http://github.com/mthh/smoomapy.git
$ cd smoomapy/
$ python setup.py install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smoomapy-0.1.3.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file smoomapy-0.1.3.tar.gz.

File metadata

  • Download URL: smoomapy-0.1.3.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for smoomapy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8d16ba024b6a9f8dd14e05ac5d38cff95b3ecc6bf7e550d7cc6560e8178201b9
MD5 e0cd8b950c294f7d9219231b08dcde27
BLAKE2b-256 fde97104c567a22a9666bd776dc2303620bf3562b33461b06346869c77f92131

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page