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
ファイル: analytics.py プロジェクト: testy-rgb/TinderBot
    def getHistogramOfMatches(self):
        #self.updateLocationDataFile()

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

        geoplotlib.hist(data, colorscale='sqrt', binsize=8)
        geoplotlib.show()
コード例 #3
0
ファイル: analytics.py プロジェクト: testy-rgb/TinderBot
    def getDelaunayTriangulation(self):
        #self.updateLocationDataFile()

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

        geoplotlib.delaunay(data, cmap='hot_r')
        geoplotlib.show()
コード例 #4
0
ファイル: analytics.py プロジェクト: testy-rgb/TinderBot
    def getHeatmapOfMatches(self):
        #self.updateLocationDataFile()

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

        geoplotlib.kde(data, bw=[5, 5])
        geoplotlib.show()
コード例 #5
0
ファイル: graph.py プロジェクト: joonsauce/HTN-2020
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
ファイル: graph.py プロジェクト: joonsauce/HTN-2020
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
ファイル: taxi.py プロジェクト: JaredChung/geoplotlib
 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
ファイル: taxi.py プロジェクト: johnlanda/geoplotlib-fixed
 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
ファイル: kde.py プロジェクト: JaredChung/geoplotlib
"""
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()
コード例 #25
0
#!/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
ファイル: delaunay.py プロジェクト: JaredChung/geoplotlib
"""
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
ファイル: labels.py プロジェクト: JaredChung/geoplotlib
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
ファイル: plot.py プロジェクト: oychang/WiFiGatherer
#!/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
ファイル: labels.py プロジェクト: johnlanda/geoplotlib-fixed
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
ファイル: vplot.py プロジェクト: oychang/WiFiGatherer
#!/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
ファイル: plot.py プロジェクト: oychang/WiFiGatherer
#!/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
ファイル: graphMap.py プロジェクト: javierazd1305/foliumMaps
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()