Wolfram Research

Function Repository Resource:

GeoSpatialDistance (1.0.0) current version: 1.1.0 »

Source Notebook

Find the spatial distance between two points on Earth

Contributed by: Peter Burbery  |  Peter Burbery

ResourceFunction["GeoSpatialDistance"][loc]

finds the spatial distance between Here and loc.

ResourceFunction["GeoSpatialDistance"][loc1,loc2]

finds the spatial distance between locations loc1 and loc2 on Earth.

Details

The spatial distance is the straight-line distance between two points on Earth, or the distance travelled if one could tunnel through the Earth from one point to the other.
The distance is returned in the unit system specified by $UnitSystem.

Examples

Basic Examples (3) 

Find the spatial distance between your location and the North and South Poles:

In[1]:=
ResourceFunction["GeoSpatialDistance"][GeoPosition["NorthPole"]]
Out[1]=
In[2]:=
ResourceFunction["GeoSpatialDistance"][GeoPosition["SouthPole"]]
Out[2]=

Find the spatial distance between your location and its antipode:

In[3]:=
ResourceFunction["GeoSpatialDistance"][GeoAntipode[Here]]
Out[3]=

Find the distance between New York City and Paris, France:

In[4]:=
ResourceFunction["GeoSpatialDistance"][
 Entity["City", {"NewYork", "NewYork", "UnitedStates"}], Entity["City", {"Paris", "IleDeFrance", "France"}]]
Out[4]=

Applications (2) 

The distance from Beijing to its antipode city:

In[5]:=
GeoNearest["City", GeoAntipode[Entity["City", {"Beijing", "Beijing", "China"}]]]
Out[5]=
In[6]:=
ResourceFunction["GeoSpatialDistance"][First[%], Entity["City", {"Beijing", "Beijing", "China"}]]
Out[6]=

Compare the direct distance to the geodesic distance:

In[7]:=
UnitSimplify[
 GeoDistance[
   Entity["City", {"CarmenDePatagones", "BuenosAires", "Argentina"}], Entity["City", {"Beijing", "Beijing", "China"}]] - ResourceFunction["GeoSpatialDistance"][
   Entity["City", {"CarmenDePatagones", "BuenosAires", "Argentina"}], Entity["City", {"Beijing", "Beijing", "China"}]]]
Out[7]=

Make a map of the geodesic path:

In[8]:=
GeoGraphics[
 GeoPath[{Entity[
    "City", {"CarmenDePatagones", "BuenosAires", "Argentina"}], Entity["City", {"Beijing", "Beijing", "China"}]}], Sequence[
 GeoBackground -> "VectorMonochrome", ImageSize -> Large]]
Out[8]=

Properties and Relations (2) 

Compare and contrast with GeoDistance:

In[9]:=
GeoDistance[Here, GeoPosition["NullIsland"]]
Out[9]=
In[10]:=
ResourceFunction["GeoSpatialDistance"][Here, GeoPosition["NullIsland"]]
Out[10]=
In[11]:=
GeoDistance[Here, GeoPosition["NullIsland"]] - ResourceFunction["GeoSpatialDistance"][Here, GeoPosition["NullIsland"]]
Out[11]=

Find the time it would take to travel at the speed of light to Null Island:

In[12]:=
UnitSimplify[
 ResourceFunction["GeoSpatialDistance"][GeoPosition["NullIsland"]]/
 Quantity["SpeedOfLight"]]
Out[12]=

Version History

  • 1.1.0 – 22 August 2022
  • 1.0.0 – 16 August 2022

Related Resources

Author Notes

I wanted to add an example with WikidataGeoPosition but its not functioning correctly right now. I was able to add an example with WikidataGeoPosition

License Information