add_variable_sp: Adds variable(s) to a SpatialPolygons

Description Usage Arguments Value Examples

View source: R/add_variable.R

Description

Adds variable(s) to a SpatialPolygons

Usage

1

Arguments

sp

A SpatialPolygons object.

df

A vector or a data frame.

Value

A SpatialPolygonsDataFrame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# download vietnam admin1 administrative map in the internal library and in
# the working direction
vn <- sptools::gadm("vietnam", "sp", 1, intlib = TRUE, save = TRUE)
vn_nodata <- remove_data_spatialpolygons(vn)
vn_nodata

a <- runif(63)
vn_data <- add_variable_sp(vn_nodata, a)
vn_data

# An example with a data frame:
vn_data2 <- add_variable_sp(vn_nodata,
   data.frame(b = rnorm(63), c = rexp(63)))
vn_data2

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.