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

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.

## 2 Comments. Leave new

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

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