How to use the geopy.geocoders.Nominatim function in geopy

To help you get started, we’ve selected a few geopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celliott / weather_exporter / docker / src / weather_exporter / exporter.py View on Github external
def get_location(city):
  location = Nominatim(timeout=int(options['geocode_timeout'])).geocode(city)
  return location
github plotly / dash-phylogeny / generation_stat.py View on Github external
def get_lat(city):
    '''
    Example:
    location = geolocator.geocode("Chicago Illinois")
    return:
    Chicago, Cook County, Illinois, United States of America
    location.address    location.altitude   location.latitude   location.longitude  location.point      location.raw
    '''
    geolocator = Nominatim()
    location = geolocator.geocode(city, timeout=1000)
    return location.latitude
github cassiogiehl / AddressToLatLong / AddresToLatLong.py View on Github external
import pandas as pd
from geopy.geocoders import Nominatim
import xlsxwriter

df = pd.read_excel(r'C:\Users\Cássio Giehl\Documents\EnderecosMKT.xls')

geolocator = Nominatim(user_agent="Geolocation")

workbook = xlsxwriter.Workbook(r'C:\Users\Cássio Giehl\Documents\AddressWithLatLong.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': True})

worksheet.write('A1', 'Logradouro', bold)
worksheet.write('B1', 'Numero', bold)
worksheet.write('C1', 'Bairro', bold)
worksheet.write('D1', 'Cidade', bold)
worksheet.write('E1', 'Estado', bold)
worksheet.write('F1', 'Lat Long', bold)
worksheet.write('G1', 'Detalhamento', bold)

for i in range(0, len(df)):
    
    local = "{}".format(df['Nome Logradouro'][i])
github jedie / django-for-runners / for_runners / geo.py View on Github external
>>> address = reverse_geo("51.6239133", "6.9749074")
    >>> address.short
    'Feldhausen, Bottrop'
    >>> address.full
    'Movie Park Germany, 1, Warner-Allee, Kuhberg, Feldhausen, Bottrop, Regierungsbezirk Münster, Nordrhein-Westfalen, 46244, Deutschland'

    >>> reverse_geo("52.518611", "13.376111").short
    'Berlin Tiergarten'

    :return: Address named tuple
        short : string
            The "sort" Address
        full : string
            The "full" Address
    """
    geolocator = Nominatim()
    location = geolocator.reverse("%s, %s" % (lat, lon))

    short_address = construct_short_address(address=location.raw["address"])

    return Address(short_address, location.address)
github noqqe / rvo / rvo / validate.py View on Github external
def validate_location(ctx, param, value):

        if value is None:
            return value

        geolocator = Nominatim()
        location = geolocator.geocode(value)

        if location is None:
            raise click.BadParameter('Location \"%s\" could not be found' % value)

        return location
github nasa-jpl-memex / GeoParser / plugin / geoparser_plugin / server / __init__.py View on Github external
from girder import constants, events
from girder.utility.model_importer import ModelImporter
from girder.utility.webroot import Webroot

from girder.api.rest import Resource, loadmodel, RestException
from girder.api.describe import Description
from girder.api import access

from solr import IndexUploadedFilesText, QueryText, IndexLocationName, QueryLocationName, IndexLatLon, QueryPoints


from tika import parser
from geograpy import extraction
from geopy.geocoders import Nominatim

geolocator = Nominatim()


class GeoParserJobs(Resource):
    def __init__(self):
        self.resourceName = 'geoparser_jobs'
        self.route('GET', ("extract_text",), self.extractText)
        self.route('GET', ("find_location",), self.findLocation)
        self.route('GET', ("find_lat_lon",), self.findLatlon)
        self.route('GET', ("get_points",), self.getPoints)


    @access.public
    def extractText(self, params):
        '''
        Using Tika to extract text from given file
        and return the text content.
github TheCurryMan / MedicAI / locationBasedAnalysis.py View on Github external
def getLocations(disease, number):

    #Initialize Nominatim
    geolocator = Nominatim()

    # Initialize Firebase Application and get user data
    fb = firebase.FirebaseApplication("https://medicai-4e398.firebaseio.com/", None)
    data = fb.get('/Diseases', None)
    current_user = fb.get('/Users', None)[number]

    total = 0

    for i in data:
        if i == disease:

            #Get the details of user's current location
            curLoc = geolocator.geocode(current_user["location"])
            curLatLong = (curLoc.latitude, curLoc.longitude)
            for location in data[i]:
                #Get the details of each location in firebase of disease provided
github khanhnamle1994 / trip-optimizer / Bio-Inspired-Algorithms / aco_main.py View on Github external
import pandas as pd
import numpy as np
from aco import ACO, Graph
from plot import plot
import datetime
import pickle
import argparse
from geopy.exc import GeocoderTimedOut
from geopy.geocoders import Nominatim
import xgboost as xgb
import pprint
import matplotlib.pyplot as plt

filename = "../xgb_model.sav"
loaded_model = pickle.load(open(filename, 'rb'))
geolocator = Nominatim(user_agent="aco-application")


def time_cost_between_points(loc1, loc2, passenger_count, store_and_fwd_flag=0):
    """
    Calculate the time (in minutes) between two points
    using the trained XGB model
    """
    # Hardcode the date to get consistent calculations
    date_list = [27, 5, 2016]  # May 27, 2016

    year = int(date_list[2])
    month = int(date_list[1])
    day = int(date_list[0])

    my_date = datetime.date(year, month, day)
github RasaHQ / rasa-demo / demo / community_events.py View on Github external
def get_country_for(city: Text) -> Optional[Text]:
    from geopy.geocoders import Nominatim

    ssl_context = ssl.create_default_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE

    geo_locator = Nominatim(ssl_context=ssl_context)
    location = geo_locator.geocode(city, language="en", addressdetails=True)

    if location:
        return location.raw["address"].get("country")

    return None
github aliss / ALISS / aliss / forms / location.py View on Github external
def nominatim_geocode(street_address, locality, postal_code):
        query = { 'street': street_address, 'city': locality, 'postalcode': postal_code }
        geolocator = Nominatim(country_bias='gb',user_agent="aliss_django")
        return geolocator.geocode(query, exactly_one=True, timeout=5)