Skip to content

Commit 2a2dc9a

Browse files
committed
new docs
1 parent 319c799 commit 2a2dc9a

29 files changed

+316
-1613
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ script:
6868
- if [[ $TEST_TARGET == 'docs' ]]; then
6969
set -e ;
7070
conda install doctr ;
71+
cp examples/Quickstart.ipynb docs/quickstart.ipynb ;
7172
pushd docs ;
72-
make clean html ;
73+
make clean html linkcheck ;
7374
popd ;
74-
doctr deploy --sync --no-require-master --built-docs docs/_build/html "docs-$TRAVIS_BRANCH";
75+
python -m doctr deploy --sync .;
76+
python -m doctr deploy --sync --no-require-master --built-docs docs/_build/html "docs-$TRAVIS_BRANCH" ;
7577
fi
78+
79+
doctr:
80+
require-master: true
81+
sync: False

README.rst

Lines changed: 13 additions & 340 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,10 @@ Folium
1515
Python Data. Leaflet.js Maps.
1616
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1717

18-
Folium builds on the data wrangling strengths of the Python ecosystem
19-
and the mapping strengths of the Leaflet.js library. Manipulate your
20-
data in Python, then visualize it in on a Leaflet map via Folium.
21-
22-
Concept
23-
-------
24-
25-
Folium makes it easy to visualize data that's been manipulated in Python
26-
on an interactive Leaflet map. It enables both the binding of data to a
27-
map for choropleth visualizations as well as passing Vincent/Vega
28-
visualizations as markers on the map.
29-
30-
The library has a number of built-in tilesets from OpenStreetMap,
31-
Mapbox, and Stamen, and supports custom tilesets with Mapbox
32-
or Cloudmade API keys. Folium supports both
33-
GeoJSON and TopoJSON overlays, as well as the binding of data to those
34-
overlays to create choropleth maps with color-brewer color schemes.
18+
`folium` builds on the data wrangling strengths of the Python ecosystem
19+
and the mapping strengths of the Leaflet.js library.
20+
Manipulate your data in Python,
21+
then visualize it in on a Leaflet map via `folium`.
3522

3623
Installation
3724
------------
@@ -40,335 +27,21 @@ Installation
4027
4128
$ pip install folium
4229
43-
Getting Started
44-
---------------
45-
46-
You can find most of the following examples in the notebook **folium_examples.ipynb** in the examples folder.
47-
48-
To create a base map, simply pass your starting coordinates to Folium:
49-
50-
.. code:: python
51-
52-
import folium
53-
map_osm = folium.Map(location=[45.5236, -122.6750])
54-
map_osm.save('osm.html')
55-
56-
|baseOSM|
57-
58-
| Folium defaults to OpenStreetMap tiles, but Stamen Terrain, Stamen
59-
Toner,
60-
| Mapbox Bright, and Mapbox Control room tiles are built in:
61-
62-
.. code:: python
63-
64-
stamen = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
65-
zoom_start=13)
66-
stamen.save('stamen_toner.html')
30+
or
6731

68-
|stamen|
69-
70-
Folium also supports Cloudmade and Mapbox custom tilesets- simply pass
71-
your key to the ``API_key`` keyword:
72-
73-
.. code:: python
32+
.. code:: bash
7433
75-
custom = folium.Map(location=[45.5236, -122.6750], tiles='Mapbox',
76-
API_key='wrobstory.map-12345678')
34+
$ conda install folium
7735
78-
Lastly, Folium supports passing any Leaflet.js compatible custom
79-
tileset:
36+
Documentation
37+
-------------
8038

81-
.. code:: python
39+
http://python-visualization.github.io/folium/docs-master/
8240

83-
tileset = r'http://{s}.tiles.yourtiles.com/{z}/{x}/{y}.png'
84-
map = folium.Map(location=[45.372, -121.6972], zoom_start=12,
85-
tiles=tileset, attr='My Data Attribution')
8641

87-
Markers
42+
Gallery
8843
-------
8944

