def main():
    """ Extracts latitude and longitude from the JSON feed, converts the list of dictionaries to a dataframe and then plot the coordinates via GeoPlotLib """
    url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_month.geojson"
    json_obj = get_json(url)
    entire_report_dictionary = json_loads_to_dictionary(json_obj)
    number_of_records, id_lon_lat = extract_records(entire_report_dictionary)[
        0], extract_records(entire_report_dictionary)[1]

    print("writing to file\n")
    with open('id_coordinates.csv', 'wt') as textiowrapper:
        textiowrapper.writelines('name,lon,lat\n')
        for i in range(number_of_records):
            x = 0
            id_num = str(id_lon_lat[i][x])
            lon = str(id_lon_lat[i][x + 1])
            lat = str(id_lon_lat[i][x + 2])
            s = id_num + ',' + lon + ',' + lat
            textiowrapper.writelines(s + '\n')
            del x
    textiowrapper.close()
    print("done writing to file\n")

    print("mapping the data\n")
    data = read_csv('id_coordinates.csv')
    geoplotlib.dot(data)
    geoplotlib.show()
Пример #2
0
    def getHistogramOfMatches(self):
        #self.updateLocationDataFile()

        data = read_csv(self.location_data)
        print(data)

        geoplotlib.hist(data, colorscale='sqrt', binsize=8)
        geoplotlib.show()
Пример #3
0
    def getDelaunayTriangulation(self):
        #self.updateLocationDataFile()

        data = read_csv(self.location_data)
        print(data)

        geoplotlib.delaunay(data, cmap='hot_r')
        geoplotlib.show()
Пример #4
0
    def getHeatmapOfMatches(self):
        #self.updateLocationDataFile()

        data = read_csv(self.location_data)
        print(data)

        geoplotlib.kde(data, bw=[5, 5])
        geoplotlib.show()
Пример #5
0
def geo_dot(file):      # file must have at top: name,lat,lon
    """
    Renders a geo dot graph
    :param file: path to file
    :return: saves image to temp/map.png
    """
    data = read_csv(file)
    geoplotlib.dot(data, point_size=3)
    # geoplotlib.show()
    geoplotlib.savefig('temp/map')
Пример #6
0
def geo_spatial(file):
    """
    Renders a geo spatial graph
    :param file: path to file
    :return: saves image to temp/spatial.png
    """
    data = read_csv(file)
    geoplotlib.graph(data, src_lat='lat_departure', src_lon='lon_departure', dest_lat='lat_arrival',
                     dest_lon='lon_arrival', color='hot_r', alpha=16, linewidth=2)
    # geoplotlib.show()
    geoplotlib.savefig('temp/spatial')
Пример #7
0
def test_graph():
    import geoplotlib
    from geoplotlib.utils import read_csv

    movement_data = read_csv('./data/graph_movement.csv')

    geoplotlib.graph(movement_data,
                     src_lat='SourceLat',
                     src_lon='SourceLon',
                     dest_lat='TargetLat',
                     dest_lon='TargetLon',
                     alpha=80,
                     linewidth=2,
                     color='inferno',
                     color_by='Weight',
                     levels=10)

    geoplotlib.show()
Пример #8
0
 def __init__(self):
     self.data = read_csv('data/taxi.csv')
     self.data = self.data.where(self.data['taxi_id'] == list(set(self.data['taxi_id']))[2])
     self.t = self.data['timestamp'].min()
     self.painter = BatchPainter()
Пример #9
0
        #convert list with [phi, lambda, h] to [name, lat, lon]
        Locations.append([Sname, deg(series[0].pos[0]), deg(series[0].pos[1])])

#path to SLOCs.csv
os.chdir(os.path.dirname(os.path.realpath(__file__)))

#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
Plotdata = read_csv('SLOCs.csv')
gp.set_bbox(BoundingBox(north=9, west=110, south=1, east=95))
gp.dot(Plotdata, color='red', point_size=2)
gp.labels(Plotdata, 'name', color='black', font_size=8, anchor_x='center')
gp.tiles_provider('positron')

