Description Usage Arguments Value Examples
Converts actuall value of a Surface to Value Density (in km^2 by default)
1 2 | ActuallVal2Density(input.surface = "SpatialPolygonsDataFrame",
surface.value.col = "numeric", area.unit = 1e+06)
|
input.surface |
A SpatialPolygonsDataFrame object |
surface.value.col |
Index of VALUE column |
area.uint |
usually to km^2 |
the original SpatialPolygonsDataFrame object but VALUE is now Density
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"]]))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.