def realTimeTwitterMap(interval):
    """
    Interval in minutes!
    """
    while True:
        df = pd.read_csv('terrortracking.csv',encoding="Latin-1")
        arr = df[['Lat', 'Long']]
        arr=arr.dropna()
        arr=(np.array(arr)).tolist()
        maps = gmaps.heatmap(arr)
        gmaps.display(maps)
        print('done')
        time.sleep(interval*60)
def plotRiskyLocations(name, country):
    if name == None:
        return
        # Consider saving this to pickle file.
    dic = {
        "Business": ["Business", "Gas", "mall", "restaurant", "cafe", "hotel"],
        "Government (General)": ["Government buildings", "Ministry"],
        "Police": ["Police post", "prison", "Police"],
        "Military": ["military base", "air base", "navy"],
        "abortion related": "abortion clinic",
        "airports & aircraft": "airport",
        "Government (Diplomatic)": "embassy",
        "Educational Institution": ["school", "university"],
        "Food or Water Supply": ["water treatment plant", "farms"],
        "NGO": ["NGO", "Non governmental organisations"],
        "Maritime": ["port", "ferry"],
        "Journalists & Media": "newspaper company",
        "Other": ["fire station", "hospital"],  # wtf do you code for this
        "Private Citizens & Property": ["shopping malls", "markets"],
        "Religious Figures/Institutions": ["temples", "churches", "mosques"],
        "Terrorists/Non-State Militia": "militia",
        "Transportation": ["Train station", "Bus stations"],
        "Utilities": ["power plant", "water plant"],
        "Tourists": ["tourist spots"],
        "Telecommunications": ["Radio station", "TV station", "Internet provider"],
        "Violent Political Party": "political party",  # and this
    }
    name = dic[name]
    geolocator = Nominatim()
    location = []
    if type(name) != list:
        loc = geolocator.geocode(name + " " + country, exactly_one=False, timeout=10)
        if loc is not None:
            location.append(loc)
    else:
        for entry in name:
            loc = geolocator.geocode(entry + " " + country, exactly_one=False, timeout=10)
            if loc is not None:
                location.append(loc)
    location = list(itertools.chain(*location))  # flatten list
    data = []
    for entry in location:
        data.append([entry.latitude, entry.longitude])
    maps = gmaps.heatmap(data)
    gmaps.display(maps)
# ## Creazione della mappa
# 
# invece che uno scatterplot con dei raggi, la libreria ci consente solo di fare una heatmap (eventualmente pesata)
# 

# In[2]:

roma = pandas.read_csv("../data/Roma_towers.csv")
coordinate = roma[['lat', 'lon']].values


# In[3]:

heatmap = gmaps.heatmap(coordinate)
gmaps.display(heatmap)

# TODO scrivere che dietro queste due semplici linee ci sta un pomeriggio intero di smadonnamenti


# In[4]:

colosseo = (41.890183, 12.492369)


# In[5]:

import gmplot
from gmplot import GoogleMapPlotter

# gmap = gmplot.from_geocode("San Francisco")
Example #4
0
import gmaps

# load a Numpy array of (latitude, longitude) pairs
data = gmaps.datasets.load_dataset('taxi_rides')

map = gmaps.heatmap(data)
gmaps.display(map)