#!/usr/bin/env python # coding: utf-8 # In[1]: import os import folium print(folium.__version__) # # Using Leaflet's Smooth Factor Option # # [Polyline](http://leafletjs.com/reference.html#polyline) objects in leaflet are smoothed by default. This removes points from the line, putting less load on the browser when drawing. The level of smoothing [can be specified](http://leafletjs.com/reference.html#polyline-smoothfactor) by passing `smoothFactor` as an option when creating any Polyline object. # # In folium, the level of smoothing can be determined by passing `smooth_factor` as an argument when initialising GeoJson, TopoJson and Choropleth objects. There are no upper or lower bounds to the smoothing level; Leaflet's default is 1. # In[2]: m = folium.Map( location=[-59.1759, -11.6016], tiles='Mapbox Bright', zoom_start=2 ) fname = os.path.join('data', 'antarctic_ice_shelf_topo.json') folium.TopoJson( data=open(fname), object_path='objects.antarctic_ice_shelf', name='default_smoothing', smooth_factor=1 ).add_to(m) folium.TopoJson( data=open(fname), object_path='objects.antarctic_ice_shelf', name='default_smoothing', smooth_factor=10, style_function=lambda x: {'color': '#004c00', 'opacity': '0.7'} ).add_to(m) folium.LayerControl().add_to(m) m.save(os.path.join('results', 'SmoothFactor.html')) m