Irescale (version 0.2.6)

convexHull: Plots the convexhull polygon from the data (latitude, longitude), and calculates the center of the convexhull and its area.

Description

convexHull Computes the area and centroid of the convex hull from the (latitute, longitude) vector. It provides a plot of how the points are dispersed in the field of interest.

Usage

convexHull(X, varOfInterest)

Arguments

X

dataframe with two colums, latitute and longitude respectively.

varOfInterest

variable of interest to plot. This variable is needed to color the points on the convexhull.

Value

A vector with two elements, the first element is the area and the second one is the centroid. The centroid is a list of two elements, latitude and longitude that represents the centroid. To have a visual idea of the returned object, it has the following shape \([area,[latitude,longitude], plotObject]\).

Details

Consideration for this function:

  • It makes usage of chull from rgeos and Polygon from graphics.

  • The centroid of the polygon is calculated by averaging the vertices of it.

  • The shown plot uses the basic plot command.

Examples

Run this code
# NOT RUN {
fileInput <- system.file("testdata", "chen.csv", package="Irescale")
data<-loadFile(fileInput)
area_centroid<-convexHull(data$data,data$varOfInterest)
# }

Run the code above in your browser using DataLab