Learn R Programming

sperich (version 1.5-8)

getDistance: Distance between two points in a grid

Description

This function calculates the distance of two points in a grid.

Usage

getDistance(point.a, point.b, resolution=1)

Value

The distance of the two points as an numeric value based on geographical degrees.

Arguments

point.a

A point in a grid given by its row and column.

point.b

A point in a grid given by its row and column.

resolution

The resolution of the grid in (geographical) degree.

Author

Maximilian Lange, Sven Lautenbach

Details

This function calculates the distance of two points in a grid by the Pythagorean theorem.

Examples

Run this code
##initialize data
point.a <- c(5,8)
point.b <- c(10,3)

##calculate the distance of the two points
distance <- getDistance(point.a,point.b, resolution=1)
print(distance)

Run the code above in your browser using DataLab