gp.show()

'https://maps-for-free.com/layer/relief/z{Z}/row{Y}/{Z}_{X}-{Y}.jpg'
#ToDo: change tile to map from the web (url above)
Пример #10
0
"""
Example of voronoi layer with filled area
"""
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox

data = read_csv('data/bus.csv')
geoplotlib.voronoi(data,
                   cmap='Blues_r',
                   max_area=1e5,
                   alpha=255,
                   f_tooltip=lambda d: d['name'])
geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.show()
Пример #11
0
import sys
import numpy
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox
from geoplotlib.colors import ColorMap

data = read_csv('data/out_FL.csv')
#TODO: apply filtering here rather than when making the csv
bb = BoundingBox.from_points(lons=data['lon'], lats=data['lat'])

#TODO: utilize layers
#mark the station locations
geoplotlib.dot(data, color=[0, 0, 0, 255])

#TODO: show based on zoom level
#geoplotlib.labels(data,'Station Name (LEA)', color=[150,150,190,255], font_size=9, anchor_x='center')

#geoplotlib.voronoi(data, cmap='Blues_r', max_area=8e3, alpha=200, f_tooltip=lambda d:d['Station Name (LEA)'] )

geoplotlib.kde(data, cmap='Blues_r', bw=10, cut_below=1e-4, scaling='lin')

#geoplotlib.delaunay(data,cmap='hot_r')

##post
geoplotlib.set_bbox(bb)
geoplotlib.set_smoothing(True)
geoplotlib.show()
Пример #12
0
"""
Multiple examples of kernel density estimation visualization
"""
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox, DataAccessObject

data = read_csv('data/opencellid_dk.csv')

geoplotlib.kde(data, bw=[5, 5], cut_below=1e-6)

# lowering clip_above changes the max value in the color scale
#geoplotlib.kde(data, bw=[5,5], cut_below=1e-6, clip_above=1)

# different bandwidths
#geoplotlib.kde(data, bw=[20,20], cmap='coolwarm', cut_below=1e-6)
#geoplotlib.kde(data, bw=[2,2], cmap='coolwarm', cut_below=1e-6)

# linear colorscale
#geoplotlib.kde(data, bw=[5,5], cmap='jet', cut_below=1e-6, scaling='lin')

geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.show()
Пример #13
0
# Simple use of Geoplotlib
# Python v 3.6
# 5/15/2018

import geoplotlib
from geoplotlib.utils import read_csv


data = read_csv('data/mtb_ride_data.csv')
geoplotlib.dot(data)
geoplotlib.show()
Пример #14
0
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()
Пример #15
0
"""
Example of delaunay triangulation
"""
from geoplotlib.layers import DelaunayLayer
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox


data = read_csv('data/test_map2.csv')
geoplotlib.delaunay(data, cmap='hot_r')
geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.set_smoothing(True)
geoplotlib.show()
Пример #16
0
 def __init__(self):
     self.data = read_csv('data/taxi.csv')
     self.cmap = colorbrewer(self.data['taxi_id'], alpha=220)
     self.t = self.data['timestamp'].min()
     self.painter = BatchPainter()
Пример #17
0
# The p-value in this case is 0.7716, which is Bigger than the standard thresholds of 0.05 or 0.01, so we accept the null hypothesis and we can say there isn't any statistically significant difference between the daily average per day of the week and the general daily average.
# # Geo-Plot : All crimes - 2017

# In[116]:


data = crime_data_2017_DF.loc[crime_data_2017_DF['Resolved'] == 'Resolved',['Category','X','Y']]

data = data.rename(columns={"Category":"name",
                            "X":"lon",
                            "Y":"lat"})

data.to_csv("../data/GraphData_2017.csv", encoding="utf-8", index=False)
data.head()
data = read_csv('../data/GraphData_2017.csv')


# In[117]:


geoplotlib.dot(data)
geoplotlib.savefig('../plot/22.AllCrimes_2017')
#geoplotlib.show()


# # Map plot for Unresolved Arson : 2017 vs. 2016 (using Folium)

# In[118]:

