Exemplo n.º 1
0
def epa_radinfo():
    """
    Find facilities in a zipcode that have EPA permits to pollute public
    water sources.
    """
    if 'format' in request.args:
        return views.send_static_file('js/all_facilities.json')
    elif 'address' not in request.args:
        return redirect(url_for('epa'))
    address = request.args['address']
    try:
        mapq.key("Fmjtd|luua2lu2ll,80=o5-hy82u")
        geo_data = mapq.geocode(address)
    except:
        return redirect(url_for('epa'))
    else:
        # Find the address state.
        state, coords = address_details(geo_data)
        # Search against the dict of radiation location states.
        closest, mileage = nearest_facility(state, coords)
        # Return miles and address of nearest location.
    latitude, longitude = closest
    latitude, longitude = round(latitude, 2), round(longitude, 2)
    mileage = int(round(mileage))
    return render_template('epa_data/radinfo.html', mileage=mileage,
                           latitude=latitude, longitude=longitude)
def con_gps(address):

	Con_key='YvRfEjkHuVoPigHYHQNlxBRvL1Kn2UKb'
#Con_sec = 'dI6pXbJaFu6pmrie'
	mapq.key(Con_key)#,Con_sec)
	gps=mapq.geocode(address)['displayLatLng']
	return float( gps['lat']),float(gps['lng'])
Exemplo n.º 3
0
def con_gps(address):

	Con_key='YvRfEjkHuVoPigHYHQNlxBRvL1Kn2UKb'
#Con_sec = 'dI6pXbJaFu6pmrie'
	mapq.key(Con_key)#,Con_sec)
	gps=mapq.geocode(address)['displayLatLng']
	return float( gps['lat']),int(gps['lng'])
Exemplo n.º 4
0
	def __init__(self,locationFolder,verbose=0):
		self.locationFolder=locationFolder;
		self.verbose=verbose
		mapq.key(self.mapQuestKey)
Exemplo n.º 5
0
import mapq
import csv
import json
import numpy as np
import re
#mapq.key
Con_key = 'YvRfEjkHuVoPigHYHQNlxBRvL1Kn2UKb'
#Con_sec = 'dI6pXbJaFu6pmrie'
mapq.key(Con_key)  #,Con_sec)


#mapq.secret(Con_sec)
def togps(numlines):
    cl = open('mess_clean4.txt', 'r')
    fl = open('crime_gps.txt', 'a')
    lines = cl.readlines()
    count = -1

    #print lines
    for line in lines[numlines:len(lines)]:
        count += 1
        dummy = []
        #print line
        if ('N/A' in line):
            pass
        else:
            for m in re.finditer("              ", line):
                t = m.end() + 1
        #print t

            address = line[t:-2]
import mapq
import csv
import json
import numpy as np
import re
#mapq.key
Con_key='YvRfEjkHuVoPigHYHQNlxBRvL1Kn2UKb'
#Con_sec = 'dI6pXbJaFu6pmrie'
mapq.key(Con_key)#,Con_sec)
#mapq.secret(Con_sec)
def togps(numlines):
	cl = open('mess_clean4.txt','r')
	fl = open('crime_gps.txt','a')
	lines = cl.readlines()
	count=-1

#print lines
	for line in lines[numlines:len(lines)]:
		count+=1
		dummy=[]
		#print line
		if ('N/A' in line):
			pass
		else:
			for m in re.finditer("              ",line):
				t=m.end()+1
		#print t
		
			address= line[t:-2]
#			print address
Exemplo n.º 7
0
# @param string file_in
# The csv file containing the data
#
# @param string api_key
# The MapQuest API key

import csv
import sys
import mapq

file_out = sys.argv[1] 
file_in = sys.argv[2]
api_key = sys.argv[3]

# Mapquest API key
mapq.key(api_key)

# This function loops over all the rows in the file and fetches the coordinates
# for the specified address from Mapquest.
# uid = column containing unique ID
# a = address (street) column
# c = city column
# s = state column
# z = zip column
def geocode(id,a,c,s,z):
	with open(file_in, 'rb') as ifile:
		reader = csv.reader(ifile)
		i = 0

		print 'Starting to fetch the coordinates...'