Page 1 of 1

[SOLVED] Gravity center ERROR

PostPosted: Wed Aug 17, 2016 4:33 am
by carolang
Hello,
I have been using RGeostats and running SI.cgi function with an acoustic data surveyed infront of CHile , Results show me an error because the gravity center point is plotted in land instead of where the data is distributed, why does occur this ????

Any suggestions I will appreciate so much :idea: ,

Carolina ;)

Re: Gravity center ERROR

PostPosted: Wed Aug 17, 2016 6:15 pm
by Didier Renard
Would it be possible to send me your data set as well as your script, please.
In particular, are you working within a projected environment or not ?
If yes, how did you define it?

Re: Gravity center ERROR

PostPosted: Wed Aug 17, 2016 8:12 pm
by carolang
Code: Select all
##################################
library(RGeostats)
                    #IMPORT DATA
dat1=read.table(file.choose(), header=T,sep=",")#data anchoa
poli=read.table(file.choose(), header=T,sep=",")#poligono
                    #Anchoa
an<-dat1[dat1$sp==3,c(1,2:3,8)]
                    # Aplica Estructura db
db<-list()
db.poly<-polygon.create(x=poli[,1],y=poli[,2])
for( i in seq_along(unique(dat1$año)))
{
  db[[i]]<-db.create(an[an$año==unique(dat1$año)[i],],flag.grid=F,ndim=2,autoname=F)
  db[[i]]<- db.locate(db[[i]],3:4,loctype="x")#define lon ,lat
  db[[i]]<- db.locate(db[[i]],5,loctype="z")#define z
  db[[i]]<- db.polygon(db[[i]],db.poly)#selecciona en poligono
  assign(paste('db',i,sep=''),db)
  }
(apoyo=data.frame(name=paste0("db",seq_along(unique(dat1$año))),año=unique(dat1$año)))
                          #ESTIMACION INDICES#
                          #centro de gravedad
cgi<-list()
for( ii in seq_along(unique(dat1$año)))
{
  cgi[[ii]]=SI.cgi(db[[ii]],flag.plot=F,flag.inertia=T,flag.ellipse=F,col=1,lwd=1)
}
                          #GRAFICAS
costa=read.table(file.choose(), header=T,sep=",")#importa costa                         
cost<-polygon(x=costa[,1],y=costa[,2])

plot(an$longitud,an$latitud,type="n",ylim=c(-42,-32),xlim=c(-75,-70),xlab="Latitud (S)",
     ylab="Longitud (O)")
lines(cost,type="l",col=2)
                        #CG (gravitiy center with plot)
cg1=SI.cgi(db[[1]],flag.plot=T,flag.inertia=T,flag.ellipse=T,col=1,lwd=1);text(locator(1),"2001",cex=.65)
cg2 .....and so on

Re: Gravity center ERROR

PostPosted: Wed Aug 17, 2016 9:17 pm
by Didier Renard
Hi Carolina

I received your data set in a private mail. I read your data set and understood your problem.

Your data are located in the sea on the border of the Chilean coast. Note that this coast is extremely elongated and the band where the measurements are located is very thin.
Moreover the coast is not rectilinear. Locally and for a given year, the data set presents a croissant shape. Then the center of gravity (obtained using SI.cgi() function) lies on the continent. This is geometrically correct. Nothing in the algorithm prevents from this possibility.

The following picture demonstrates the data set (displayed in black), the coast line and the center of gravity.

Image

Re: Gravity center ERROR

PostPosted: Thu Aug 18, 2016 1:20 pm
by carolang
Thanks for your reply
But, In this example, What do you recommend to do if I want to use the others
spatial indices ( like isotropy index) available in RGeostat package??

Re: Gravity center ERROR

PostPosted: Fri Aug 19, 2016 7:53 am
by Didier Renard
Hello

Mathematically, it does not hurt me having the center of gravity (or the other SI) located on earth. Nevertheless they designate the REAL location of the center of gravity.
But I think that what you are looking for is the center of gravity of a population located (by definition) in the sea. This additional criterion must be included in the calculation process.
We could imagine to perform such calculations (for all SI) using an additional constraint ... but this may lead to horribly difficult calculations.
I would prefer a DATA TRANSFORMATION, which could be run both ways:
- transform the data in another space
- perform the calculations in that space
- transform the resulting information back in the original space.

During our discussions (in the process of writing a manual for ICES), Nicolas BEZ suggested a transform which makes the coast line (or Chile in particular) a vertical line, such that the sea would be on its left and earth on its right. This is the type of simple transform that I imagine.
Unfortunately, I do not have a specific code available for doing that. But may be Nicolas could follow up on this post.

Re: [SOLVED] Gravity center ERROR

PostPosted: Fri Jun 28, 2019 10:50 am
by satya31
Excellent thread..!!!