Description Usage Arguments Details Value Examples
View source: R/code_revised_cca.R
After clustering assign additional data from a data frame with columns indicated as latitude and longitude.
1  | assign.data(cluster, points, dist=1000)
 | 
cluster | 
 The from cca() generated data frame with cluster-information.  | 
points | 
 Data frame with additional data, containing at least a "lat" and "long" column with point coordinates which will be assigned.  | 
dist | 
 The assignment distance given in meters. Are the given point coordinates within this distance from an identified cluster, this point will be assigned to the cluster.  | 
Multiple points can be assigned to the same cluster. If no cluster is within the given distance, the cluster_id will be 0.
Returns the data frame given as points with an additional column "cluster_id" referring to the identified cluster. A cluster_id 0 indicates that no cluster was within the given distance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  | data(landcover)
# clustering urban areas
urban <- cca(landcover, cell.class=1,s=2000, unit="m")
str(urban)
# plot the result    
result <- landcover*NA
result[cellFromXY(result,urban$cluster[,c("long","lat")])]<-urban$cluster[,"cluster_id"]*(-1)
plot(result, col=rainbow(9))
# data.frame with additional information (name)    
data.points <- data.frame(
      long=c(13.26,13.28),
      lat=c(52.34,52.20),
      name=c("Pappelhausen","New Garden")
    )
    
points(data.points$long, data.points$lat, pch="X")
    
assign.data(cluster=urban$cluster, points=data.points, dist=3000)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.