[SOLVED] Gravity center ERROR

If you have problems using RGeostats package or if you simply need some help on an unlisted subject.

[SOLVED] Gravity center ERROR

Postby carolang » Wed Aug 17, 2016 4:33 am

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 ;)
carolang
 
Posts: 5
Joined: Mon Feb 22, 2016 2:09 pm

Re: Gravity center ERROR

Postby Didier Renard » Wed Aug 17, 2016 6:15 pm

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?
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: Gravity center ERROR

Postby carolang » Wed Aug 17, 2016 8:12 pm

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
carolang
 
Posts: 5
Joined: Mon Feb 22, 2016 2:09 pm

Re: Gravity center ERROR

Postby Didier Renard » Wed Aug 17, 2016 9:17 pm

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
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: Gravity center ERROR

Postby carolang » Thu Aug 18, 2016 1:20 pm

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??
carolang
 
Posts: 5
Joined: Mon Feb 22, 2016 2:09 pm

Re: Gravity center ERROR

Postby Didier Renard » Fri Aug 19, 2016 7:53 am

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.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm

Re: [SOLVED] Gravity center ERROR

Postby satya31 » Fri Jun 28, 2019 10:50 am

Excellent thread..!!!
satya31
 
Posts: 1
Joined: Fri Jun 28, 2019 5:50 am


Return to Other Troubleshooting

Who is online

Users browsing this forum: No registered users and 7 guests

cron