attribute_polygon: Polygon-attribution

Description Usage Arguments Value Examples

View source: R/setAttributes.R

Description

Takes a data frame df with fields x and y and a shape in data frame format, shape_table, and determines whether, and in which, polygon each point in df lies.

Usage

1
attribute_polygon(df, shape_df)

Arguments

df

data frame to which the polygon id is attributed. Must contain fields x and y.

shape_df

the polygon-containing data frame. Must contain fields x, y and id. Multiple polygons/land-masses can be treated simultaneously through id.

Value

a vector of length nrow(df) indicating the id in which each point in df lies.

Examples

1
2
3
4
5
df <- data.frame(x=c(0.2,1),y=c(0.2,1))
shape_df <- data.frame(x=c(0,0,0.5,0.5),
y = c(0,0.5,0.5,0),
id = 1)
df$id <- attribute_polygon(df,shape_df)

shazhe/mvst0 documentation built on May 29, 2019, 9:20 p.m.