Function Repository Resource:

GeoSpatialDistance

Source Notebook

Find the spatial distance between two points on Earth

Contributed by: Peter Cullen 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.
To find the position of a location like a city or building with a string, use the resource function WikidataGeoPosition.

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"][
 ResourceFunction["WikidataGeoPosition"]["New York City"], ResourceFunction["WikidataGeoPosition"]["Paris"]]
Out[4]=

Applications (2) 

The distance from Beijing to its antipode city:

In[5]:=
GeoNearest["City", GeoAntipode[ResourceFunction["WikidataGeoPosition"]["Beijing"]]]
Out[5]=
In[6]:=
ResourceFunction["GeoSpatialDistance"][
 First[GeoNearest["City", GeoAntipode[ResourceFunction["WikidataGeoPosition"]["Beijing"]]]], ResourceFunction["WikidataGeoPosition"]["Beijing"]]
Out[6]=

Compare the direct distance to the geodesic distance:

In[7]:=
UnitSimplify[
 GeoDistance[
   ResourceFunction["WikidataGeoPosition"]["Carmen de Patagones"], ResourceFunction["WikidataGeoPosition"]["Beijing"]] - ResourceFunction["GeoSpatialDistance"][
   ResourceFunction["WikidataGeoPosition"]["Carmen de Patagones"], ResourceFunction["WikidataGeoPosition"]["Beijing"]]]
Out[7]=

Properties and Relations (2) 

Compare and contrast with GeoDistance:

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

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

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

Publisher

Peter Burbery

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