1

When I run the following code the negative sign get's removed for some reason and I always end up with a positive latitude and longitude.

Code:


def extract_reduced_accuracy_lat_long(location):
    if location:
        loc = Location(location)
        print("location is")
        print(loc)
        lat = round(float(loc.lat.degrees), 1)
        lng = round(float(loc.lng.degrees), 1)
        return lat, lng
    else:
        return None, None



lat, long = extract_reduced_accuracy_lat_long("-40.20361-40.20361")
print(lat)
print(long)

output:

location is
<iso6709.iso6709.Location object at 0x7fc37447ae10>
40.2
40.2

Any idea why this is happening. Thanks

user2875230
  • 195
  • 1
  • 2
  • 14

2 Answers2

0

Let's try to wrap in parentheses your coordinates like this:

lat, long = extract_reduced_accuracy_lat_long([-40.20361, -40.20361])
L0ndl3m
  • 141
  • 5
0

You must use brackets to contain your coordinate points. This way it is taking two points at arguments, separated by a comma. Like so:

lat,long=extract_reduced_accuracy_lat_long([-40.20361,-40.20361])
acharb07
  • 13
  • 5