# Vincenty Ellipsoid Great Circle Distance in R (Example)

In this article, I’ll show how to compute a Vincenty ellipsoid great circle distance in R.

The tutorial consists of the following content:

Let’s dive right in!

## Creating Example Data

At the start, let’s create some example data in R:

```my_points <- matrix(c(81.25798, 73.81277,      # Create longitude/latitude matrix
14.91254, 18.18145),
nrow = 2)
colnames(my_points) <- c("longitude", "latitude")
rownames(my_points) <- c("pt_1", "pt_2")
my_points                                      # Print longitude/latitude matrix``` Table 1 shows the structure of our exemplifying data: It consists of two longitude and latitude points.

## Example: Calculate Vincenty Ellipsoid Great Circle Distance Using distVincentyEllipsoid() Function of geosphere Package

In this example, I’ll illustrate how to calculate the Vincenty ellipsoid great circle distance in R.

For this, we first need to install and load the geosphere package:

```install.packages("geosphere")                  # Install geosphere package

Now, we can apply the distVincentyEllipsoid function of the geosphere package to calculate the Vincenty ellipsoid distance of our two geospatial points:

```my_dist <- distVincentyEllipsoid(my_points)    # Calculate Vincenty ellipsoid distance
my_dist                                        # Print Vincenty ellipsoid distance
#  872988```

The geographical distance between our two data points according to the Vincenty formula is 872988.

## Video & Further Resources

I have recently published a video on my YouTube channel, which explains the contents of this tutorial. You can find the video below:

Furthermore, you might read some of the other articles of my homepage. You can find a selection of articles about distance metrics below:

To summarize: This article has shown how to calculate a Vincenty ellipsoid distance in R programming. If you have further questions and/or comments, let me know in the comments.

Subscribe to the Statistics Globe Newsletter

• Sudeshna
June 21, 2021 4:49 am

What is the default units in which we get the distance? Is it in m or km?

• June 21, 2021 7:13 am

Hey Sudeshna,

You can read more about that in the help documentation of the distVincentyEllipsoid function by executing ?distVincentyEllipsoid in the RStudio console.

This is a quote from the help documentation: “Distance value in the same units as the ellipsoid (default is meters)”

I hope that helps!

Joachim