Skip to content

Instantly share code, notes, and snippets.

View wrobstory's full-sized avatar

Rob Story wrobstory

View GitHub Profile
@wrobstory
wrobstory / README.md
Last active February 6, 2016 19:02
d3.chart Choropleths

Choropleth charts built with the d3.chart framework. choropleth_chart.js is the chart type definition, which allows for rapid iteration of different quantize-scale domain/range, colors, and projections. The colors are based on color brewer, and you can pass any of the sequential scale abbreviations ('BuGn', 'PuBuGn', etc) to the range parameter to iterate on colors.

@wrobstory
wrobstory / README.md
Last active April 15, 2020 03:18
Folium Income Choropleth

A Leaflet.js map created with Folium and a custom D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_3 = folium.Map(location=[40, -99], zoom_start=4)
map_3.geo_json(geo_path=county_geo, data_out='data3.json', data=df,
               columns=['GEO_ID', 'Median_Household_Income_2011'],
               key_on='feature.id',
               fill_color='PuRd', line_opacity=0.3,
               legend_name='Median Household Income 2011 ($)',
 topojson='objects.us_counties_20m')
@wrobstory
wrobstory / README.md
Last active December 17, 2015 12:29
Folium Unemployment Choropleth

A Leaflet.js map created with Folium and a custom D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_2 = folium.Map(location=[40, -99], zoom_start=4)
map_2.geo_json(geo_path=county_geo, data_out='data2.json', data=df,
               columns=['GEO_ID', 'Unemployment_rate_2011'],
               key_on='feature.id',
               threshold_scale=[0, 5, 7, 9, 11, 13],
               fill_color='YlGnBu', line_opacity=0.3,
 legend_name='Unemployment Rate 2011 (%)',
@wrobstory
wrobstory / README.md
Last active March 22, 2022 21:06
Folium Employed Choropleth

A Leaflet.js map created with Folium and the default D3 threshold scale, with data bound between the Pandas DataFrame and the TopoJSON. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map_1 = folium.Map(location=[48, -102], zoom_start=3)
map_1.geo_json(geo_path=county_geo, data_out='data1.json', data=df,
               columns=['GEO_ID', 'Employed_2011'],
               key_on='feature.id',
               fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.3,
               topojson='objects.us_counties_20m')
map_1.create_map(path='map_1.html')
@wrobstory
wrobstory / README.md
Last active March 22, 2022 20:03
Folium Choropleth Custom

A Leaflet.js map created with Folium and the default D3 threshold scale. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map.geo_json(geo_path=state_geo, data=state_data,
             columns=['State', 'Unemployment'],
             threshold_scale=[5, 6, 7, 8, 9, 10],
             key_on='feature.id',
             fill_color='BuPu', fill_opacity=0.7, line_opacity=0.5,
             legend_name='Unemployment Rate (%)',
 reset=True)
@wrobstory
wrobstory / README.md
Last active April 22, 2019 17:24
Folium Choropleth Default

A Leaflet.js map created with Folium and the default D3 threshold scale. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map = folium.Map(location=[48, -102], zoom_start=3)
map.geo_json(geo_path=state_geo, data=state_data,
             columns=['State', 'Unemployment'],
             key_on='feature.id',
             fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2,
             legend_name='Unemployment Rate (%)')
map.create_map(path='us_states.html')
@wrobstory
wrobstory / README.md
Last active December 17, 2015 12:29
Folium Geo/TopoJSON Overlay

A Leaflet.js map created with Folium using both GeoJSON and TopoJSON. The map was generated with the following Python code:

geo_path = r'data/antarctic_ice_edge.json'
topo_path = r'data/antarctic_ice_shelf_topo.json'

ice_map = folium.Map(location=[-59.1759, -11.6016],
                     tiles='Mapbox Bright', zoom_start=2)
ice_map.geo_json(geo_path=geo_path)
ice_map.geo_json(geo_path=topo_path, topojson='objects.antarctic_ice_shelf')
@wrobstory
wrobstory / NOAA_46041.csv
Last active December 17, 2015 12:29
Folium Vincent/Vega Markers
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 11 columns, instead of 9 in line 8.
station_id,latitude (degrees north),longitude (degrees east),date_time,air_temperature (C°),sea_level_pressure (hPa),wind_speed (m/s),gust_speed (m/s),significant_wave_height (m),dominant_wave_period (s),sea_surface_temperature (C°) 2868187,47.34899902,-124.7080002,2013-04-18T00:50:00Z,7.199999809,1032.599976,5,8,1,8,10.10000038 2868187,47.34899902,-124.7080002,2013-04-18T01:50:00Z,6.800000191,1032.300049,4,5,1.100000024,6,10 2868187,47.34899902,-124.7080002,2013-04-18T02:50:00Z,6.900000095,1031.800049,3,4,1.100000024,7,10 2868187,47.34899902,-124.7080002,2013-04-18T03:50:00Z,7,1031.699951,2,3,1,6,9.899999619 2868187,47.34899902,-124.7080002,2013-04-18T04:50:00Z,7.099999905,1031.900024,1,2,0.899999976,8,9.899999619 2868187,47.34899902,-124.7080002,2013-04-18T05:50:00Z,7.199999809,1031.699951,0,1,0.899999976,6,9.800000191 2868187,47.34899902,-124.7080002,2013-04-18T06:50:00Z,7.400000095,1031.400024,3,3,0.899999976,6,9.800000191 2868187,47.34899902,-124.7080002,2013-04-18T07:50:00Z,7.400000095,1031.300049,2,3,0
@wrobstory
wrobstory / README.md
Last active December 17, 2015 12:29
Folium Polygon Markers

A Leaflet.js map created with Folium. This map was generated with the following Python code:

map_5 = folium.Map(location=[45.5236, -122.6750], zoom_start=13)
map_5.polygon_marker(location=[45.5012, -122.6655], popup='Ross Island Bridge',
                     fill_color='#132b5e', num_sides=3, radius=10)
map_5.polygon_marker(location=[45.5132, -122.6708], popup='Hawthorne Bridge',
                     fill_color='#45647d', num_sides=4, radius=10)
map_5.polygon_marker(location=[45.5275, -122.6692], popup='Steel Bridge',
 fill_color='#769d96', num_sides=6, radius=10)
@wrobstory
wrobstory / README.md
Last active August 29, 2022 07:07
Folium Click-for-marker

A Leaflet.js map created with Folium- click on the map to add markers, double-click to remove them. This map was generated with the following Python code:

map_4 = folium.Map(location=[46.8527, -121.7649], tiles='Stamen Terrain',
                   zoom_start=13)
map_4.simple_marker(location=[46.8354, -121.7325], popup='Camp Muir')
map_4.click_for_marker(popup='Waypoint')
map_4.create_map(path='mtrainier.html')