Exemplo n.º 1
0
def plot_location_node(locs, labels):
    mymap = gmp.from_geocode("New York")

    clist = color_dicts.html_color_codes.keys()
    for cur_label in range(np.max(labels)):
        print("cur_label", cur_label)
        path = [[], []]
        color = ''
        for i in range(len(locs)):
            loc = locs[i]
            cluster_label = labels[i]
            assert (loc != 'not applicable')
            if cluster_label == cur_label:
                # print("Color", clist[cluster_label])
                color = clist[cluster_label]
                path[0].append(float(loc.split(' ')[0]))
                path[1].append(-float(loc.split(' ')[2]))

        edge = [tuple(path[0]), tuple(path[1])]
        # mymap.heatmap(edge[0], edge[1], threshold=5, radius=40)
        mymap.scatter(edge[0], edge[1], c=color, s=200, marker=False, alpha=1)
    mymap.draw("cluster_map.html")
Exemplo n.º 2
0
 def __init__(self, location, file_path):
     self._file_path = file_path
     self._gmap = GoogleMapPlotter.from_geocode(location)
     self._marker_list = []
     self._jpg_paths = []
     self._per_dir_jpg_paths = {}
Exemplo n.º 3
0
                longitude = float(DB[tweet]['place'][u'bounding_box'][u'coordinates'][0][0][0])
                latitude = float(DB[tweet]['place'][u'bounding_box'][u'coordinates'][0][0][1])
                if (category == 'PO'):
                    po_lon.append(longitude)
                    po_lat.append(latitude)
                elif category == 'PL':
                    pl_lon.append(longitude)
                    pl_lat.append(latitude)

    po_scatter_path = (po_lat,po_lon)
    pl_scatter_path = (pl_lat,pl_lon)

    if (city is 'US'):
        mymap = GoogleMapPlotter(39.908213, -99.675441, 4)
    else:
        mymap = GoogleMapPlotter.from_geocode(city, 12)
        lat, lng = mymap.geocode(city)
    for group in ultralist:
        drawGroupBox(group,mymap)
        
    mymap.scatter(po_scatter_path[0], po_scatter_path[1], c='tomato', marker=True)
    mymap.scatter(pl_scatter_path[0], pl_scatter_path[1], c='lemonchiffon', marker=True)
    mymap.draw('./mymap.html')
    webbrowser.open(tweetMap)
        
    
if (searchType == 'real'):
    startDate = raw_input('Enter todays date: ')

    while True:
        for tweet in DB:
Exemplo n.º 4
0
for c in cameras:
    count, density = gen.generate_features(c)
    traffic_stat = clf.predict([count, density])
    if traffic_stat == 2:
        print(c, ' : High traffic')
    elif traffic_stat == 1:
        print(c, ' : Medium traffic')
    else:
        print(c, ' : Low traffic')
    traffic.append(traffic_stat)

count = [traffic.count(0), traffic.count(1), traffic.count(2)]
status = count.index(max(count))

color = ['green', 'yellow', 'red']
gmap = gmp.from_geocode(
    "Veermata Jijabai Technological Institute, Mumbai, Maharashtra")
gmap.scatter([19.018892, 19.024714], [72.855786, 72.856964],
             color[status],
             size=40,
             marker=False)
gmap.scatter(
    [19.019693, 19.020433, 19.021336, 19.022432, 19.024055, 19.023030],
    [72.856173, 72.856409, 72.856570, 72.856763, 72.857053, 72.856914],
    color[status],
    size=10,
    marker=False)

##this will generate html file of google map
gmap.draw("map.html")
Exemplo n.º 5
0
def ua_map(datax, datay, sales):
    ua_map = GoogleMapPlotter.from_geocode("Ukraine", 7)
    for (x, y, s) in zip(datax, datay, sales):
        ua_map.scatter([x], [y], c='#%02x%02x%02x' % convert_to_rgb(s+1, maxval=10), size=1000+10*s, marker=False, alpha=0.5)    
    #ua_map.heatmap(datax, datay, radius=40)
    ua_map.draw("mymap.html")
        
            xy = X[class_member_mask & ~core_samples_mask]
            plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=col,
                     markeredgecolor='k', markersize=2)
        
        plt.title('Estimated number of clusters: %d, %d' % (n_clusters_, len(labels[labels == -1])))
        plt.show()
    print('Singled: %d, max: %d' % (data.groupby(by='cluster').count().query('Customer_Code == 1').count()[0], data.groupby(by='cluster').count().max()[0]))
    return data, last_index

#Кластеризуем дважды, при этом запоминаем номер последнего кластера, чтобы кластера не пересекались
kiev_loc, index = cluster(kiev_loc)
kiev_loc_singles = kiev_loc[kiev_loc.cluster.isin(kiev_loc.groupby(by='cluster').count().query('Customer_Code == 1').reset_index()['cluster'])]
kiev_loc_singles, index = cluster(kiev_loc_singles, e=0.00441, cluster_last_index=index)

kiev_loc.update(kiev_loc_singles)
kiev_loc.cluster = kiev_loc.cluster.astype(int)

print('Result: Singled: %d, max: %d' % (kiev_loc.groupby(by='cluster').count().query('Customer_Code == 1').count()[0], kiev_loc.groupby(by='cluster').count().max()[0]))
#points are near each to other?
kiev_loc.groupby(by='cluster').agg(np.std).plot()


ua_map = GoogleMapPlotter.from_geocode("Ukraine, Kiev", 12)
for (code, x, y, cluster) in kiev_loc.as_matrix():
    ua_map.scatter([y], [x], c='#%02x%02x%02x' % convert_to_rgb(cluster, minval=kiev_loc.cluster.min(), maxval=kiev_loc.cluster.max()), size=50, marker=False, alpha=0.5)
    
ua_map.draw("clustered.html")


#50.41916499 30.51916459