How to read trace in R

I have a large dataset from polygons, and with a loop I try at some point to find, calculate and save intersections. At the 870th iteration, the loop stops and I get an 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 understand this:

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 someone explain to me what to look at traceback?

thank

+4
source share
1 answer

It literally shows you how the functions were called and where the error occurred. Check out 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 what ais called bthat called c, and then can error occurred. It shows you calling environments.

+2
source

Source: https://habr.com/ru/post/1689623/


All Articles