3

I am using geopy to simply calculate the distance between two long,lat co-ordinates.

However I am confused on what scale the longitude should be on.

The latitude co-ordinated go from -90 to +90, and currently I've put my Longitude on a scale from 0-360 degrees - should this be -180 to 180 to satisfy :

great_circle(NYC, test).miles

where NYC and test are the co-ord pairs.

Thanks,

Izzy

Izzy888
  • 65
  • 2
  • 10

1 Answers1

3

Geopy Point latitude must be in range [-90; 90], longitude should be in range [-180; 180].

Longitude is automatically normalized (e.g. 185 is normalized to -175), while out-of-band latitudes would result in a ValueError being thrown. See the Point normalization testcases for getting the better idea on how normalization works: test/test_point.py

An example from docs for calculating distance between two points:

>>> from geopy import distance
>>> newport_ri = (41.49008, -71.312796)
>>> cleveland_oh = (41.499498, -81.695391)
>>> print(distance.distance(newport_ri, cleveland_oh).miles)
538.39044536
KostyaEsmukov
  • 848
  • 6
  • 11