# [AniMov] Problem with getverticeshr

Sander Oom slist at oomvanlieshout.net
Fri Apr 28 17:44:07 CEST 2006

```Xiaohua Dai wrote:
> Hi Sander,
>
> Although I'm not the expert, I'll try to answer your question.
>
> 1. At least 3 pixels are needed to draw a polygon.  Compared to lev =
> 85, there should appear a new small polygon (if not merged with
> neighbouring polygons) when lev = 95. However, it is too small when lev
> = 90.
>
> 2. Did you check the value of ver when error occured. For example, ver =
> NULL. Then you can use the if statement to exclude it.
>
> if (!is.null(getverticeshr(hr, lev = num))) { ver = getverticeshr(hr,
> lev = num) } else {break;}
>
> I did not test the code.
>
> HTH,
> Xiaohua
>
> On 4/28/06, *Sander Oom* <slist at oomvanlieshout.net
> <mailto:slist at oomvanlieshout.net>> wrote:
>
>     Dear Clément and AniMove members,
>
>     It has been a while, but I have returned (as a part-time hobby) to
>     animal movement analysis.
>
>     I am trying to calculate home range using the code suggestions from the
>     AniMove Howto instructions.
>
>     When converting the home ranges to shape file, I run into problem with
>     getverticeshr:
>
>     >     ver <- getverticeshr(hr, lev = 85)
>     >     ver <- getverticeshr(hr, lev = 90)
>     Error in getcontour(ud) : The parts of the object should contain at
>     least 3 pixels
>     >     ver <- getverticeshr(hr, lev = 95)
>
>     Some levels work fine, some give errors. I am a bit puzzled why, in the
>     above example, levels 85 and 95 are fine and 90 is not?
>
>     The code is in a for loop like this (using the very helpful function
>     kver.to.shapefile ):
>
>     for (num in seq(30,95,by=5) ){
>        print(paste("*** Create vertices for: ", num))
>        ver <- getverticeshr(hr, lev = num)
>        #   plot(ver)
>        print(paste("*** Export to shape  "))
>        kver.to.shapefile(ver, path = paste(strSableShapesOut, "/", num,
>     sep=""))
>     } ## End of for loop
>
>     How could I put a control in this loop avoiding any cases in which the
>     error would otherwise occur? Thus avoiding the loop to crash on the
>     first error.
>
>     Thanks in advance for your help,
>
>     Sander.
>
>

Thanks for your reply! I checked 'ver':

[1] "*** Create vertices for:  75"
Error in getcontour(ud) : The parts of the object should contain at
least 3 pixels
>
> ver
\$Zebra01
id        x       y
1   1 313532.0 7486504
2   1 314224.1 7486504
3   1 314916.2 7487196
4   1 315608.2 7487196
5   1 316300.3 7487888
6   1 316992.3 7487888
7   1 317684.4 7488580
8   1 318376.5 7488580
9   1 319068.5 7489272
10  1 319760.6 7489964
11  1 320452.6 7490656
12  1 320452.6 7491348
13  1 320452.6 7492040
14  1 320452.6 7492732
15  1 321144.7 7493424
16  1 321144.7 7494116
17  1 321144.7 7494808
18  1 320452.6 7495501
19  1 320452.6 7496193
20  1 320452.6 7496885
21  1 319760.6 7497577
22  1 319760.6 7498269
23  1 319068.5 7498961
24  1 318376.5 7499653
25  1 317684.4 7499653
26  1 316992.3 7499653
27  1 316300.3 7499653
28  1 315608.2 7499653
29  1 314916.2 7499653
30  1 314224.1 7499653
31  1 314224.1 7498961
32  1 313532.0 7498269
33  1 313532.0 7497577
34  1 313532.0 7496885
35  1 313532.0 7496193
36  1 312840.0 7495501
37  1 312840.0 7494808
38  1 312840.0 7494116
39  1 312840.0 7493424
40  1 312840.0 7492732
41  1 312147.9 7492040
42  1 312147.9 7491348
43  1 312147.9 7490656
44  1 312147.9 7489964
45  1 311455.9 7489272
46  1 311455.9 7488580
47  1 312147.9 7487888
48  1 312840.0 7487196
49  1 313532.0 7486504

attr(,"class")
[1] "kver"
>

It certainly is not NULL?

Will ponder over it some more!

Sander.

```