Thanks for hints
result = coder.geocode()
place, (lat, lon) = result
locality = result.locality
Take a look at the code I wrote for the community almanac to get an idea:
Douglas Mayle
> --
> You received this message because you are subscribed to the Google Groups "geopy" group.
> To post to this group, send email to ge...@googlegroups.com.
> To unsubscribe from this group, send email to geopy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/geopy?hl=en.
>
from geopy import geocoders,util
lat = 50.326880
lon = 14.543244
def result_with_locality(res):
first = None
for x in res:
if not first: first = x
if x and x.locality and x.administrative: return x
return first
geoc = geocoders.Google('xyz')
result = result_with_locality(geoc.geocode('%f,
%f'%(lat,lon),exactly_one=False))
place, (lat, lng) = result
if result.locality and result.administrative: print '%s, %s' %
(result.locality, result.administrative)
Traceback (most recent call last):
File "./reverse.py", line 17, in <module>
result = result_with_locality(geoc.geocode('%f,
%f'%(lat,lon),exactly_one=False))
File "./reverse.py", line 13, in result_with_locality
if x and x.locality and x.administrative: return x
AttributeError: 'RichResult' object has no attribute 'locality'
--
/) = http://blog.starenka.net = ,~~.
/\___/\ (( *- www.starenka.net -* ( 6 )-_,
\`@_@'/ )) "Life is what happens when you're busy (\___ )=='-'
{_:Y:.}_// making other plans." - John Lennon \ . ) )
-={_}^-'{_}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-~'`~'`~'`~'`~
PS. Never eat yellow snow ;)
Doug