#!/usr/bin/env python # coding: utf-8 # In[1]: import os import folium print(folium.__version__) # In[2]: import json us_states = os.path.join('data', 'us-states.json') with open(us_states) as f: states = json.load(f) kw = dict(location=[48, -102], zoom_start=3) # In[3]: from folium import GeoJson m = folium.Map(tiles=None, **kw) GeoJson(states).add_to(m) m.save(os.path.join('results', 'GeoJSONWithoutTitles_0.html')) m # In[4]: import branca # Create a white image of 4 pixels, and embed it in a url. white_tile = branca.utilities.image_to_url([[1, 1], [1, 1]]) # Create a map using this url for each tile. m = folium.Map(tiles=white_tile, attr='white tile', **kw) GeoJson(states).add_to(m) m.save(os.path.join('results', 'GeoJSONWithoutTitles_1.html')) m # In[5]: images = [[(-1)**((i+j)//30) for i in range(300)] for j in range(300)] tiles = branca.utilities.image_to_url(images) m = folium.Map(tiles=tiles, attr='Just because we can', **kw) GeoJson(states).add_to(m) m.save(os.path.join('results', 'GeoJSONWithoutTitles_2.html')) m # In[6]: images = [[(-1)**((i//30+j//30)) for i in range(300)] for j in range(300)] tiles = branca.utilities.image_to_url(images) m = folium.Map(tiles=tiles, attr='Just because we can', **kw) GeoJson(states).add_to(m) m.save(os.path.join('results', 'GeoJSONWithoutTitles_3.html')) m