Skip to content

Commit a52e6d7

Browse files
authored
Merge pull request #457 from glfharris/master
Removed deprecated methods from examples and code snippets
2 parents 6ab5397 + 987ca93 commit a52e6d7

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

README.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ To create a base map, simply pass your starting coordinates to Folium:
4949
5050
import folium
5151
map_osm = folium.Map(location=[45.5236, -122.6750])
52-
map_osm.create_map(path='osm.html')
52+
map_osm.save('osm.html')
5353
5454
|baseOSM|
5555

@@ -61,7 +61,7 @@ To create a base map, simply pass your starting coordinates to Folium:
6161
6262
stamen = folium.Map(location=[45.5236, -122.6750], tiles='Stamen Toner',
6363
zoom_start=13)
64-
stamen.create_map(path='stamen_toner.html')
64+
stamen.save('stamen_toner.html')
6565
6666
|stamen|
6767

@@ -95,7 +95,7 @@ Markers
9595
tiles='Stamen Terrain')
9696
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows')
9797
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge')
98-
map_1.create_map(path='mthood.html')
98+
map_1.save('mthood.html')
9999
100100
|hood|
101101

@@ -109,7 +109,7 @@ Folium supports colors and marker icon types (from bootstrap)
109109
map_1.simple_marker([45.3288, -121.6625], popup='Mt. Hood Meadows',marker_icon='cloud')
110110
map_1.simple_marker([45.3311, -121.7113], popup='Timberline Lodge',marker_color='green')
111111
map_1.simple_marker([45.3300, -121.6823], popup='Some Other Location',marker_color='red',marker_icon='info-sign')
112-
map_1.create_map(path='iconTest.html')
112+
map_1.save('iconTest.html')
113113
114114
|iconTest|
115115

@@ -123,7 +123,7 @@ Folium also supports circle-style markers, with custom size and color:
123123
map_2.circle_marker(location=[45.5215, -122.6261], radius=500,
124124
popup='Laurelhurst Park', line_color='#3186cc',
125125
fill_color='#3186cc')
126-
map_2.create_map(path='portland.html')
126+
map_2.save('portland.html')
127127
128128
|circle|
129129

@@ -136,7 +136,7 @@ Folium has a convenience function to enable lat/lng popovers:
136136
map_3 = folium.Map(location=[46.1991, -122.1889], tiles='Stamen Terrain',
137137
zoom_start=13)
138138
map_3.lat_lng_popover()
139-
map_3.create_map(path='sthelens.html')
139+
map_3.save('sthelens.html')
140140
141141
|latlng|
142142

@@ -151,7 +151,7 @@ markers:
151151
zoom_start=13)
152152
map_4.simple_marker(location=[46.8354, -121.7325], popup='Camp Muir')
153153
map_4.click_for_marker(popup='Waypoint')
154-
map_4.create_map(path='mtrainier.html')
154+
map_4.save('mtrainier.html')
155155
156156
|waypoints|
157157

@@ -171,7 +171,7 @@ Folium also supports the Polygon marker set from the
171171
fill_color='#769d96', num_sides=6, radius=10)
172172
map_5.polygon_marker(location=[45.5318, -122.6745], popup='Broadway Bridge',
173173
fill_color='#769d96', num_sides=8, radius=10)
174-
map_5.create_map(path='bridges.html')
174+
map_5.save('bridges.html')
175175
176176
|polygon|
177177

@@ -194,7 +194,7 @@ marker type, with the visualization as the popover:
194194
radius=12, popup=(vis2, 'vis2.json'))
195195
buoy_map.polygon_marker(location=[46.216, -124.1280], fill_color='#43d9de',
196196
radius=12, popup=(vis3, 'vis3.json'))
197-
buoy_map.create_map(path='NOAA_buoys.html')
197+
buoy_map.save('NOAA_buoys.html')
198198
199199
|vincent|
200200

