#create some points
x = seq(154,110,length=25)
y = seq(-10,-54,length=25)
z = seq(100,200,length=25)
wt = runif(25) #random weights
#calculate the Centre of Gravity for these points
COGravity(x,y,z,wt)
#create a simple objects of class 'asc'
x = as.asc(matrix(1:50,nr=50,nc=50))
wt = as.asc(matrix(runif(50),nr=50,nc=50))
#calculate COG with weighting defined in x
COGravity(x)
#calculate COG with weighting defined in wt (values in x are assumed elevation (z))
COGravity(x,wt=wt)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SDMTools)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SDMTools/COGravity.Rd_%03d_medium.png", width=480, height=480)
> ### Name: COGravity
> ### Title: Centre of Gravity or Mass calculations for spatial data
> ### Aliases: COGravity
>
> ### ** Examples
>
> #create some points
> x = seq(154,110,length=25)
> y = seq(-10,-54,length=25)
> z = seq(100,200,length=25)
> wt = runif(25) #random weights
> #calculate the Centre of Gravity for these points
> COGravity(x,y,z,wt)
COGx COGx.sd COGy COGy.sd COGz COGz.sd
131.92854 12.82263 -32.07146 12.82263 150.16240 29.14235
>
> #create a simple objects of class 'asc'
> x = as.asc(matrix(1:50,nr=50,nc=50))
> wt = as.asc(matrix(runif(50),nr=50,nc=50))
>
> #calculate COG with weighting defined in x
> COGravity(x)
COGx COGx.sd COGy COGy.sd
33.66667 11.90086 25.50000 14.43468
> #calculate COG with weighting defined in wt (values in x are assumed elevation (z))
> COGravity(x,wt=wt)
COGx COGx.sd COGy COGy.sd COGz COGz.sd
25.62093 14.53769 25.50000 14.43445 25.62093 14.53769
>
>
>
>
>
> dev.off()
null device
1
>