# 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 |

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 library("geosphere") # Load geosphere package |

install.packages("geosphere") # Install geosphere package library("geosphere") # Load 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 # [1] 872988 |

my_dist <- distVincentyEllipsoid(my_points) # Calculate Vincenty ellipsoid distance my_dist # Print Vincenty ellipsoid distance # [1] 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:

*The YouTube video will be added soon.*

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

- Haversine Great Circle Distance
- Law of Cosines Great Circle Distance
- Meeus Great Circle Distance
- Distance Along Rhumb Line
- Vincenty Sphere Great Circle Distance
- Geospatial Distance Between Two Points
- Introduction to R Programming

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.

**5**/

**5**(

**1**vote )

### Statistics Globe Newsletter