{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Map of King County Real Estate by Zipcode\n", "\n", "Continuation of *3.2 Geospatial Mapping* in [Main Notebook](https://github.com/czarinagluna/regression-analysis-for-estimating-prices/blob/main/main.ipynb)\n", "\n", "*** \n", "**By [Czarina Luna](https://www.linkedin.com/in/czarinagluna/)**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%store -r UnderMillion" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%store -r OverMillion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Please use the [notebook viewer](https://nbviewer.org/github/czarinagluna/regression-analysis-for-estimating-prices/blob/main/map.ipynb) to render the maps.**" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import folium as folium\n", "\n", "def map_zipcode(data, title, color, name):\n", " '''Maps the data points according to price per zipcode in King County'''\n", " king_county_geo = 'data/map/Zipcodes_for_King_County_and_Surrounding_Area___zipcode_area.geojson'\n", "\n", " king_county_map = folium.Map(location=[47.484823, -122.112342], tiles='cartodbpositron', zoom_start=9.5)\n", "\n", " folium.Choropleth(\n", " geo_data=king_county_geo,\n", " data=data,\n", " columns=['zipcode', 'price'],\n", " key_on='feature.properties.ZIP',\n", " fill_color=color,\n", " fill_opacity=0.7,\n", " line_opacity=0.2,\n", " legend_name=title).add_to(king_county_map)\n", "\n", " folium.LayerControl().add_to(king_county_map)\n", " king_county_map.save(name)\n", " return king_county_map\n", "\n", "import warnings\n", "warnings.filterwarnings('ignore')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "