-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
import folium
import pandas as pd
import numpy as np
import geopandas as gpd
import fiona
import matplotlib.pyplot as plt
import seaborn as sns
from shapely.geometry import Point
from branca.colormap import linear
import random
import shapely
import geopandas
location = pd.read_csv('community.csv',encoding= "ISO-8859-1")
location = location.dropna()
location = location.reset_index(drop=True)
location.head()
from geopandas import GeoDataFrame
import json
geojson_layer = folium.GeoJson(json.load(open('Boundaries.geojson')),
name='geojson')
gdf1 = geopandas.read_file('Boundaries.geojson')
gdf1['area_num_1'] = gdf1.area_num_1.astype(int)
cols=['community','geometry','area_num_1']
gdf = gdf1[cols]
polygon = location
cols = ['community','latitude','longitude','arrest','domestic']
polygon = polygon[cols]
polygon_1 = pd.merge(polygon,gdf,left_on='community',right_on='area_num_1',how='left')
polygon_1 = GeoDataFrame(polygon_1,crs={'init':'epsg:4326'},geometry=gdf['geometry'])
polygon_1 = polygon_1.dropna()
map1 = folium.Map(location=[41.6,-87.5],zoom_start=12,tiles='Stamen Terrain')
#heat_data = [[row['latitude'],row['longitude']] for index, row in polygon_1.iterrows()]
minimap = plugins.MiniMap()
map1.add_child(minimap)
geoj2 = folium.GeoJson(data=polygon_1,
name='chicago',smooth_factor=2,
style_function=lambda x: {'color':'grey', 'fillOpacity': 0.9,'weight':0.5},
tooltip=folium.GeoJsonTooltip(fields=['community_x', 'latitude'],
aliases = ['Number of Transactions','Total People'],
style="font-family: san serif;",
labels=True,sticky=True),
highlight_function=lambda x:{'weight':0.5,'fillColor':'Red',
'fillOpacity':0.4}).add_to(map1)Metadata
Metadata
Assignees
Labels
No labels