spatial.join.locs: Spatial join; join information of a shape to the points that...

Description Usage Arguments Value Examples

Description

Spatial join; join information of a shape to the points that it contains

Usage

1
spatial.join.locs(points, shapes, targetcolumn, column.names)

Arguments

points

a SpatialPointsDataFrame. Projection cannot be unknown.

shapes

a SpatialPolygonsDataFrame. Projection cannot be unknown.

targetcolumn

a character string vector with the names of the columns in shapes which need to be joined to points.

column.names

a character string vector with the column names that will be given to the joined columns added to points.

Value

It returns the points spdf with the new columns joined to the data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
pts = cbind(1.5:5.5, 1.5:5.5)
dimnames(pts)[[1]] = letters[1:5]
df = data.frame(a = 1:5)
row.names(df) = letters[5:1]
points <- SpatialPointsDataFrame(pts, df, match.ID = TRUE)

grd <- GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as(grd, "SpatialPolygons")
centroids <- coordinates(polys)
x <- centroids[,1]
y <- centroids[,2]
z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
pols <- SpatialPolygonsDataFrame(polys,
                                 data=data.frame(x=x, y=y, z=z, row.names=row.names(polys)))
result <- spatial.join.locs(points, pols)

boukepieter/AnalDTM documentation built on June 18, 2019, 12:33 a.m.