Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Convert matplotlib contour plots to geojson

Project description

# geojsoncontour
[![Build Status](]( [![PyPI version](]( [![Coverage Status](](
A Python 3 module to convert matplotlib contour plots to geojson. Supports both contour and contourf plots.

Designed to show geographical [contour plots](,
created with [matplotlib/pyplot](, as vector layer on interactive slippy maps like [OpenLayers]( and [Leaflet](

Demo project that uses geojsoncontour: [](

![geojson contour demo usage](

## Installation
Install with pip,
$ pip install geojsoncontour

## Usage

Use `contour_to_geojson` to create a geojson with contour lines from a `matplotlib.contour` plot (not filled).
Use `contourf_to_geojson` to create a geojson with filled contours from a `matplotlib.contourf` plot.

### Contour plot to geojson
import numpy
import matplotlib.pyplot as plt
import geojsoncontour

# Create contour data lon_range, lat_range, Z
<your code here>

# Create a contour plot plot from grid (lat, lon) data
figure = plt.figure()
ax = figure.add_subplot(111)
contour = ax.contour(lon_range, lat_range, Z,

# Convert matplotlib contour to geojson
geojson = geojsoncontour.contour_to_geojson(
For filled contour plots (`matplotlib.contourf`) use `contourf_to_geojson`.
See [](examples/ and [](examples/ for simple but complete examples.

### Show the geojson on a map
An easy way to show the generated geojson on a map is the online geojson renderer [](

### Style properties
Stroke color and width are set as geojson properties following

### Create geojson tiles
Try [geojson-vt]( or [tippecanoe]( if performance is an issue and you need to tile your geojson contours.

## Tests

Run all tests,
python -m unittest discover

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
geojsoncontour-0.3.0-py3-none-any.whl (8.2 kB) Copy SHA256 hash SHA256 Wheel py3 Apr 6, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page