Continuation of 3.2 Geospatial Mapping in Main Notebook
By Czarina Luna
%store -r UnderMillion
%store -r OverMillion
Please use the notebook viewer to render the maps.
import folium as folium
def map_zipcode(data, title, color, name):
'''Maps the data points according to price per zipcode in King County'''
king_county_geo = 'data/map/Zipcodes_for_King_County_and_Surrounding_Area___zipcode_area.geojson'
king_county_map = folium.Map(location=[47.484823, -122.112342], tiles='cartodbpositron', zoom_start=9.5)
folium.Choropleth(
geo_data=king_county_geo,
data=data,
columns=['zipcode', 'price'],
key_on='feature.properties.ZIP',
fill_color=color,
fill_opacity=0.7,
line_opacity=0.2,
legend_name=title).add_to(king_county_map)
folium.LayerControl().add_to(king_county_map)
king_county_map.save(name)
return king_county_map
import warnings
warnings.filterwarnings('ignore')
map_zipcode(UnderMillion, 'House Prices Sold Under $1 Million', 'PuBuGn', 'data/images/UnderMillion.html')
map_zipcode(OverMillion, 'House Prices Sold Over $1 Million', 'Greens', 'data/images/OverMillion.html')