def visualize_heatmap_for_data(self, df):
     """
     Normally visualize accidents distributions across borough
     :param df: Dataset
     :return: None
     """
     geo_data_for_plotting = {"lat": df["LATITUDE"], "lon": df["LONGITUDE"]}
     geoplotlib.kde(geo_data_for_plotting, 1)
     east = max(df["LONGITUDE"])
     west = min(df["LONGITUDE"])
     south = max(df["LATITUDE"])
     north = min(df["LATITUDE"])
     bbox = BoundingBox(north=north, west=west, south=south, east=east)
     geoplotlib.set_bbox(bbox)
     geoplotlib.tiles_provider('toner-lite')
     geoplotlib.show()
示例#2
0
#!/usr/bin/env python2
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox, DataAccessObject

data = read_csv('filtered_lonlat.csv')

# http://andreacuttone.com/geoplotlib/api.html#module-geoplotlib
geoplotlib.dot(data, color=[0,0,0], point_size=1.5)
geoplotlib.kde(data, bw=10, cmap='PuBuGn', cut_below=1e-4, clip_above=1e-2, alpha=180)
geoplotlib.graph(read_csv('group0.csvgraph.csv'), src_lat='flat', src_lon='flon',
        dest_lat='tlat', dest_lon='tlon', color=[0,0,0], linewidth=2)
geoplotlib.graph(read_csv('group1.csvgraph.csv'), src_lat='flat', src_lon='flon',
        dest_lat='tlat', dest_lon='tlon', color=[0,255,0], linewidth=2)
geoplotlib.graph(read_csv('group2.csvgraph.csv'), src_lat='flat', src_lon='flon',
        dest_lat='tlat', dest_lon='tlon', color=[128,0,128], linewidth=2)
geoplotlib.kde(read_csv('chokepoints.csv'), bw=10, cmap='hot',
        cut_below=1e-4, clip_above=1e-2, alpha=180)

bbox = BoundingBox(north=25.7188,west=-80.280,south=25.711,east=-80.280)
geoplotlib.set_bbox(bbox)
geoplotlib.set_window_size(1400, 1600)
#geoplotlib.set_window_size(700, 800)
geoplotlib.tiles_provider('toner')
geoplotlib.set_smoothing(True)
geoplotlib.savefig('output')
#geoplotlib.show()
示例#3
0
"""
Example of setting a custom tile provider
"""
import geoplotlib
from geoplotlib.utils import read_csv

geoplotlib.tiles_provider({
    'url':
    lambda zoom, xtile, ytile:
    'http://a.tile.stamen.com/watercolor/%d/%d/%d.png' % (zoom, xtile, ytile),
    'tiles_dir':
    'mytiles',
    'attribution':
    'my attribution'
})
geoplotlib.show()
示例#4
0
import geoplotlib

thedata = geoplotlib.utils.read_csv('bus.csv')
geoplotlib.tiles_provider('toner-lite')
geoplotlib.dot(thedata)
#geoplotlib.geojson('bus.json')
geoplotlib.show()
wifi_STATENISLAND = wifi[wifi['boro_w'] == 'Staten Island']

#################### MAP PLOTS

#1. Streetlights = green, wifi = blue, and crime locations = red (general - everything on the map)

alphaCrime = 20

streetLightColor = [103, 191, 92]
wifiColor = [0, 122, 255]
crimeColor = [237, 102, 93, alphaCrime]
gp.clear()
plotPointSize = 2

gp.set_window_size(800, 800)
gp.tiles_provider('darkmatter')

#Street light plot
geoPoltData = streetlight[["lat_s", "lon_s"]].rename(columns={
    'lat_s': 'lat',
    'lon_s': 'lon'
},
                                                     inplace=False)
gp.dot(geoPoltData, point_size=plotPointSize, color=streetLightColor)

#Wifi plot
geoPoltData = wifi[["lat_w", "lon_w"]].rename(columns={
    'lat_w': 'lat',
    'lon_w': 'lon'
},
                                              inplace=False)
示例#6
0
"""
Example of setting a custom tile provider
"""
import geoplotlib


geoplotlib.tiles_provider({
    'url': lambda zoom, xtile, ytile: 'http://a.tile.stamen.com/watercolor/%d/%d/%d.png' % (zoom, xtile, ytile),
    'tiles_dir': 'mytiles',
    'attribution': 'my attribution'
})
geoplotlib.show()
f = open("VLOCs.csv", "w+")
f.close()

#write csv to be read by geoplotlib
with open('VLOCs.csv', mode='w', newline='') as VLOCs:
    VLOCs = csv.writer(VLOCs, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
    VLOCs.writerow(['name', 'S_lat', 'S_lon', 'D_lat', 'D_lon'])
    for station in Locations:
        VLOCs.writerow([station[0], station[1], station[2], station[3], station[4]])

#empty SLOCs.csv
f = open("SLOCs.csv", "w+")
f.close()

#write csv to be read by geoplotlib
with open('SLOCs.csv', mode='w', newline='') as SLOCs:
    SLOCs = csv.writer(SLOCs, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
    SLOCs.writerow(['name', 'lat', 'lon'])
    for station in Locations:
        SLOCs.writerow([station[0], station[1], station[2]])

#plot stations
Plotdata1 = read_csv('VLOCs.csv')
Plotdata2 = read_csv('SLOCs.csv')
gp.set_bbox(BoundingBox(north=9, west=110, south=1, east=95))
gp.graph(Plotdata1, 'S_lat', 'S_lon', 'D_lat', 'D_lon', linewidth=2, color='Blues')
gp.dot(Plotdata2, color='blue', point_size=3)
gp.labels(Plotdata2, 'name', color='black', font_size=8, anchor_x='center')
gp.tiles_provider('positron')

gp.show()