コード例 #1
0
ファイル: showMap.py プロジェクト: OmarMahfoze17/SchoolX
def showOnMap(address,locName,color):
    mplt.register_api_key('AIzaSyAnRmqg-kRi7wBE_v1wkujL12RqQV2dGIA')
    googleAddress, lat,lng  = getLocation(address)
    data = pd.DataFrame({
    'latitude':lat,
    'longitude':lng,
    'color':color,
    'name':locName
    })
    mplt.plot_markers(data)
コード例 #2
0
def mapsplot_register():
    """
    mapsplotlib Google Static Maps API key to enable queries to Google.
    """
    try:
        with open('data/api_key.txt', mode='r') as f:
            API_key = f.readline().strip()
            mplt.register_api_key(API_key)
            logger.info("Google static map API_KEY successfully registered")
    except:
        logger.error("mplt.register API_KEY failed")
        raise
コード例 #3
0
from mapsplotlib import mapsplot as mplt
import pandas as pd
if __name__ == '__main__':
    mplt.register_api_key('AIzaSyBuhS-obrP54G_ToqQAn3rnDY4hLxjy3Z4')
    with open(
            "../dataset/yelp_academic_dataset_business.json") as business_file:
        df = pd.read_json(business_file, lines=True)
    df = df[df['city'] == 'Phoenix']
    mplt.density_plot(df['latitude'], df['longitude'])
コード例 #4
0
import pandas as pd
from mapsplotlib import mapsplot as mplt


def string_to_coordinate_pair(input):
    spl = input.split(",")
    return (float(spl[0]), float(spl[1]))


f = open("googlemapskey.txt")
apikey = f.readline()[0:-1]
mplt.register_api_key(apikey)

data = pd.read_csv("2018-05-24T04.59.44.000.in",
                   sep="\t",
                   index_col=False,
                   encoding="ISO-8859-1")
points = set()

for idx, row in data.iterrows():
    split = row["path"].split(" ")
    #print(split)
    path = [string_to_coordinate_pair(x) for x in split[1:]]
    points |= set([path[0], path[-1]])
print(len(points))
dct = {'latitude': [], 'longitude': []}
for point in points:
    dct['latitude'].append(point[0])
    dct['longitude'].append(point[1])
df = pd.DataFrame(data=dct)
mplt.density_plot(df['latitude'], df['longitude'])
コード例 #5
0
with open('openrice_data.json') as json_data:
    original_data = json.load(json_data)

#get coords
for obj in original_data:
    lats.append(obj['address'][0])
    longs.append(obj['address'][1])

#get names
for obj in original_data:
    names.append(obj['name'])

# for x in range( len(lats) ):
#     temp = (lats[x], longs[x], reviews[x])
#     combo.append(temp)

# labels = ['latitude', 'longitude', 'reviews']
# df = pd.DataFrame.from_records(combo, columns=labels)

mplt.register_api_key('AIzaSyBWMZIWfp9p0bdqqDoEuJN3D4IuVKtUttU')


## Getting data and filtering
## Please register your key and design the correct query
key = "AIzaSyBWMZIWfp9p0bdqqDoEuJN3D4IuVKtUttU"
query = ""

# you might want a for loop to send and receive the query
url = "https://maps.googleapis.com/maps/api/distancematrix/json?" + query
res = requests.get(url).json()
コード例 #6
0
import csv
import string
import pandas as pd
import matplotlib.pyplot as plt
from mapsplotlib import mapsplot as mplt



mplt.register_api_key('AIzaSyC23WZ06xZau9Gw2R_ulYm6f0L5uxLdAeM')

def map(file_ext):
    print('Generating Map')
    f = open('distances_latlon'+file_ext+'.csv', 'r')
    reader = csv.reader(f)
    cities_list = list(reader)
    f.close()


    cities_lat = []
    cities_lon = []
    color = []
    size = []
    marker_list = []
    Upper = list(string.ascii_uppercase)
    digits = list(string.digits)
    markers = Upper+digits
    for i in range(len(cities_list)):
        cities_lat.append(float(cities_list[i][0]))
        cities_lon.append(float(cities_list[i][1]))
        color.append('blue')
        size.append('medium')
コード例 #7
0
'''
This is the only separated file since you need python 2.x to run it, activate the python 2.x env to make it work
'''
from utilities.twitterparser import Twitter_Parser
from mapsplotlib import mapsplot as mplt
from utilities.env import *

parser = Twitter_Parser()
tweets_with_location = parser.get_location_tweets(remove_locality=True)
mplt.register_api_key(maps_api_key)
mplt.density_plot(tweets_with_location['latitude'],
                  tweets_with_location['longitude'])
コード例 #8
0
#!/usr/bin/env
# -*- coding: utf-8 -*-
__author__ = "Powen Ko, www.powenko.com"

import pandas as pd
from mapsplotlib import mapsplot as mplt
df = pd.read_csv("data.csv")
mplt.register_api_key('your_google_api_key_here')
mplt.density_plot(df['latitude'], df['longitude'])
コード例 #9
0
ファイル: example_utm.py プロジェクト: malaclemys/mapsplotlib
from mapsplotlib import mapsplot as mplt
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.io import loadmat

mplt.register_api_key('xxx')  # xxx = your Google api key

fileLines_survey = 'lines_survey'
survey_data = loadmat('Lines/' + fileLines_survey + '.mat')

east_survey = survey_data['lines_survey'][:, 0]
north_survey = survey_data['lines_survey'][:, 1]
z_survey = survey_data['lines_survey'][:, 2]

eastn = east_survey[~np.isnan(east_survey)]
northn = north_survey[~np.isnan(north_survey)]
zn = z_survey[~np.isnan(z_survey)]

d_utm = {'east': eastn, 'north': northn, 'value': zn}
df_utm = pd.DataFrame(data=d_utm)

mplt.scatter_with_utm(df_utm['east'],
                      df_utm['north'],
                      df_utm['value'],
                      29,
                      'N',
                      maptype='satellite',
                      cbar=True,
                      title='Some Survey',
                      cLabel='Val',