#!/usr/bin/env python # coding: utf-8 # # Map of King County Real Estate by Zipcode # # Continuation of *3.2 Geospatial Mapping* in [Main Notebook](https://github.com/czarinagluna/regression-analysis-for-estimating-prices/blob/main/main.ipynb) # # *** # **By [Czarina Luna](https://www.linkedin.com/in/czarinagluna/)** # In[1]: get_ipython().run_line_magic('store', '-r UnderMillion') # In[2]: get_ipython().run_line_magic('store', '-r OverMillion') # **Please use the [notebook viewer](https://nbviewer.org/github/czarinagluna/regression-analysis-for-estimating-prices/blob/main/map.ipynb) to render the maps.** # In[4]: 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') # In[5]: map_zipcode(UnderMillion, 'House Prices Sold Under $1 Million', 'PuBuGn', 'data/images/UnderMillion.html') # In[6]: map_zipcode(OverMillion, 'House Prices Sold Over $1 Million', 'Greens', 'data/images/OverMillion.html') # # Contact # # Feel free to contact me for any questions and connect with me on [Linkedin](https://www.linkedin.com/in/czarinagluna/).