({{, (RefLink[GeoDistance, paclet:ref/GeoDistance])[{(Subscript[lat, 1]),(Subscript[lon, 1])},{(Subscript[lat, 2]),(Subscript[lon, 2])}] 
gives the geodesic distance between latitude-longitude positions on the Earth.}, {, (RefLink[GeoDistance, paclet:ref/GeoDistance])[(Subscript[loc, 1]),(Subscript[loc, 2])]
gives the distance between locations specified by position objects or geographical entities.}, {, (RefLink[GeoDistance, paclet:ref/GeoDistance])[{(Subscript[loc, 1]),…,(Subscript[loc, n])}]
gives the total distance from (Subscript[loc, 1]) to (Subscript[loc, n]) through all the intermediate (Subscript[loc, i]).}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[GeoDistance, paclet:ref/GeoDistance])[(Subscript[loc, 1]),(Subscript[loc, 2])] gives the distance between locations (Subscript[loc, 1]) and (Subscript[loc, 2]) as measured along the geodesic joining them on the surface of the reference ellipsoid. Heights are ignored.

The result is returned as a (RefLink[Quantity, paclet:ref/Quantity]) object with dimensions of length. The unit used can be chosen with the option (RefLink[UnitSystem, paclet:ref/UnitSystem]), which has (RefLink[$UnitSystem, paclet:ref/$UnitSystem]) as default value.

Latitudes and longitudes can be given as numbers in degrees, as DMS strings, or as (RefLink[Quantity, paclet:ref/Quantity]) angles.

Position objects in (RefLink[GeoDistance, paclet:ref/GeoDistance])[(Subscript[loc, 1]),(Subscript[loc, 2])] can be given as (RefLink[GeoPosition, paclet:ref/GeoPosition]), (RefLink[GeoPositionXYZ, paclet:ref/GeoPositionXYZ]), (RefLink[GeoPositionENU, paclet:ref/GeoPositionENU]), or (RefLink[GeoGridPosition, paclet:ref/GeoGridPosition]) objects.

In (RefLink[GeoDistance, paclet:ref/GeoDistance])[(Subscript[loc, 1]),(Subscript[loc, 2])], the (Subscript[loc, i]) can be (RefLink[Entity, paclet:ref/Entity]) objects with domains such as "City", "Country", and "AdministrativeDivision".

For entities corresponding to extended geographic regions, (RefLink[GeoDistance, paclet:ref/GeoDistance]) by default computes the minimum distance between any points in the regions.

(RefLink[GeoDistance, paclet:ref/GeoDistance])[(Subscript[loc, 1]),(Subscript[loc, 2])] by default uses the reference ellipsoid associated with the datum for (Subscript[loc, 1]).

(RefLink[GeoDistance, paclet:ref/GeoDistance]) and (RefLink[GeoDirection, paclet:ref/GeoDirection]) solve the geodetic inverse problem.

(RefLink[GeoDistance, paclet:ref/GeoDistance]) has option (RefLink[DistanceFunction, paclet:ref/DistanceFunction]), with the following settings:

(RefLink[GeoDistance, paclet:ref/GeoDistance]) by default uses the setting (RefLink[DistanceFunction, paclet:ref/DistanceFunction])->"Boundary".

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

Distance between two positions on the reference ellipsoid:

GeoDistance[{37,-109},{40.113,-88.261}]

Distance between two cities:

GeoDistance[(Entity["Chicago", Entity["City",{"Chicago","Illinois","UnitedStates"}], "Entity[\"City\", {\"Chicago\", \"Illinois\", \"UnitedStates\"}]", "city"]),(Entity["Tokyo", Entity["City",{"Tokyo","Tokyo","Japan"}], "Entity[\"City\", {\"Tokyo\", \"Tokyo\", \"Japan\"}]", "city"])]

Distance between two fully specified geodetic positions:

GeoDistance[GeoPosition[{37,-109,150},"ITRF00"], GeoPosition[{40.113,-88.261,192.868},"ITRF00"]]

Total distance between several locations:

GeoDistance[{(Entity["Los Angeles", Entity["City",{"LosAngeles","California","UnitedStates"}], "Entity[\"City\", {\"LosAngeles\", \"California\", \"UnitedStates\"}]", "city"]),(Entity["Dallas", Entity["City",{"Dallas","Texas","UnitedStates"}], "Entity[\"City\", {\"Dallas\", \"Texas\", \"UnitedStates\"}]", "city"]),(Entity["Miami", Entity["City",{"Miami","Florida","UnitedStates"}], "Entity[\"City\", {\"Miami\", \"Florida\", \"UnitedStates\"}]", "city"])}]

OpenersExampleSection1(Spacer1)Scope  (6)

Distance between any two points on the Earth, using the parameters of the default datum "ITRF00":

GeoDistance[{46.42,-21.02},{-30.23,40.51}]

Angles can also be specified as DMS strings:

GeoDistance["46°25'12''N 21°1'12''W",{"30°13'48.''S","40°30'36.''E"}]

Or as (RefLink[Quantity, paclet:ref/Quantity]) objects:

GeoDistance[{Quantity[46.42,"AngularDegrees"],Quantity[-21.02,"AngularDegrees"]},{Quantity[-30.23,"AngularDegrees"],Quantity[40.51,"AngularDegrees"]}]

Compute the distance between (RefLink[Entity, paclet:ref/Entity]) objects:

GeoDistance[(Entity["Spain", Entity["Country","Spain"], "Entity[\"Country\", \"Spain\"]", "country"]),(Entity["Germany", Entity["Country","Germany"], "Entity[\"Country\", \"Germany\"]", "country"])]

Or between an (RefLink[Entity, paclet:ref/Entity]) object and a geo position:

GeoDistance[GeoPosition[{40,-4}],(Entity["Germany", Entity["Country","Germany"], "Entity[\"Country\", \"Germany\"]", "country"])]

Distance between geodetic positions, in different formats:

p=GeoPosition[{46.42,-21.02}]

q=GeoGridPosition[{0.7,0.9},"Mercator"]

GeoDistance[p,q]

GeoDistance[GeoPositionXYZ[p],GeoPositionENU[q,GeoPosition[{0,0}]]]

Height and time information is ignored in (RefLink[GeoDistance, paclet:ref/GeoDistance]) computations:

GeoDistance[GeoPosition[{20,30,100}],GeoPosition[{-20,-30,200,3.6 10^9}]]

%===GeoDistance[GeoPosition[{20,30}],GeoPosition[{-20,-30}]]

Points in different datums. The datum of the second point is changed to the datum of the first:

GeoDistance[GeoPosition[{30.,40.},"ITRF90"],GeoPosition[{-50.,-60.},"WGS72"]]

GeoDistance[GeoPosition[{30.,40.}],GeoPosition[{-50.,-60.}]]

The difference is small:

UnitConvert[%-%%,"Meters"]

Total distance between several locations:

GeoDistance[{(Entity["Los Angeles", Entity["City",{"LosAngeles","California","UnitedStates"}], "Entity[\"City\", {\"LosAngeles\", \"California\", \"UnitedStates\"}]", "city"]),GeoPosition[{40,-90}],(Entity["Miami", Entity["City",{"Miami","Florida","UnitedStates"}], "Entity[\"City\", {\"Miami\", \"Florida\", \"UnitedStates\"}]", "city"])}]

%==GeoDistance[(Entity["Los Angeles", Entity["City",{"LosAngeles","California","UnitedStates"}], "Entity[\"City\", {\"LosAngeles\", \"California\", \"UnitedStates\"}]", "city"]),GeoPosition[{40,-90}]]+GeoDistance[GeoPosition[{40,-90}],(Entity["Miami", Entity["City",{"Miami","Florida","UnitedStates"}], "Entity[\"City\", {\"Miami\", \"Florida\", \"UnitedStates\"}]", "city"])]

OpenersExampleSection2(Spacer1)Options  (2)

OpenersExampleSubsection0(Spacer1)DistanceFunction  (1)

For extended entities, the distance is computed as the minimum between boundary points:

GeoDistance[(Entity["Illinois, United States", Entity["AdministrativeDivision",{"Illinois","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Illinois\", \"UnitedStates\"}]", "administrative division"]),(Entity["Florida, United States", Entity["AdministrativeDivision",{"Florida","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Florida\", \"UnitedStates\"}]", "administrative division"]),DistanceFunction->"Boundary"]

The distance between centers is larger:

GeoDistance[(Entity["Illinois, United States", Entity["AdministrativeDivision",{"Illinois","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Illinois\", \"UnitedStates\"}]", "administrative division"]),(Entity["Florida, United States", Entity["AdministrativeDivision",{"Florida","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Florida\", \"UnitedStates\"}]", "administrative division"]),DistanceFunction->"Center"]

When an entity is inside the other, a signed definition of distance can be used:

GeoDistance[(Entity["Illinois, United States", Entity["AdministrativeDivision",{"Illinois","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Illinois\", \"UnitedStates\"}]", "administrative division"]),(Entity["Champaign", Entity["City",{"Champaign","Illinois","UnitedStates"}], "Entity[\"City\", {\"Champaign\", \"Illinois\", \"UnitedStates\"}]", "city"])]

GeoDistance[(Entity["Illinois, United States", Entity["AdministrativeDivision",{"Illinois","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Illinois\", \"UnitedStates\"}]", "administrative division"]),(Entity["Champaign", Entity["City",{"Champaign","Illinois","UnitedStates"}], "Entity[\"City\", {\"Champaign\", \"Illinois\", \"UnitedStates\"}]", "city"]),DistanceFunction->"SignedBoundary"]

OpenersExampleSubsection1(Spacer1)UnitSystem  (1)

The default unit of the result is determined by the value of (RefLink[$UnitSystem, paclet:ref/$UnitSystem]):

$UnitSystem

GeoDistance[(Entity["New York City", Entity["City",{"NewYork","NewYork","UnitedStates"}], "Entity[\"City\", {\"NewYork\", \"NewYork\", \"UnitedStates\"}]", "city"]),(Entity["London", Entity["City",{"London","GreaterLondon","UnitedKingdom"}], "Entity[\"City\", {\"London\", \"GreaterLondon\", \"UnitedKingdom\"}]", "city"])]

Change to a different system:

GeoDistance[(Entity["New York City", Entity["City",{"NewYork","NewYork","UnitedStates"}], "Entity[\"City\", {\"NewYork\", \"NewYork\", \"UnitedStates\"}]", "city"]),(Entity["London", Entity["City",{"London","GreaterLondon","UnitedKingdom"}], "Entity[\"City\", {\"London\", \"GreaterLondon\", \"UnitedKingdom\"}]", "city"]),UnitSystem->"Metric"]

OpenersExampleSection3(Spacer1)Properties & Relations  (10)

(RefLink[GeoDistance, paclet:ref/GeoDistance]) is a symmetric function:

p=GeoPosition[{30,40}];
q=GeoPosition[{-40,120}];

GeoDistance[p,q]

GeoDistance[q,p]

(RefLink[GeoDistance, paclet:ref/GeoDistance]) is a partial inverse of (RefLink[GeoDestination, paclet:ref/GeoDestination]):

GeoDestination[GeoPosition[{30,40}],{10^6,135}]

GeoDistance[GeoPosition[{30,40}],%,UnitSystem->"Metric"]

(RefLink[GeoDistance, paclet:ref/GeoDistance]) returns part of the result returned by (RefLink[GeoDisplacement, paclet:ref/GeoDisplacement]) for point-like locations:

p=Entity["City",{"Oslo","Oslo","Norway"}];
q=Entity["City",{"BuenosAires","BuenosAires","Argentina"}];

GeoDistance[p,q,UnitSystem->"SIBase"]

GeoDisplacement[p,q]

The length of a degree of parallel strongly depends on latitude:

GeoDistance[{10,0},{10,1}]

GeoDistance[{80,0},{80,1}]

But the length of a degree of meridian is approximately constant:

GeoDistance[{10,0},{11,0}]

GeoDistance[{80,0},{81,0}]

The distance corresponding to a given meridian angle α increases when approaching the poles:

α=1;

Plot[QuantityMagnitude@GeoDistance[{lat-α/2,0},{lat+α/2,0}],{lat,-90+α/2,90-α/2}]

Compute distances between consecutive pairs in a list of points with (RefLink[GeoDistanceList, paclet:ref/GeoDistanceList]):

points={{-20,10},{40,20},{-23,45},{82,-132}};

GeoDistanceList[points]//Normal

The same result can be obtained using (RefLink[Partition, paclet:ref/Partition]) and (RefLink[GeoDistance, paclet:ref/GeoDistance]), though in a less efficient way:

GeoDistance@@@Partition[points,2,1]

Include the distance between the last and first point:

GeoDistance@@@Partition[points,2,1,1]

(RefLink[GeoDistance, paclet:ref/GeoDistance]) computes distances between points:

points={{-20,10},{40,20},{-23,45},{82,-132}};

GeoDistance[points]

(RefLink[GeoLength, paclet:ref/GeoLength]) computes the length of a geo path:

GeoLength[GeoPath[points]]

Construct points on a geodesic circle, starting with regular bearings:

points=First@GeoDestination[{70,0},{1000000,Range[0,360,30]}]

On an ellipsoid, they are not exactly equidistant:

GeoDistance@@@Partition[points,2,1]

Differences[%]

Construct multiple points along a geodesic, at regular distance intervals:

points=First@GeoDestination[{70,0},{Range[0,1000000,100000],90}]

GeoDistance@@@Partition[points,2,1]

The list of distances can also be obtained with (RefLink[GeoDistanceList, paclet:ref/GeoDistanceList]):

%==GeoDistanceList[points]

The distance between two locations coincides with the distance between their antipodal locations:

p=GeoPosition[{35.1,75.7}];
q=GeoPosition[{60.4,130.9}];

GeoDistance[p,q]

GeoDistance[GeoAntipode[p],GeoAntipode[q]]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

Distance between extended geo entities is computed between boundaries by default, and hence zero for contiguous entities:

GeoDistance[(Entity["Mexico", Entity["Country","Mexico"], "Entity[\"Country\", \"Mexico\"]", "country"]),(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"])]

GeoDistance[(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),(Entity["Canada", Entity["Country","Canada"], "Entity[\"Country\", \"Canada\"]", "country"])]

Therefore, this total distance is also zero:

GeoDistance[{(Entity["Mexico", Entity["Country","Mexico"], "Entity[\"Country\", \"Mexico\"]", "country"]),(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),(Entity["Canada", Entity["Country","Canada"], "Entity[\"Country\", \"Canada\"]", "country"])}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[GeoDistanceList, paclet:ref/GeoDistanceList])  ▪  (RefLink[GeoGridUnitDistance, paclet:ref/GeoGridUnitDistance])  ▪  (RefLink[TravelDistance, paclet:ref/TravelDistance])  ▪  (RefLink[TravelDistanceList, paclet:ref/TravelDistanceList])  ▪  (RefLink[GeoNearest, paclet:ref/GeoNearest])  ▪  (RefLink[GeoLength, paclet:ref/GeoLength])  ▪  (RefLink[GeoGroup, paclet:ref/GeoGroup])  ▪  (RefLink[GeoDirection, paclet:ref/GeoDirection])  ▪  (RefLink[GeoDestination, paclet:ref/GeoDestination])  ▪  (RefLink[GeoPosition, paclet:ref/GeoPosition])  ▪  (RefLink[GeodesyData, paclet:ref/GeodesyData])  ▪  (RefLink[DistanceMatrix, paclet:ref/DistanceMatrix])  ▪  (RefLink[GeoArea, paclet:ref/GeoArea])  ▪  (RefLink[CentralFeature, paclet:ref/CentralFeature])  ▪  (RefLink[SpatialMedian, paclet:ref/SpatialMedian])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Maps & Cartography, paclet:guide/MapsAndCartography])}, {▪(RefLinkPlain[Geodesy, paclet:guide/Geodesy])}, {▪(RefLinkPlain[Geographic Data & Entities, paclet:guide/GeographicData])}, {▪(RefLinkPlain[Distance and Similarity Measures, paclet:guide/DistanceAndSimilarityMeasures])}, {▪(RefLinkPlain[Locations, Paths, and Routing, paclet:guide/LocationsPathsAndRouting])}, {▪(RefLinkPlain[Transportation Data, paclet:guide/TransportationData])}, {▪(RefLinkPlain[Earth Sciences: Data & Computation, paclet:guide/EarthSciencesDataAndComputation])}, {▪(RefLinkPlain[Cloud Execution Metadata, paclet:guide/CloudExecutionMetadata])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/18-geocomputation.html])(WebLink[: Geocomputation, https://www.wolfram.com/language/elementary-introduction/18-geocomputation.html])}})}})