Giter Club home page Giter Club logo

Comments (6)

wolframteetz avatar wolframteetz commented on September 3, 2024

Test with large radius

(---begin---)
# Parse the json to pull out the geocode
if not d['status'] == 'OK':
full_url = full_url + '&radius=5000'
print "Radius 5000"
# Request geocode from address
req = urllib2.Request(full_url)
opener = urllib2.build_opener()
f = opener.open(req)
d = simplejson.load(f)
if not d['status'] == 'OK':
raise Exception('Error. Google Maps API return status: {}'.format(d['status']))
geocode = [d['results'][0]['geometry']['location']['lat'],
d['results'][0]['geometry']['location']['lng']]
return geocode
(---)

Iteration 0
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
Iteration 6
Radius 5000
Traceback (most recent call last):
File "", line 1, in
File "isocronut.py", line 424, in generate_isochrone_map
iso = get_isochrone(origin, duration, number_of_angles, tolerance, access_type, config_path)
File "isocronut.py", line 394, in get_isochrone
iso[i] = geocode_address(data[0][i], access_type, config_path)
File "isocronut.py", line 233, in geocode_address
raise Exception('Error. Google Maps API return status: {}'.format(d['status']))
Exception: Error. Google Maps API return status: ZERO_RESULTS

Failed, so it is some other issue

from isocronut.

wolframteetz avatar wolframteetz commented on September 3, 2024

Debug output appended

CALL

python
import sys
reload(sys)
sys.setdefaultencoding('utf8')
origin=[48.10892,11.451958]
duration = 90
number_of_angles=48
tolerance = 2
import isocronut
isochrone = isocronut.generate_isochrone_map(origin, duration, number_of_angles, tolerance)
from subprocess import call
call(["open", "isochrone.html"])

CODE (in get_isochrone)

for i in range(number_of_angles):
    print "Geocoding #",i
    print "Data ",data[0][i]
    iso[i] = geocode_address(data[0][i], access_type, config_path)
    time.sleep(0.5)

OUTPUT

isochrone = isocronut.generate_isochrone_map(origin, duration, number_of_angles, tolerance)
Iteration 0
Iteration 1
Iteration 2
Iteration 3
Iteration 4
Iteration 5
Iteration 6
Geocoding # 0
Data Ölschlag 3, 92334 Berching, Germany
Geocoding # 1
Data Schweinkofen 21, 92345 Dietfurt, Germany
Geocoding # 2
Data Essing, Germany
Geocoding # 3
Data Auf der Winzerer Höhe, 93059 Regensburg, Germany
Geocoding # 4
Data Unnamed Road, 93073 Neutraubling, Germany
Geocoding # 5
Data Holztraubacher Str. 15, 84066 Mallersdorf-Pfaffenberg, Germany
Geocoding # 6
Data SR65, 94339 Leiblfing, Germany
Geocoding # 7
Data Freundorf 2, 94569 Stephansposching, Germany
Geocoding # 8
Data Marklkofen, Germany
Geocoding # 9
Data Elsenbach 7, 84494 Neumarkt-Sankt Veit, Germany
Geocoding # 10
Data Hölzling 5, 84568 Pleiskirchen, Germany
Geocoding # 11
Data Kraiburg, Germany
Geocoding # 12
Data Aigner 16, 83342 Tacherting, Germany
Geocoding # 13
Data TS31, 83352 Altenmarkt, Germany
Geocoding # 14
Data Betonstraße 20, 83362 Surberg, Germany
Geocoding # 15
Data Unnamed Road, 83324 Ruhpolding, Germany
Geocoding # 16
Data Unterbergen 4, 83246 Unterwössen, Germany
Geocoding # 17
Data Kohlentalstraße 8, 6385 Schwendt, Austria
Geocoding # 18
Data Stadtberg, 6351 Kufstein, Austria
Geocoding # 19
Data Almen 4, 6335 Almen, Austria
Geocoding # 20
Data Unnamed Road, 83700 Rottach-Egern, Germany
Geocoding # 21
Data Unnamed Road, 83708 Kreuth, Germany
Geocoding # 22
Data Unnamed Road, 83661 Lenggries, Germany
Geocoding # 23
Data Unnamed Road, 83661 Lenggries, Germany
Geocoding # 24
Data Gemeinde Vomp, Austria
Geocoding # 25
Data Unnamed Road, 6108, Austria
Waiting 5s
Radius 5000
Traceback (most recent call last):
File "", line 1, in
File "isocronut.py", line 429, in generate_isochrone_map

File "isocronut.py", line 399, in get_isochrone
time.sleep(0.5)
File "isocronut.py", line 236, in geocode_address
geocode = [d['results'][0]['geometry']['location']['lat'],
Exception: Error. Google Maps API return status: ZERO_RESULTS

from isocronut.

wolframteetz avatar wolframteetz commented on September 3, 2024

Exception can be caught with s.th. like this, but should be failsafe for i=0. Better idea?

I don't understand why there have to be these addresses anyway ;) I think they are also the primary reason for the outliers - geocoding Unknown Road, can lead to surprising results of course...

for i in range(number_of_angles):
    print "Geocoding #",i
    print "Data ",data[0][i]
    try:
        iso[i] = geocode_address(data[0][i], access_type, config_path)
    except:
        if i > 0:
            print "Exception caught for isocoding"
            iso[i] = iso[i-1]           
    time.sleep(0.1)

from isocronut.

drewfustin avatar drewfustin commented on September 3, 2024

I think the proper way to handle this is:

a) initialize iso with None:

iso = [None] * number_of_angles

b) don't bother resetting iso[i] for i that fails:

    try:
        iso[i] = geocode_address(data[0][i], access_type, config_path)
    except:
        print "Exception caught for isocoding"

c) then after the i for loop, throw out all angles that failed, and fail ultimately if none of them work at all:

iso = [x for x in iso if x is not None]
if len(iso) == 0:
    raise Exception('No valid points along the isochrone were found.')

Thoughts?

from isocronut.

wolframteetz avatar wolframteetz commented on September 3, 2024

Proper but still very messy because translating a known location to "unknown road, cleveland ohio" and back introduced terrible noise outside of city areas and quite some outliers.

Working on the mapbox solution instead, it's much nicer anyway.

from isocronut.

drewfustin avatar drewfustin commented on September 3, 2024

Yeah, my other thought was: as a post-process, determine outlying radii using some outlier detection method and through those out.

from isocronut.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.