-2

I am trying to optimise the k parameter using AdehabitatHR LoCoH.k.area and it stops running when the topology is such that it can't produce a polygon. Message is:

rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 12.

I have done a number of successful single runs using LoCoH.k with only a few not running due to orphan holes.

Is it possible to keep LoCoH.k.area looping through the k values specified in the vector even if the one prior produces an orphan hole?

Thanks, Janine

s__
  • 9,270
  • 3
  • 27
  • 45
Janine
  • 11
  • 1

1 Answers1

0

You cant wrap LoCoH.k.area function in tryCatch. E.g. the function with krange = 5:9 argument throws:

Error in rgeos::createPolygonsComment(oobj) : rgeos_PolyCreateComment: orphaned hole, cannot find containing polygon for hole at index 6

Please see the code below:

library(adehabitatHR)
data(puechabonsp)
locs <- puechabonsp$relocs

## The call below throws an error
## LoCoH.k.area(locs[, 1], krange = 5:9)

pdf()
y <- sapply(5:9, function(x) tryCatch(
  expr = cbind(LoCoH.k.area(locs[, 1], krange = x), k = x), 
  error = function(e){}, 
  finally = NULL))

dev.off()
do.call(rbind, y)

Output:

     Brock    Calou     Chou     Jean k
1 25.21552 38.61693 83.37389 80.97771 8
2 27.37161 39.10789 86.45349 83.44156 9
Artem
  • 3,304
  • 3
  • 18
  • 41
  • Thanks Artem. I am off on Leave for a month so will try your suggestion when I return. Many thanks again. – Janine Sep 06 '18 at 23:16