Пример #18
0
 def __init__(self):
     self.data = read_csv('SLOCs.csv')
     self.cmap = colorbrewer(self.data['name'], alpha=220)
     self.t = self.data['timestamp'].min()
     self.painter = BatchPainter()
Пример #19
0
"""
Example of spatial graph
"""
import geoplotlib
from geoplotlib.utils import read_csv

data = read_csv('./data/flights.csv')
geoplotlib.graph(data,
                 src_lat='lat_departure',
                 src_lon='lon_departure',
                 dest_lat='lat_arrival',
                 dest_lon='lon_arrival',
                 color='hot_r',
                 alpha=16,
                 linewidth=2)
geoplotlib.show()
Пример #20
0
 def __init__(self):
     self.data = read_csv('data/taxi.csv')
     self.cmap = colorbrewer(self.data['taxi_id'], alpha=220)
     self.t = self.data['timestamp'].min()
     self.painter = BatchPainter()
Пример #21
0
"""
Multiple examples of kernel density estimation visualization
"""
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox, DataAccessObject

data = read_csv('data/opencellid_dk.csv')

geoplotlib.kde(data, bw=5, cut_below=1e-4)

# lowering clip_above changes the max value in the color scale
#geoplotlib.kde(data, bw=5, cut_below=1e-4, clip_above=.1)

# different bandwidths
#geoplotlib.kde(data, bw=20, cmap='PuBuGn', cut_below=1e-4)
#geoplotlib.kde(data, bw=2, cmap='PuBuGn', cut_below=1e-4)

# linear colorscale
#geoplotlib.kde(data, bw=5, cmap='jet', cut_below=1e-4, scaling='lin')

geoplotlib.set_bbox(BoundingBox.KBH)
geoplotlib.show()
Пример #22
0
)

schools = df.School

data = [go.Bar(x=df.School, y=df.Gap)]

py.iplot(data, filename='jupyter-basic_bar')

# # geoplotlib

# In[ ]:

import geoplotlib
from geoplotlib.utils import read_csv

data = read_csv('bus.csv')
geoplotlib.dot(data)
geoplotlib.show()

# # Direct plotting

# In[116]:

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(200, 6),
                  index=pd.date_range('1/9/2009', periods=200),
                  columns=list('ABCDEF'))

df.plot(figsize=(20, 10)).legend(bbox_to_anchor=(1, 1))
Пример #23
0
from math import degrees
from geoplotlib.colors import colorbrewer
from geoplotlib.utils import epoch_to_str, BoundingBox, read_csv

if __name__ == "__main__":
    path = sys.argv[1]
    files = os.listdir(path)
    stations = []
    for file in files:
        stations.append(parse_binary_llh(path + '/' + file)[0])
        print(stations[-1].name)

    file = open('tmp.csv', 'w')
    file.write('name,lat,lon\n')
    for stat in stations:
        name, lon, lat = (stat.name, degrees(stat.pos[0]),
                          degrees(stat.pos[1]))
        print(name, lon, lat)
        file.write(','.join([name, str(lon), str(lat)]) + '\n')
    file.close()

    data = read_csv('tmp.csv')
    print(type(data))
    geoplotlib.delaunay(data, cmap="hot_r")
    geoplotlib.labels(data,
                      'name',
                      color=[0, 0, 255, 255],
                      font_size=10,
                      anchor_x='center')
    geoplotlib.show()
Пример #24
0
import geoplotlib
from geoplotlib.utils import read_csv

data = read_csv('test_map2.csv')
geoplotlib.dot(data)
geoplotlib.show()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox
import sys

args = sys.argv
if len(args) != 2:
    sys.exit(f"usage: ./{args[0]} /path/to/.csv")

data = read_csv(args[1])
geoplotlib.kde(data, 5, cut_below=1e-4, show_colorbar=False)
geoplotlib.set_bbox(BoundingBox.USA)
geoplotlib.show()
Пример #26
0
"""
Example of voronoi layer with filled area
"""
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox


