Python Forum
[SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)"
#1
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.longitude
Any idea why?

Thank you.
Reply
#2
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you!

latitude,longitude = d.destination(point=center, bearing=index).format_decimal().split(',')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Too much values to unpack actualpy 3 481 Feb-11-2024, 05:38 PM
Last Post: deanhystad
  ValueError - Formatting issue when values enter thousands phillyfa 4 1,187 Apr-20-2023, 06:22 PM
Last Post: phillyfa
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,144 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  [Solved]Return values from npyscreen Extra 2 1,172 Oct-09-2022, 07:19 PM
Last Post: Extra
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,157 May-17-2022, 11:38 AM
Last Post: Larz60+
  unpack dict menator01 1 1,197 Apr-09-2022, 03:10 PM
Last Post: menator01
  ValueError: not enough values to unpack (expected 4, got 1) vlearner 2 6,336 Jan-28-2022, 06:36 PM
Last Post: deanhystad
  Cannot unpack non-iterable NoneType object, i would like to ask for help on this. Jadiac 3 8,931 Oct-18-2020, 02:11 PM
Last Post: Jadiac
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 6,014 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  struct.unpack failed Roro 2 3,364 Jun-13-2020, 05:28 PM
Last Post: DreamingInsanity

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020