Using GeoPandas and MPLLeaflet to render maps

This example will demonstrate using GeoPandas to load and plot some polygons representing the New York City boroughs. Then we'll put it into a Leaflet map right in the notebook using mplleaflet.

Installation

conda install -c conda-forge geopandas
conda install -c conda-forge mplleaflet

It is better to install all the dependencies using the main conda channel first, before installing the above packages from conda-forge.


In [3]:
import os

import geopandas as gpd
import matplotlib.pyplot as plt

import mplleaflet

%matplotlib inline

The following data is downloaded from data.melbourne.vic.gov.au.


In [9]:
df = gpd.read_file('data/geo_export_bbd3984d-4213-4949-8df3-130185e1a6df.shp')

In [14]:
ax = df.plot(figsize=(15,15))



In [15]:
# The display call inserts the html in the IPython notebook.
# An interactive, panable, zoomable map.
mplleaflet.display(fig=ax.figure, crs=df.crs)


Out[15]:

In [ ]: