I am working on the crime classification problem from kaggle, I am trying to plot a heatmap of crime incidents over the map of San Francisco. Below is the scatter plot and code for the scatter plot of incidents in SF.
SF_map=np.loadtxt("/home/syed/crime/sf_map_copyright_openstreetmap_contributors.txt") lon_lat_box = (-122.5247, -122.3366, 37.699, 37.8299) asp = SF_map.shape * 1.0 / SF_map.shape fig = plt.figure(figsize=(16,16)) plt.imshow(SF_map,cmap='gray',extent=lon_lat_box,aspect=1/asp) ax=plt.gca() train[(train['Y']<40)].plot(x='X',y='Y',ax=ax,kind='scatter',marker='o',s=20,color='red',alpha=0.01) ax.set_axis_off()
I want to plot a heatmap over SF for the frequency of incident. I tried using seaborn.heatmap but couldn’t get it to work. Please suggest me some good approach.
Here is the file for SF map : https://www.kaggle.com/benhamner/sf-crime/saving-the-python-maps-file/output