/folium

Python Data. Leaflet.js Maps.

Primary LanguagePythonMIT LicenseMIT

image

image

image

image

Folium

Folium

Python Data. Leaflet.js Maps.

Folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js library. Manipulate your data in Python, then visualize it in on a Leaflet map via Folium.

Concept

Folium makes it easy to visualize data that's been manipulated in Python on an interactive Leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing Vincent/Vega visualizations as markers on the map.

The library has a number of built-in tilesets from OpenStreetMap, MapQuest Open, MapQuest Open Aerial, Mapbox, and Stamen, and supports custom tilesets with Mapbox or Cloudmade API keys. Folium supports both GeoJSON and TopoJSON overlays, as well as the binding of data to those overlays to create choropleth maps with color-brewer color schemes.

Installation

Getting Started

To create a base map, simply pass your starting coordinates to Folium:

baseOSM

Folium defaults to OpenStreetMap tiles, but Stamen Terrain, Stamen Toner,
Mapbox Bright, and Mapbox Control room tiles are built in:

stamen

Folium also supports Cloudmade and Mapbox custom tilesets- simply pass your key to the API_key keyword:

Lastly, Folium supports passing any Leaflet.js compatible custom tileset:

Markers

Folium supports the plotting of numerous marker types, starting with a simple Leaflet
style location marker with popup text:

hood

Live example

Folium supports colors and marker icon types (from bootstrap)

iconTest

Folium also supports circle-style markers, with custom size and color:

circle

Live example

Folium has a convenience function to enable lat/lng popovers:

latlng

Live example

Click-for-marker functionality will allow for on-the-fly placement of markers:

waypoints

Live example

Folium also supports the Polygon marker set from the Leaflet-DVF:

polygon

Live example

Vincent/Vega Markers

Folium enables passing vincent visualizations to any marker type, with the visualization as the popover:

vincent

Live example

GeoJSON/TopoJSON Overlays

Both GeoJSON and TopoJSON layers can be passed to the map as an overlay, and multiple layers can be visualized on the same map:

ice

Live example

Choropleth Maps

Folium allows for the binding of data between Pandas DataFrames/Series and Geo/TopoJSON geometries. Color Brewer sequential color schemes are built-in to the library, and can be passed to quickly visualize different combinations:

states_1

Live example

Folium creates the legend on the upper right based on a D3 threshold scale, and makes the best-guess at values via quantiles. Passing your own threshold values is simple:

states_2

Live example

By binding data via the Pandas DataFrame, different datasets can be quickly visualized. In the following example, the df DataFrame contains six columns with different economic data, a few of which we will visualize:

counties_1

Live example

counties_2

Live example

counties_3

Live example

Dependencies

Jinja2

Pandas (Map Data Binding only)

Numpy (Map Data Binding only)

Vincent (Map Data Binding only)

Status

Beta

Docs

https://folium.readthedocs.org/