2

I'm trying to obtain coordinates for road intersections similar to how you can type '1100 N & 300 W' in Google Maps, but given a table with tens of thousands of pairs. Does anyone know of a geolocation module that supports that type of search?

I'm testing geopy, which can easily locate one roadway and even includes the option to limit the search by an area (i.e. city or county), but after several attempts to change my test intersection wording still can't go beyond locating a single roadway.

I've tried simply changing the road names to be more descriptive, ie CR 1100 N and CR 300 W...W CR 1100 N and N CR 300 W, but the inclusion of CR actually throws an error entirely.

Here's what I have so far...

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="agent", format_string="%s, Madison County, IN")
location = geolocator.geocode("1100 N & 300 W")
print(location.address)
print(location.latitude)
print(location.longitude)

And the results:

Address: North 300 West, Anderson, Madison County, Indiana, 46011, USA

Latitude: 40.142406 Longitude: -85.728747

Expected Lat: 40.262935 Expected Lon: -85.728308

trphelps15
  • 21
  • 3

2 Answers2

0

Try: https://geocoder.ca/1100%20N%20&%20300%20W%20ALEXANDRIA,%20IN

This Cross Street location. (1100 N & 300 W ALEXANDRIA IN) 40.262950, -85.72831

Also as JSON: https://geocoder.ca/1100%20N%20&%20300%20W%20ALEXANDRIA,%20IN?json=1

{ "standard" : { "staddress" : "N & 300", "stnumber" : "1100", "postal" : "46063", "street1" : "1100 N ", "city" : "Alexandria", "prov" : "IN", "street2" : "300 W ", "confidence" : "0.8" }, "longt" : "-85.728310", "TimeZone" : "America/Indiana/Indianapolis", "AreaCode" : "765", "latt" : "40.262950"}

Ervin Ruci
  • 829
  • 6
  • 10
  • That is the type of input/output I’m hoping for, but as a batch code. I want to be able to feed many thousands of street pairs and have them produce the latitude and longitude. Is there a way to feed many pairs to the website through a python script without having to pull up the website? – trphelps15 Jun 15 '19 at 00:12
  • No, there is no batch mode. You need to loop through, send your requests one at a time. – Ervin Ruci Jun 15 '19 at 01:19
0

This is another approach to batch, I have to do something similar. Note you will need an active internet connection.

# Python 3.6
from geopy.geocoders import ArcGIS

def my_LatLong(address):
    n = ArcGIS().geocode(address)
    # n is a list [0] = street names [1] = lat/long
    return n[1]

with Open('file') as streets: 
# do something
# or you can us pandas.

    for i in streets:
        # i = line entry of street intersections
        print(my_LatLong(i))
        # write to file or do something
           
onxx
  • 1,435
  • 3
  • 13
  • 22