ActuallVal2Density: Converts actuall value of a Surface to Value Density (in km^2...

Description Usage Arguments Value Examples

Description

Converts actuall value of a Surface to Value Density (in km^2 by default)

Usage

1
2
ActuallVal2Density(input.surface = "SpatialPolygonsDataFrame",
  surface.value.col = "numeric", area.unit = 1e+06)

Arguments

input.surface

A SpatialPolygonsDataFrame object

surface.value.col

Index of VALUE column

area.uint

usually to km^2

Value

the original SpatialPolygonsDataFrame object but VALUE is now Density

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# test  ActuallVal2Density -------------------------------------------------------
# Make a spatial polygon
S<-readWKT("POLYGON((0 0,2000 0,2000 2000,0 2000,0 0))",id = "S",p4s = CRS("+init=epsg:3035"))
df<-cbind(AREA=gArea(S),VALUE=1000)
row.names(df)<-sapply(slot(S,"polygons"),function(x) slot(x,"ID"))
df<-as.data.frame(df)
S<-SpatialPolygonsDataFrame(S,data = df,match.ID = TRUE)
# Covert actuall value to density
S_D<-ActuallVal2Density(input.surface = S,surface.value.col = 2,area.unit = 1e+06)
# plot
X11(width=12,height = 12)
split.screen(figs = c(2,1))
screen(1)
plot(S)
title("the input surface")
text(coordinates(S)[,1],coordinates(S)[,2],paste("Actuall Value =",S[["VALUE"]]))
screen(2)
plot(S_D)
title("the input surface changed the attr VALUE")
text(coordinates(S_D)[,1],coordinates(S_D)[,2],paste("Density =", S_D[["VALUE"]]))

etsakl/DasyMapR documentation built on May 16, 2019, 9:07 a.m.