[SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" (/thread-33119.html) |
[SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" - Winfried - Mar-30-2021 Hello, I need to draw a circle around a location set by its latitude + longitude. For some reason, geopy isn't happy with the following: import geopy import geopy.distance import gpxpy import gpxpy.gpx center = geopy.Point(51.519, -0.1263) d = geopy.distance.distance(kilometers=5) for index in range(0, 359): final = d.destination(point=center, bearing=index).format_decimal() #Does display two items successfully, separated by comma print(final) #ValueError: too many values to unpack (expected 2) #latitude,longitude = d.destination(point=center, bearing=index).format_decimal() #AttributeError: 'str' object has no attribute 'latitude' #latitude,longitude = final.latitude,final.longitudeAny idea why? Thank you. RE: [geopy] "ValueError: too many values to unpack (expected 2)" - buran - Mar-30-2021 Point.format_decimal() method return string (see source code). So, when you try to unpack it it try to bind every char to a name.
RE: [geopy] "ValueError: too many values to unpack (expected 2)" - Winfried - Mar-30-2021 Thank you! latitude,longitude = d.destination(point=center, bearing=index).format_decimal().split(',') |