-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_data_on_map.py
More file actions
46 lines (31 loc) · 1.2 KB
/
plot_data_on_map.py
File metadata and controls
46 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pandas as pd
import gmplot
df = pd.read_csv('Dataset/train.csv')
ps = pd.read_csv('Dataset/police_station.csv')
df.dropna(inplace=True)
gmapf = gmplot.GoogleMapPlotter(41.868397, -87.648281, 13)
gmapf.apikey = "AIzaSyDeRNMnZ__VnQDiATiuz4kPjF_c9r1kWe8"
ps_lat = ps["LATITUDE"]
ps_lon = ps["LONGITUDE"]
gmapf.scatter(ps_lat, ps_lon, color='blue', shape='x')
df_th = df.loc[df["Primary Type"]=="THEFT"]
df_bat = df.loc[df["Primary Type"]=="BATTERY"]
df_ass = df.loc[df["Primary Type"]=="ASSAULT"]
df_dp = df.loc[df["Primary Type"]=="DECEPTIVE PRACTICE"]
df_cd = df.loc[df["Primary Type"]=="CRIMINAL DAMAGE"]
th_lon = df_th["Longitude"]
th_lat = df_th["Latitude"]
gmapf.scatter(th_lat, th_lon, color='red', marker=True)
bat_lon = df_bat["Longitude"]
bat_lat = df_bat["Latitude"]
gmapf.scatter(bat_lat, bat_lon, color='yellow', marker=True)
ass_lon = df_ass["Longitude"]
ass_lat = df_ass["Latitude"]
gmapf.scatter(ass_lat, ass_lon, color='green', marker=True)
dp_lon = df_dp["Longitude"]
dp_lat = df_dp["Latitude"]
gmapf.scatter(ass_lat, ass_lon, color='orange', marker=True)
cd_lon = df_cd["Longitude"]
cd_lat = df_cd["Latitude"]
gmapf.scatter(ass_lat, ass_lon, color='black', marker=True)
gmapf.draw("map.html")