data = read_csv("data/bus.csv")
geoplotlib.voronoi(data, cmap="Blues_r", max_area=1e5, alpha=255, f_tooltip=lambda d: d["name"])
geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.show()
Пример #27
0
"""
Example of delaunay triangulation
"""
from geoplotlib.layers import DelaunayLayer
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox


data = read_csv('data/bus.csv')
geoplotlib.delaunay(data, cmap='hot_r')
geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.set_smoothing(True)
geoplotlib.show()
Пример #28
0
import geoplotlib
from geoplotlib.colors import colorbrewer
from geoplotlib.utils import epoch_to_str, BoundingBox, read_csv


data = read_csv('./data/metro.csv')
geoplotlib.dot(data, 'r')
geoplotlib.labels(data, 'name', color=[0,0,255,255], font_size=10, anchor_x='center')
geoplotlib.set_bbox(BoundingBox.KBH)
geoplotlib.show()
Пример #29
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()
Пример #30
0
import geoplotlib
from geoplotlib.colors import colorbrewer
from geoplotlib.utils import epoch_to_str, BoundingBox, read_csv

data = read_csv('./data/metro.csv')
geoplotlib.dot(data, 'r')
geoplotlib.labels(data,
                  'name',
                  color=[0, 0, 255, 255],
                  font_size=10,
                  anchor_x='center')
geoplotlib.set_bbox(BoundingBox.KBH)
geoplotlib.show()
Пример #31
0

#Scipy example of curve fitting noisy data
np.random.seed(0)

x = np.linspace(-1, 1, 2000)
y = np.cos(x) + 0.3*np.random.rand(2000)
p = np.polynomial.Chebyshev.fit(x, y, 90)

t = np.linspace(-1, 1, 200)
plt.plot(x, y, 'r.')
plt.plot(t, p(t), 'k-', lw=3)
plt.show()

#geoplot example of mapping patterns according to flight paths
data = read_csv('flights.csv')
geoplotlib.graph(data,
                 src_lat='lat_departure',
                 src_lon='lon_departure',
                 dest_lat='lat_arrival',
                 dest_lon='lon_arrival',
                 color='hot_r',
                 alpha=16,
                 linewidth=2)
geoplotlib.show()

# 3D plotting and visualization of signals using numpy
np.random.seed(1)

N = 70
Пример #32
0
#!/usr/bin/env python2
import geoplotlib
from geoplotlib.utils import read_csv, BoundingBox


data = read_csv('./network_density.csv')
geoplotlib.voronoi(data, line_color='b', line_width=1)
geoplotlib.set_bbox(BoundingBox.DK)
geoplotlib.show()
Пример #33
0
"""
Example of spatial graph
"""
import geoplotlib
from geoplotlib.utils import read_csv


data = read_csv('./data/flights.csv')
geoplotlib.graph(data,
                 src_lat='lat_departure',
                 src_lon='lon_departure',
                 dest_lat='lat_arrival',
                 dest_lon='lon_arrival',
                 color='hot_r',
                 alpha=16,
                 linewidth=2)
geoplotlib.show()
Пример #34
0
"""
Example of rendering markers
"""
import geoplotlib
from geoplotlib.utils import read_csv


metro = read_csv('./data/metro.csv')
s_tog = read_csv('./data/s-tog.csv')

geoplotlib.markers(metro, 'data/m.png', f_tooltip=lambda r: r['name'])
geoplotlib.markers(s_tog, 'data/s-tog.png', f_tooltip=lambda r: r['name'])
geoplotlib.show()
Пример #35
0
#!/usr/bin/env python2

import geoplotlib
from geoplotlib.utils import read_csv

data = read_csv('ui_network_density.csv')
geoplotlib.dot(data)
geoplotlib.show()
Пример #36
0
import geoplotlib
from geoplotlib.colors import colorbrewer
from geoplotlib.utils import epoch_to_str, BoundingBox, read_csv


data = read_csv('agentTest.csv')
plot points
geoplotlib.dot(data, 'b')
# plot the heatmap
#geoplotlib.hist(data, colorscale='sqrt', binsize=4)
# geoplotlib.show()