@@ -213,9 +213,9 @@ and multiple layers can be visualized on the same map:
213213
214214
ice_map = folium.Map(location=[-59.1759, -11.6016],
215215
tiles='Mapbox Bright', zoom_start=2)
216-
ice_map.geo_json(geo_path=geo_path)
217-
ice_map.geo_json(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
218-
ice_map.create_map(path='ice_map.html')
216+
ice_map.choropleth(geo_path=geo_path)
217+
ice_map.choropleth(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
218+
ice_map.save('ice_map.html')
219219
220220
|ice|
221221

@@ -241,12 +241,12 @@ to quickly visualize different combinations:
241241
242242
#Let Folium determine the scale
243243
map = folium.Map(location=[48, -102], zoom_start=3)
244-
map.geo_json(geo_path=state_geo, data=state_data,
244+
map.choropleth(geo_path=state_geo, data=state_data,
245245
columns=['State', 'Unemployment'],
246246
key_on='feature.id',
247247
fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
248248
legend_name='Unemployment Rate (%)')
249-
map.create_map(path='us_states.html')
249+
map.save('us_states.html')
250250
251251
|states_1|
252252

@@ -258,14 +258,14 @@ own threshold values is simple:
258258

259259
.. code:: python
260260
261-
map.geo_json(geo_path=state_geo, data=state_data,
261+
map.choropleth(geo_path=state_geo, data=state_data,
262262
columns=['State', 'Unemployment'],
263263
threshold_scale=[5, 6, 7, 8, 9, 10],
264264
key_on='feature.id',
265265
fill_color='BuPu', fill_opacity=0.7, line_opacity=0.5,
266266
legend_name='Unemployment Rate (%)',
267267
reset=True)
268-
map.create_map(path='us_states.html')
268+
map.save('us_states.html')
269269
270270
|states_2|
271271

@@ -280,12 +280,12 @@ will visualize:
280280
281281
#Number of employed with auto scale
282282
map_1 = folium.Map(location=[48, -102], zoom_start=3)
283-
map_1.geo_json(geo_path=county_geo, data_out='data1.json', data=df,
283+
map_1.choropleth(geo_path=county_geo, data_out='data1.json', data=df,
284284
columns=['GEO_ID', 'Employed_2011'],
285285
key_on='feature.id',
286286
fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.3,
287287
topojson='objects.us_counties_20m')
288-
map_1.create_map(path='map_1.html')
288+
map_1.save('map_1.html')
289289
290290
|counties_1|
291291

@@ -295,14 +295,14 @@ will visualize:
295295
296296
#Unemployment with custom defined scale
297297
map_2 = folium.Map(location=[40, -99], zoom_start=4)
298-
map_2.geo_json(geo_path=county_geo, data_out='data2.json', data=df,
298+
map_2.choropleth(geo_path=county_geo, data_out='data2.json', data=df,
299299
columns=['GEO_ID', 'Unemployment_rate_2011'],
300300
key_on='feature.id',
301301
threshold_scale=[0, 5, 7, 9, 11, 13],
302302
fill_color='YlGnBu', line_opacity=0.3,
303303
legend_name='Unemployment Rate 2011 (%)',
304304
topojson='objects.us_counties_20m')
305-
map_2.create_map(path='map_2.html')
305+
map_2.save('map_2.html')
306306
307307
|counties_2|
308308

@@ -312,13 +312,13 @@ will visualize:
312312
313313
#Median Household income
314314
map_3 = folium.Map(location=[40, -99], zoom_start=4)
315-
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
315+
map_3.choropleth(geo_path=county_geo, data_out='data3.json', data=df,
316316
columns=['GEO_ID', 'Median_Household_Income_2011'],
317317
key_on='feature.id',
318318
fill_color='PuRd', line_opacity=0.3,
319319
legend_name='Median Household Income 2011 ($)',
320320
topojson='objects.us_counties_20m')
321-
map_3.create_map(path='map_3.html')
321+
map_3.save('map_3.html')
322322
323323
|counties_3|
324324

examples/antarctic_shelf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import folium
77

88

9-
geo_path = r'data/antarctic_ice_edge.json'
10-
topo_path = r'data/antarctic_ice_shelf_topo.json'
9+
geo_path = r'antarctic_ice_edge.json'
10+
topo_path = r'antarctic_ice_shelf_topo.json'
1111

1212
ice_map = folium.Map(location=[-59.1759, -11.6016],
1313
tiles='Mapbox Bright', zoom_start=2)
14-
ice_map.geo_json(geo_path=geo_path)
15-
ice_map.geo_json(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
16-
ice_map.create_map()
14+
ice_map.choropleth(geo_path=geo_path)
15+
ice_map.choropleth(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
16+
ice_map.save('map.html')

examples/choropleth_states.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313

1414
# Let Folium determine the scale.
1515
states = folium.Map(location=[48, -102], zoom_start=3)
16-
states.geo_json(geo_path=state_geo, data=state_data,
17-
columns=['State', 'Unemployment'],
18-
key_on='feature.id',
19-
fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
20-
legend_name='Unemployment Rate (%)')
16+
states.choropleth(geo_path=state_geo, data=state_data,
17+
columns=['State', 'Unemployment'],
18+
key_on='feature.id',
19+
fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
20+
legend_name='Unemployment Rate (%)')
2121
states.save(outfile='us_state_map.html')
2222

2323
# Let's define our own scale and change the line opacity.
2424
states2 = folium.Map(location=[48, -102], zoom_start=3)
25-
states2.geo_json(geo_path=state_geo, data=state_data,
26-
columns=['State', 'Unemployment'],
27-
threshold_scale=[5, 6, 7, 8, 9, 10],
28-
key_on='feature.id',
29-
fill_color='BuPu', fill_opacity=0.7, line_opacity=0.5,
30-
legend_name='Unemployment Rate (%)',
31-
reset=True)
25+
states2.choropleth(geo_path=state_geo, data=state_data,
26+
columns=['State', 'Unemployment'],
27+
threshold_scale=[5, 6, 7, 8, 9, 10],
28+
key_on='feature.id',
29+
fill_color='BuPu', fill_opacity=0.7, line_opacity=0.5,
30+
legend_name='Unemployment Rate (%)',
31+
reset=True)
3232
states2.save(outfile='us_state_map_2.html')

0 commit comments

Comments
 (0)