Function Repository Resource:

RhumbLineDistanceList

Source Notebook

Successive pairwise rhumbline distances between a list of geodetic positions

Contributed by: Peter Cullen Burbery

ResourceFunction["RhumbLineDistanceList"][{loc1,loc2,,locn}]

returns the list of loxodromic distances between consecutive pairs of locations.

Details and Options

The locations loci in ResourceFunction["RhumbLineDistanceList"][{loc1,,locn}] can be given as pairs {lat,lon} in degrees, GeoPosition objects, geographic Entity objects, or any other specification of a location.
The result is returned as a QuantityArray object with dimensions of length. The unit used can be chosen with the option UnitSystem, which has "Metric" as its default value.
If the input list of locations has length n, the resulting list of distances has length n-1.

Examples

Basic Examples (3) 

List of consecutive loxodromic distances between cities:

In[1]:=
ResourceFunction[
 "RhumbLineDistanceList"][{Entity[
   "City", {"BuenosAires", "BuenosAires", "Argentina"}], Entity["City", {"RioDeJaneiro", "RioDeJaneiro", "Brazil"}], Entity["City", {"MexicoCity", "DistritoFederal", "Mexico"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}]
Out[1]=

Convert the QuantityArray object to its normal form:

In[2]:=
Normal[%]
Out[2]=

Draw the three rhumbline segments on a map:

In[3]:=
GeoGraphics[{Red, Thick, GeoPath[{Entity[
     "City", {"BuenosAires", "BuenosAires", "Argentina"}], Entity["City", {"RioDeJaneiro", "RioDeJaneiro", "Brazil"}], Entity["City", {"MexicoCity", "DistritoFederal", "Mexico"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}, "RhumbLine"]}]
Out[3]=

Scope (3) 

Specify locations as pairs {lat,lon} in degrees:

In[4]:=
ResourceFunction[
  "RhumbLineDistanceList"][{{0, 0}, {10.5, -22.9}, {10, 150.9}}] // Normal
Out[4]=

Latitude and longitude can also be given as DMS strings:

In[5]:=
ResourceFunction[
  "RhumbLineDistanceList"][{{"46°25'12''N", "21°1'12''W"}, {"30°13'48.''S", "40°30'36.''E"}, {"40d20m12s N", "112d50m W"}}] // Normal
Out[5]=

Or as Quantity angles:

In[6]:=
ResourceFunction[
  "RhumbLineDistanceList"][{{Quantity[0, "AngularDegrees"], Quantity[1, "Radians"]}, {Quantity[MixedMagnitude[{10, 5, 0}], MixedUnit[{"AngularDegrees", "Arcminutes", "Arcseconds"}]], Quantity[-21.02`, "AngularDegrees"]}, {Quantity[-30.233`, "AngularDegrees"], Quantity[40.5`, "AngularDegrees"]}}] // Normal
Out[6]=

Use GeoPosition objects:

In[7]:=
ResourceFunction[
  "RhumbLineDistanceList"][{GeoPosition[{0, 0}], GeoPosition[{10, -30}], GeoPosition[{-70, 170}]}] // Normal
Out[7]=
In[8]:=
ResourceFunction["RhumbLineDistanceList"][
  GeoPosition[{{0, 0}, {10, -30}, {-70, 170}}]] // Normal
Out[8]=

Use other forms of geodetic position:

In[9]:=
ResourceFunction[
  "RhumbLineDistanceList"][{GeoPosition[{0, 0}], GeoPositionXYZ[{5.19*^6, 3.00*^6, 2.20*^6}], GeoGridPosition[{1, 1}, "Albers"]}] // Normal
Out[9]=

Use Entity objects:

In[10]:=
GeoDistanceList[{Entity["City", {"Lisbon", "Lisboa", "Portugal"}], Entity["City", {"Madrid", "Madrid", "Spain"}], Entity["City", {"Paris", "IleDeFrance", "France"}], Entity["City", {"Vienna", "Vienna", "Austria"}]}] // Normal
Out[10]=

Options (2) 

UnitSystem (2) 

The default unit of the result is "Metric":

In[11]:=
ResourceFunction[
  "RhumbLineDistanceList"][{Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}] // Normal
Out[11]=

Change to a different system:

In[12]:=
GeoDistanceList[{Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}, UnitSystem -> "Imperial"] // Normal
Out[12]=

Properties and Relations (3) 

RhumbLineDistanceList is basically equivalent to a combination of Subsequences and RhumbLineDistance:

In[13]:=
locs = {GeoPosition[{0, 0}], GeoPosition[{20, 10}], GeoPosition[{40, -10}]}
Out[13]=
In[14]:=
ResourceFunction[
ResourceObject[<|"Name" -> "RhumbLineDistance", "ShortName" -> "RhumbLineDistance", "UUID" -> "57ed03fa-96d6-44e5-b12c-9f2a20aed845", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Find the distance between two geographical locations along a rhumb line", "RepositoryLocation" -> URL[
     "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$16221af3d3c340c4a2128043e8fb9e38`RhumbLineDistance", "FunctionLocation" -> CloudObject[
     "https://www.wolframcloud.com/obj/80efd290-9d04-4f39-8dc2-74780cdb9e47"]|>, {ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"}]] @@@ Subsequences[locs, {2}]
Out[14]=
In[15]:=
% == ResourceFunction["RhumbLineDistanceList"][locs]
Out[15]=

RhumbLineDistanceList[{loc}] returns an empty list:

In[16]:=
ResourceFunction["RhumbLineDistanceList"][{Here}]
Out[16]=

RhumbLineDistanceList reports distances along the rhumb line. GeoSpatialDistanceList reports straight-line distances through space. GeoDistanceList reports geodesic distance. TravelDistanceList reports distance by road:

In[17]:=
ResourceFunction[
  "RhumbLineDistanceList"][{Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}] // Normal
Out[17]=
In[18]:=
ResourceFunction[
ResourceObject[<|"Name" -> "GeoSpatialDistanceList", "ShortName" -> "GeoSpatialDistanceList", "UUID" -> "eceee46d-d7cb-4d22-9623-4ab8b817384e", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Get a list of spatial distances between consecutive pairs of locations", "RepositoryLocation" -> URL[
     "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"], "SymbolName" -> "FunctionRepository`$f5baab64247d4d429cefa66b4103a61f`GeoSpatialDistanceList", "FunctionLocation" -> CloudObject[
     "https://www.wolframcloud.com/obj/f8a79128-8295-4c52-be61-e112e831c145"]|>, ResourceSystemBase -> Automatic]][
 GeoPosition /@ {Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}]
Out[18]=
In[19]:=
GeoDistanceList[{Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}] // Normal
Out[19]=
In[20]:=
TravelDistanceList[{Entity[
    "City", {"SanFrancisco", "California", "UnitedStates"}], Entity["City", {"Chicago", "Illinois", "UnitedStates"}], Entity["City", {"NewYork", "NewYork", "UnitedStates"}]}] // Normal
Out[20]=

Neat Examples (1) 

Compute the distances between the capitals of members of NATO:

In[21]:=
NATOCapitals = EntityClass["Country", "NATO"][
  EntityProperty["Country", "CapitalCity"]]
Out[21]=
In[22]:=
ResourceFunction["RhumbLineDistanceList"][NATOCapitals]
Out[22]=
In[23]:=
Normal[ResourceFunction["RhumbLineDistanceList"][NATOCapitals]]
Out[23]=

Publisher

Peter Burbery

Requirements

Wolfram Language 13.3 (June 2023) or above

Version History

  • 1.0.0 – 05 July 2023

Related Resources

Author Notes

Ideas for future research including adding support for different distance functions including “Boundary”, corresponding to minimum distance between any points in regions, and “SignedBoundary”, corresponding to distance to boundary, negative for interior points. I think “Center” is used by default, which corresponds to distance between centers of regions. I tried using RegionDistance which as of 13.3 supports region1 and region2, not just a region and a point, but the problem was what function it was using to compute the distance. I think it was using the geodesic distance over the ellipsoid. The problem was that it differed slightly from GeoDistance for some reason.

GeoDistance[,,DistanceFunction"Boundary"] () should be equivalent to Quantity[RegionDistance[Region[["Polygon"]],Region[["Polygon"]]],"Meters"] (). The difference is . To make this work, I would need to first figure out why there is a difference here. Then I would need indicate to RegionDistance I am using not the geodesic distance but the loxodromic distance. The function SignedRegionDistance could be used for the option "SignedBoundary" once it supports two regions, and not just a region and a point. SignedRegionDistanceis effectivelyMinValue[{Norm[p-q],qreg},q∈reg]whenpis not inregand-MinValue[{Norm[p-q],qreg},q]otherwise. This could be used to compute the signed region distance while I wait for support for two regions to be introduced, but there's still the bug and the problem of using a loxodrome and not a geodesic. An example of where this could be useful is GeoDistance[,] () and GeoDistance[,,DistanceFunction"SignedBoundary"] ().

License Information