def get_reference_address_location(self): """ get Lat/Lng coordinates for the address currently used as reference address by the WebGeocoder instance """ from geopy.geocoders import Nominatim as nom # https://geopy.readthedocs.io/en/stable/ geolocator = nom(user_agent='pnj-python-web-geocoder') address, (latitude, longitude) = geolocator.geocode(self.get_reference_address()) return (latitude, longitude) # return just the lat & lng, in a tuple
def count_number_of_labels_per_postcode(unieke_postcodes, unieke_energielabels, relevant_data): number_of_energielabels_per_postcode = np.zeros( (len(unieke_postcodes), len(unieke_energielabels))) geolocator = nom() for a in range(len(relevant_data)): for i in range(len(unieke_postcodes)): if relevant_data[a, 0] == unieke_postcodes[i]: if relevant_data[a, 1] == 'A': number_of_energielabels_per_postcode[i, 0] += 1 elif relevant_data[a, 1] == 'A+': number_of_energielabels_per_postcode[i, 1] += 1 elif relevant_data[a, 1] == 'A++': number_of_energielabels_per_postcode[i, 2] += 1 elif relevant_data[a, 1] == 'B': number_of_energielabels_per_postcode[i, 3] += 1 elif relevant_data[a, 1] == 'C': number_of_energielabels_per_postcode[i, 4] += 1 elif relevant_data[a, 1] == 'D': number_of_energielabels_per_postcode[i, 5] += 1 elif relevant_data[a, 1] == 'E': number_of_energielabels_per_postcode[i, 6] += 1 elif relevant_data[a, 1] == 'F': number_of_energielabels_per_postcode[i, 7] += 1 elif relevant_data[a, 1] == 'G': number_of_energielabels_per_postcode[i, 8] += 1 return number_of_energielabels_per_postcode
def calculate_locations_of_postcodes(begin_postcode, eind_postcode, postcodeandcolorlabel): location = np.zeros((len(postcodeandcolorlabel), 2)) kleur = np.empty([len(postcodeandcolorlabel), 1], dtype=np.dtype('a7')) geolocator = nom() for i in range(len(postcodeandcolorlabel)): if int(postcodeandcolorlabel[i, 0][:4]) >= int(begin_postcode) and int( postcodeandcolorlabel[i, 0][:4]) < int(eind_postcode): #print postcodeandcolorlabel[i,0] kleur[i] = postcodeandcolorlabel[i, 1] lat = geolocator.geocode(postcodeandcolorlabel[i, 0]) location[i, 0] = lat.longitude location[i, 1] = lat.latitude return location, kleur
def funlongitudes_latitudes(students_per_locationin): print students_per_locationin[:, 1], len(students_per_locationin) #for b in range geolocator = nom() geo_students = np.zeros((len(students_per_locationin), 5)) for i in range(len(students_per_locationin)): if students_per_locationin[i, 1] != "elders buiten NED": print students_per_locationin[i, 1] lat = geolocator.geocode(students_per_locationin[i, 0]) geo_students[i, 0] = lat.longitude geo_students[i, 1] = lat.latitude let = geolocator.geocode(students_per_locationin[i, 1]) geo_students[i, 2] = let.longitude geo_students[i, 3] = let.latitude geo_students[i, 4] = students_per_locationin[i, 2] print geo_students return geo_students
def getTimezone(pCity, pState): geolocator = nom() cityState = str(pCity + " " + pState) location = geolocator.geocode(cityState) print('lat/lon: ', (location.latitude, location.longitude)) googleApiURL = "https://maps.googleapis.com/maps/api/timezone/xml?location=" + str( location.latitude) + "," + str( location.longitude ) + "×tamp=1331161200&key=" + googleAuth.GOOGLE_API_KEY soupedGoogle = soupTheLink.soupTheLink(googleApiURL) timezoneId = soupedGoogle.time_zone_id.get_text() timezoneName = soupedGoogle.time_zone_name.get_text() print('timezoneId: ', timezoneId) print('timezoneName: ', timezoneName) if len(timezoneId) == 0: timezoneId = 'No timezone ID found.' if len(timezoneName) == 0: timezoneName = 'No timezone name found.' return timezoneId, timezoneName
## Date: 12/14/20 ## Authors: Jason Baker, Joseph Castro, Julian Fortin, Emerson Jimenez ## Github: https://github.com/PHRZNForeign/Team31_CST205 ## Abstract: This program opens a visual GUI for the user to fill in location names and it performs operations to show relevant locational data using geopy API import sys from PySide2.QtWidgets import * from PySide2.QtCore import * # pip install geopy import geopy from geopy.geocoders import Nominatim as nom from geopy.distance import geodesic # geopy API key, using a generic name for user-agent gives a 403 forbidden error geolocator = nom(user_agent="cst205final-project") class MyWindow(QWidget): def __init__(self): super().__init__() # set name and dimensions for out GUI box self.setWindowTitle('Geography lookup') self.setGeometry(100,100,500,300) vbox = QVBoxLayout() # line edits used for entering in the locations what will talk to the geopy api self.my_line = QLineEdit(self) self.my_line2 = QLineEdit(self) self.my_lbl = QLabel('Enter a location name:') self.my_lbl2 = QLabel('')
def reverseGeocode(latitude, longitude): geolocator = nom() return geolocator.reverse(latitude, longitude)