90-
| Folium supports the plotting of numerous marker types, starting with a
91-
simple Leaflet
92-
| style location marker with popup text:
93-
94-
.. code:: python
95-
96-
map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,
97-
tiles='Stamen Terrain')
98-
folium.Marker([45.3288, -121.6625], popup='Mt. Hood Meadows').add_to(map_1)
99-
folium.Marker([45.3311, -121.7113], popup='Timberline Lodge').add_to(map_1)
100-
map_1.save('mthood.html')
101-
102-
|hood|
103-
104-
`Live example <http://bl.ocks.org/wrobstory/5609718>`__
105-
106-
Folium supports colors and marker icon types (from bootstrap)
107-
108-
.. code:: python
109-
110-
map_1 = folium.Map(location=[45.372, -121.6972], zoom_start=12,tiles='Stamen Terrain')
111-
folium.Marker([45.3288, -121.6625], popup='Mt. Hood Meadows',
112-
icon = folium.Icon(icon = 'cloud')).add_to(map_1)
113-
folium.Marker([45.3311, -121.7113], popup='Timberline Lodge',
114-
icon = folium.Icon(color ='green')).add_to(map_1)
115-
folium.Marker([45.3300, -121.6823], popup='Some Other Location',
116-
icon = folium.Icon(color ='red')).add_to(map_1)
117-
map_1.save('iconTest.html')
118-
119-
.. iconTest is broken, TODO: Link to the notebook directly.
120-
121-
Folium also supports circle-style markers, with custom size and color:
122-
123-
.. code:: python
124-
125-
map_2 = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
126-
zoom_start=13)
127-
folium.Marker(location=[45.5244, -122.6699], popup='The Waterfront').add_to(map_2)
128-
folium.CircleMarker(location=[45.5215, -122.6261], radius=50,
129-
popup='Laurelhurst Park', color='#3186cc',
130-
fill_color='#3186cc').add_to(map_2)
131-
map_2.save('portland.html')
132-
133-
|circle|
134-
135-
`Live example <http://bl.ocks.org/wrobstory/5609747>`__
136-
137-
Folium has a convenience function to enable lat/lng popovers:
138-
139-
.. code:: python
140-
141-
map_3 = folium.Map(location=[46.1991, -122.1889], tiles='Stamen Terrain',
142-
zoom_start=13)
143-
folium.LatLngPopup().add_to(map_3)
144-
map_3.save('sthelens.html')
145-
146-
|latlng|
147-
148-
`Live example <http://bl.ocks.org/wrobstory/5609756>`__
149-
150-
Click-for-marker functionality will allow for on-the-fly placement of
151-
markers:
152-
153-
.. code:: python
154-
155-
map_4 = folium.Map(location=[46.8527, -121.7649], tiles='Stamen Terrain',
156-
zoom_start=13)
157-
folium.Marker(location=[46.8354, -121.7325], popup='Camp Muir').add_to(map_4)
158-
folium.ClickForMarker(popup='Waypoint').add_to(map_4)
159-
map_4.save('mtrainier.html')
160-
161-
|waypoints|
162-
163-
`Live example <http://bl.ocks.org/wrobstory/5609762>`__
164-
165-
Folium also supports the Polygon marker set from the
166-
`Leaflet-DVF <https://github.com/humangeo/leaflet-dvf>`__:
167-
168-
.. code:: python
169-
170-
map_5 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
171-
folium.RegularPolygonMarker(location=[45.5012, -122.6655], popup='Ross Island Bridge',
172-
fill_color='#132b5e', number_of_sides=3, radius=10).add_to(map_5)
173-
folium.RegularPolygonMarker(location=[45.5132, -122.6708], popup='Hawthorne Bridge',
174-
fill_color='#45647d', number_of_sides=4, radius=10).add_to(map_5)
175-
folium.RegularPolygonMarker(location=[45.5275, -122.6692], popup='Steel Bridge',
176-
fill_color='#769d96', number_of_sides=6, radius=10).add_to(map_5)
177-
folium.RegularPolygonMarker(location=[45.5318, -122.6745], popup='Broadway Bridge',
178-
fill_color='#769d96', number_of_sides=8, radius=10).add_to(map_5)
179-
map_5.save('bridges.html')
180-
181-
|polygon|
182-
183-
`Live example <http://bl.ocks.org/wrobstory/5609786>`__
184-
185-
Vincent/Vega Markers
186-
--------------------
187-
188-
Folium enables passing
189-
`vincent <https://github.com/wrobstory/vincent>`__ visualizations to any
190-
marker type, with the visualization as the popover:
191-
192-
.. code:: python
193-
194-
buoy_map = folium.Map(location=[46.3014, -123.7390], zoom_start=7,
195-
tiles='Stamen Terrain')
196-
popup1 = folium.Popup(max_width=800,
197-
).add_child(folium.Vega(vis1, width=500, height=250))
198-
folium.RegularPolygonMarker([47.3489, -124.708],
199-
fill_color='#43d9de', radius=12, popup=popup1).add_to(buoy_map)
200-
popup2 = folium.Popup(max_width=800,
201-
).add_child(folium.Vega(vis2, width=500, height=250))
202-
folium.RegularPolygonMarker([44.639, -124.5339],
203-
fill_color='#43d9de', radius=12, popup=popup2).add_to(buoy_map)
204-
popup3 = folium.Popup(max_width=800,
205-
).add_child(folium.Vega(vis3, width=500, height=250))
206-
folium.RegularPolygonMarker([46.216, -124.1280],
207-
fill_color='#43d9de', radius=12, popup=popup3).add_to(buoy_map)
208-
buoy_map.save('NOAA_buoys.html')
209-
210-
|vincent|
211-
212-
`Live example <http://bl.ocks.org/wrobstory/5609803>`__
213-
214-
GeoJSON/TopoJSON Overlays
215-
-------------------------
216-
217-
Both GeoJSON and TopoJSON layers can be passed to the map as an overlay,
218-
and multiple layers can be visualized on the same map:
219-
220-
.. code:: python
221-
222-
geo_path = r'data/antarctic_ice_edge.json'
223-
topo_path = r'data/antarctic_ice_shelf_topo.json'
224-
225-
ice_map = folium.Map(location=[-59.1759, -11.6016],
226-
tiles='Mapbox Bright', zoom_start=2)
227-
ice_map.choropleth(geo_path=geo_path)
228-
ice_map.choropleth(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
229-
ice_map.save('ice_map.html')
230-
231-
|ice|
232-
233-
`Live example <http://bl.ocks.org/wrobstory/5609811>`__
234-
235-
Choropleth Maps
236-
---------------
237-
238-
Folium allows for the binding of data between Pandas DataFrames/Series
239-
and Geo/TopoJSON geometries. `Color Brewer <http://colorbrewer2.org/>`__
240-
sequential color schemes are built-in to the library, and can be passed
241-
to quickly visualize different combinations:
242-
243-
.. code:: python
244-
245-
import folium
246-
import pandas as pd
247-
248-
state_geo = r'data/us-states.json'
249-
state_unemployment = r'data/US_Unemployment_Oct2012.csv'
250-
251-
state_data = pd.read_csv(state_unemployment)
252-
253-
#Let Folium determine the scale
254-
map = folium.Map(location=[48, -102], zoom_start=3)
255-
map.choropleth(geo_path=state_geo, data=state_data,
256-
columns=['State', 'Unemployment'],
257-
key_on='feature.id',
258-
fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
259-
legend_name='Unemployment Rate (%)')
260-
map.save('us_states.html')
261-
262-
|states_1|
263-
264-
`Live example <http://bl.ocks.org/wrobstory/5609830>`__
265-
266-
Folium creates the legend on the upper right based on a D3 threshold
267-
scale, and makes the best-guess at values via quantiles. Passing your
268-
own threshold values is simple:
269-
270-
.. code:: python
271-
272-
map.choropleth(geo_path=state_geo, data=state_data,
273-
columns=['State', 'Unemployment'],
274-
threshold_scale=[5, 6, 7, 8, 9, 10],
275-
key_on='feature.id',
276-
fill_color='BuPu', fill_opacity=0.7, line_opacity=0.5,
277-
legend_name='Unemployment Rate (%)',
278-
reset=True)
279-
map.save('us_states.html')
280-
281-
|states_2|
282-
283-
`Live example <http://bl.ocks.org/wrobstory/5609856>`__
284-
285-
By binding data via the Pandas DataFrame, different datasets can be
286-
quickly visualized. In the following example, the ``df`` DataFrame
287-
contains six columns with different economic data, a few of which we
288-
will visualize:
289-
290-
.. code:: python
291-
292-
#Number of employed with auto scale
293-
map_1 = folium.Map(location=[48, -102], zoom_start=3)
294-
map_1.choropleth(geo_path=county_geo, data_out='data1.json', data=df,
295-
columns=['GEO_ID', 'Employed_2011'],
296-
key_on='feature.id',
297-
fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.3,
298-
topojson='objects.us_counties_20m')
299-
map_1.save('map_1.html')
300-
301-
|counties_1|
302-
303-
`Live example <http://bl.ocks.org/wrobstory/5609889>`__
304-
305-
.. code:: python
306-
307-
#Unemployment with custom defined scale
308-
map_2 = folium.Map(location=[40, -99], zoom_start=4)
309-
map_2.choropleth(geo_path=county_geo, data_out='data2.json', data=df,
310-
columns=['GEO_ID', 'Unemployment_rate_2011'],
311-
key_on='feature.id',
312-
threshold_scale=[0, 5, 7, 9, 11, 13],
313-
fill_color='YlGnBu', line_opacity=0.3,
314-
legend_name='Unemployment Rate 2011 (%)',
315-
topojson='objects.us_counties_20m')
316-
map_2.save('map_2.html')
317-
318-
|counties_2|
319-
320-
`Live example <http://bl.ocks.org/wrobstory/5609934>`__
321-
322-
.. code:: python
323-
324-
#Median Household income
325-
map_3 = folium.Map(location=[40, -99], zoom_start=4)
326-
map_3.choropleth(geo_path=county_geo, data_out='data3.json', data=df,
327-
columns=['GEO_ID', 'Median_Household_Income_2011'],
328-
key_on='feature.id',
329-
fill_color='PuRd', line_opacity=0.3,
330-
legend_name='Median Household Income 2011 ($)',
331-
topojson='objects.us_counties_20m')
332-
map_3.save('map_3.html')
333-
334-
|counties_3|
335-
336-
`Live example <http://bl.ocks.org/wrobstory/5609959>`__
337-
338-
Dependencies
339-
------------
340-
341-
Jinja2
342-
343-
Pandas (Map Data Binding only)
344-
345-
Numpy (Map Data Binding only)
346-
347-
Vincent (Map Data Binding only)
348-
349-
Status
350-
------
351-
352-
Beta
353-
354-
Docs
355-
----
356-
357-
https://folium.readthedocs.org/
45+
http://python-visualization.github.io/folium/docs-master/
35846

359-
.. |Folium| image:: http://farm3.staticflickr.com/2860/8754661081_c40e5a214c_o.jpg
360-
.. |baseOSM| image:: http://farm6.staticflickr.com/5334/8754817259_de071db265_c.jpg
361-
.. |stamen| image:: http://farm3.staticflickr.com/2883/8755937912_1d9ef78118_c.jpg
362-
.. |hood| image:: http://farm4.staticflickr.com/3666/8755937936_d7efbc6dee_c.jpg
363-
.. |iconTest| image:: http://cl.ly/image/2b0l1K0v370P/icon_test.png
364-
.. |circle| image:: http://farm9.staticflickr.com/8280/8755938394_9f491ef79f_c.jpg
365-
.. |latlng| image:: http://farm4.staticflickr.com/3698/8755938152_14bc024bde_c.jpg
366-
.. |waypoints| image:: http://farm6.staticflickr.com/5343/8754817433_2ecde65790_c.jpg
367-
.. |polygon| image:: http://farm8.staticflickr.com/7405/8754817131_24285bff5f_c.jpg
368-
.. |vincent| image:: http://farm4.staticflickr.com/3699/8754817119_4a14ebc3fe_c.jpg
369-
.. |ice| image:: http://farm8.staticflickr.com/7335/8754817253_f32155f902_c.jpg
370-
.. |states_1| image:: http://farm3.staticflickr.com/2837/8755937872_ed5ec8e854_c.jpg
371-
.. |states_2| image:: http://farm9.staticflickr.com/8542/8754816951_752b8a7867_c.jpg
372-
.. |counties_1| image:: http://farm4.staticflickr.com/3792/8755938318_bc82a81c64_c.jpg
373-
.. |counties_2| image:: http://farm9.staticflickr.com/8140/8754817355_2bfea43ff5_c.jpg
374-
.. |counties_3| image:: http://farm4.staticflickr.com/3755/8755938218_06fdc51d40_c.jpg
47+
.. |Folium| image:: http://python-visualization.github.io/folium/docs-master/_images/folium_logo.jpg

0 commit comments

Comments
 (0)