Home > Net >  Getting only positive values for latitude and longitude with iso60709 Location
Getting only positive values for latitude and longitude with iso60709 Location

Time:03-30

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

CodePudding user response:

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

lat, long = extract_reduced_accuracy_lat_long([-40.20361, -40.20361])

CodePudding user response:

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])
  • Related