Let's make an Asthma Choropleth using open data, ogr2ogr, folium and pandas (and indirectly leaflet.js, d3.js, GeoJSON, open street maps and moar) and talk about using gist and blocks..
-
get UK Asthma data http://customer.instantatlas.com/INHALE/dataviews/ for this example I use dataView12_17.csv
-
get some CCG map boundaries
wget 'https://geoportal.statistics.gov.uk/Docs/Boundaries/Clinical_commissioning_groups_(Eng)_Apr_2013_Boundaries_(Generalised_Clipped).zip'
-
make CCG map boundaries into GeoJSON format
ogr2ogr -f 'ESRI Shapefile' -t_srs 'EPSG:4326' ccgs_4326.shp CCG_APR_2013_EN_BFE.shp ogr2ogr -f GeoJSON ccgs.json ccgs_4326.shp
-
load the UK Asthma data .csv into a pandas dataframe and add a CCG column id so it can join up with GeoJSON. See the Gist for the python code to generate the dataframe.
-
make the choropleth using folium magic python code
map = folium.Map(location=[54.2, -2.45], zoom_start=5) map.geo_json(geo_path=ccg_geo, data_out='data1.json', data=df1, columns=['CCG13CD', 'Asthma emergency admissions per 1,000 population(2011)'], key_on='feature.properties.CCG13CD', fill_color='PuBu', fill_opacity=0.7, line_opacity=0.3, legend_name='Asthma emergency admissions per 1,000 population(2011)') map.create_map(path='map_1.html')