geo_dd
geo_dd

Reputation: 313

How to read a traceback in R

I have a large dataset of polygons and, with a loop, I am trying at some point to find, calculate and store intersections. On the 870th iteration, the loop stops and I get the error :

Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false,  : 
  TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point 26.437120350000001 39.241770119999998 at 26.437120350000001 39.241770119999998

I use traceback() but I can not actually understand it:

4: .Call("rgeos_intersection", .RGEOS_HANDLE, spgeom1, spgeom2, 
       byid, ids, PACKAGE = "rgeos")
3: RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false, 
       "rgeos_intersection")
2: gIntersection(combinations[[i]][[1, m]], combinations[[i]][[2, 
       m]]) at #17 . Can anyone explain what to look in ` traceback`?

Can anyone explain me what to look in traceback?

Thanks

Upvotes: 4

Views: 3325

Answers (1)

LyzandeR
LyzandeR

Reputation: 37879

It literally shows you the way the functions were called and where the error occurred. Check this example:

a <- function(x) {
  b <- function(y) {
    c <- function(z) {
     stop('there was a problem')  
    }
    c()
  }
  b()
}

When I call a():

> a()

Error in c() : there was a problem 
4. stop("there was a problem") 
3. c() 
2. b() 
1. a() 

In the above example you can see that a called b which called c and then in c the error occurred. It shows you the calling environments.

Upvotes: 5

Related Questions