Skip to contents

Remove points from the start (head), end (tail), or both ends of an outline.

Usage

coo_trim_head(x, ..., .cols = NULL, .ldk_col = NULL)

coo_trim_tail(x, ..., .cols = NULL, .ldk_col = NULL)

coo_trim_both(x, ..., .cols = NULL, .ldk_col = NULL)

Arguments

x

A matrix (nx2), list of matrices, or tibble with coo columns.

...

Additional arguments (reserved for future use).

.cols

Column name(s) to process when x is a tibble. If NULL, automatically detects columns containing coo columns.

n

Integer or numeric. Number of points to remove, or if between 0 and 1, fraction of perimeter to remove.

Value

  • If x is a single matrix: returns the trimmed matrix

  • If x is a list: returns a list of trimmed matrices

  • If x is a tibble: returns the tibble with trimmed coo column(s)

Details

coo_trim_head(n): Removes n points from the start (head).

coo_trim_tail(n): Removes n points from the end (tail).

coo_trim_both(n): Removes n points from each end (2n total).

If n is between 0 and 1, interprets as fraction of perimeter to remove.

Landmarks are NOT adjusted. Use with caution if shape has landmarks.

See also

coo_head() for keeping first n points; coo_tail() for removing last n points

Examples

# Remove 10 points from start
coo_trim_head(shapes$cat, n = 10)
#> <xy [110 x 2]>
#>       [,1] [,2]
#>  [1,] 176   43 
#>  [2,] 170   43 
#>  [3,] 164   43 
#>  [4,] 158   43 
#>  [5,] 152   43 
#>  [6,] ...  ... 
#>  [7,] 219   45 
#>  [8,] 213   47 
#>  [9,] 208   53 
#> [10,] 204   59 
#> [11,] 202   65 

# Remove 5 points from end
coo_trim_tail(bot$coo, n = 5)
#> $brahma
#> <xy [133 x 2]>
#>       [,1] [,2]
#>  [1,]  37  561 
#>  [2,]  40  540 
#>  [3,]  40  529 
#>  [4,]  43  508 
#>  [5,]  46  487 
#>  [6,] ...  ... 
#>  [7,]  69  749 
#>  [8,]  59  728 
#>  [9,]  54  718 
#> [10,]  45  698 
#> [11,]  38  677 
#> 
#> $caney
#> <xy [163 x 2]>
#>       [,1] [,2]
#>  [1,]  53  535 
#>  [2,]  53  525 
#>  [3,]  54  505 
#>  [4,]  53  495 
#>  [5,]  54  485 
#>  [6,] ...  ... 
#>  [7,] 105  676 
#>  [8,] 103  666 
#>  [9,] 100  656 
#> [10,]  91  636 
#> [11,]  83  626 
#> 
#> $chimay
#> <xy [184 x 2]>
#>       [,1] [,2]
#>  [1,]  49  333 
#>  [2,]  49  325 
#>  [3,]  49  318 
#>  [4,]  50  310 
#>  [5,]  50  302 
#>  [6,] ...  ... 
#>  [7,]  79  425 
#>  [8,]  75  418 
#>  [9,]  72  410 
#> [10,]  66  395 
#> [11,]  62  387 
#> 
#> $corona
#> <xy [124 x 2]>
#>       [,1] [,2]
#>  [1,]  91  426 
#>  [2,]  91  416 
#>  [3,]  90  395 
#>  [4,]  91  385 
#>  [5,]  91  374 
#>  [6,] ...  ... 
#>  [7,] 124  578 
#>  [8,] 124  557 
#>  [9,] 124  547 
#> [10,] 122  537 
#> [11,] 122  516 
#> 
#> $deusventrue
#> <xy [147 x 2]>
#>       [,1] [,2]
#>  [1,]  74  481 
#>  [2,]  70  472 
#>  [3,]  62  454 
#>  [4,]  59  445 
#>  [5,]  52  425 
#>  [6,] ...  ... 
#>  [7,] 120  620 
#>  [8,] 116  612 
#>  [9,] 112  593 
#> [10,] 109  583 
#> [11,] 103  565 
#> 
#> $duvel
#> <xy [156 x 2]>
#>       [,1] [,2]
#>  [1,]  61  315 
#>  [2,]  61  304 
#>  [3,]  61  293 
#>  [4,]  61  293 
#>  [5,]  61  282 
#>  [6,] ...  ... 
#>  [7,]  93  412 
#>  [8,]  92  401 
#>  [9,]  92  401 
#> [10,]  88  390 
#> [11,]  81  379 
#> 
#> $franziskaner
#> <xy [119 x 2]>
#>       [,1] [,2]
#>  [1,]  54  439 
#>  [2,]  54  418 
#>  [3,]  54  408 
#>  [4,]  54  389 
#>  [5,]  54  379 
#>  [6,] ...  ... 
#>  [7,]  79  603 
#>  [8,]  76  594 
#>  [9,]  70  573 
#> [10,]  68  563 
#> [11,]  63  542 
#> 
#> $grimbergen
#> <xy [121 x 2]>
#>       [,1] [,2]
#>  [1,]  42  404 
#>  [2,]  40  394 
#>  [3,]  40  373 
#>  [4,]  40  362 
#>  [5,]  40  352 
#>  [6,] ...  ... 
#>  [7,]  95  560 
#>  [8,]  94  539 
#>  [9,]  94  528 
#> [10,]  90  518 
#> [11,]  82  497 
#> 
#> $guiness
#> <xy [178 x 2]>
#>       [,1] [,2]
#>  [1,]  69  385 
#>  [2,]  69  377 
#>  [3,]  69  369 
#>  [4,]  69  360 
#>  [5,]  69  344 
#>  [6,] ...  ... 
#>  [7,] 102  488 
#>  [8,]  90  473 
#>  [9,]  84  464 
#> [10,]  80  457 
#> [11,]  76  449 
#> 
#> $hoegardeen
#> <xy [188 x 2]>
#>       [,1] [,2]
#>  [1,]  42  544 
#>  [2,]  40  531 
#>  [3,]  40  519 
#>  [4,]  40  506 
#>  [5,]  40  493 
#>  [6,] ...  ... 
#>  [7,]  77  679 
#>  [8,]  73  667 
#>  [9,]  69  654 
#> [10,]  65  641 
#> [11,]  61  631 
#> 
#> $jupiler
#> <xy [151 x 2]>
#>       [,1] [,2]
#>  [1,]  55  515 
#>  [2,]  54  501 
#>  [3,]  54  488 
#>  [4,]  54  474 
#>  [5,]  54  460 
#>  [6,] ...  ... 
#>  [7,]  96  665 
#>  [8,]  93  652 
#>  [9,]  88  638 
#> [10,]  83  624 
#> [11,]  79  611 
#> 
#> $kingfisher
#> <xy [177 x 2]>
#>       [,1] [,2]
#>  [1,]  71  384 
#>  [2,]  71  374 
#>  [3,]  71  365 
#>  [4,]  71  355 
#>  [5,]  71  345 
#>  [6,] ...  ... 
#>  [7,]  89  480 
#>  [8,]  89  471 
#>  [9,]  85  462 
#> [10,]  83  452 
#> [11,]  81  442 
#> 
#> $latrappe
#> <xy [131 x 2]>
#>       [,1] [,2]
#>  [1,]  26  389 
#>  [2,]  25  377 
#>  [3,]  25  364 
#>  [4,]  25  352 
#>  [5,]  25  339 
#>  [6,] ...  ... 
#>  [7,]  75  539 
#>  [8,]  62  526 
#>  [9,]  51  514 
#> [10,]  43  501 
#> [11,]  32  476 
#> 
#> $lindemanskriek
#> <xy [171 x 2]>
#>       [,1] [,2]
#>  [1,]  60  427 
#>  [2,]  60  419 
#>  [3,]  55  404 
#>  [4,]  54  395 
#>  [5,]  54  387 
#>  [6,] ...  ... 
#>  [7,]  95  543 
#>  [8,]  89  527 
#>  [9,]  87  519 
#> [10,]  84  510 
#> [11,]  82  502 
#> 
#> $nicechouffe
#> <xy [141 x 2]>
#>       [,1] [,2]
#>  [1,]  82  361 
#>  [2,]  81  353 
#>  [3,]  77  336 
#>  [4,]  77  327 
#>  [5,]  76  319 
#>  [6,] ...  ... 
#>  [7,] 115  475 
#>  [8,] 109  458 
#>  [9,] 107  450 
#> [10,] 104  442 
#> [11,] 102  435 
#> 
#> $pecheresse
#> <xy [124 x 2]>
#>       [,1] [,2]
#>  [1,]  63  495 
#>  [2,]  61  476 
#>  [3,]  61  467 
#>  [4,]  60  447 
#>  [5,]  58  428 
#>  [6,] ...  ... 
#>  [7,] 106  665 
#>  [8,] 103  646 
#>  [9,] 101  637 
#> [10,]  95  617 
#> [11,]  90  599 
#> 
#> $sierranevada
#> <xy [171 x 2]>
#>       [,1] [,2]
#>  [1,]  61  345 
#>  [2,]  61  333 
#>  [3,]  61  333 
#>  [4,]  61  320 
#>  [5,]  61  308 
#>  [6,] ...  ... 
#>  [7,]  86  442 
#>  [8,]  76  429 
#>  [9,]  76  429 
#> [10,]  69  418 
#> [11,]  63  407 
#> 
#> $tanglefoot
#> <xy [169 x 2]>
#>       [,1] [,2]
#>  [1,]  48  367 
#>  [2,]  48  359 
#>  [3,]  48  351 
#>  [4,]  48  335 
#>  [5,]  49  327 
#>  [6,] ...  ... 
#>  [7,]  84  471 
#>  [8,]  76  463 
#>  [9,]  69  455 
#> [10,]  59  439 
#> [11,]  55  431 
#> 
#> $tauro
#> <xy [169 x 2]>
#>       [,1] [,2]
#>  [1,]  56  515 
#>  [2,]  54  503 
#>  [3,]  54  491 
#>  [4,]  54  478 
#>  [5,]  54  466 
#>  [6,] ...  ... 
#>  [7,]  92  647 
#>  [8,]  88  635 
#>  [9,]  82  623 
#> [10,]  79  610 
#> [11,]  75  598 
#> 
#> $westmalle
#> <xy [136 x 2]>
#>       [,1] [,2]
#>  [1,]  70  394 
#>  [2,]  70  386 
#>  [3,]  67  369 
#>  [4,]  67  361 
#>  [5,]  66  344 
#>  [6,] ...  ... 
#>  [7,]  96  526 
#>  [8,]  97  510 
#>  [9,]  97  502 
#> [10,]  92  486 
#> [11,]  91  478 
#> 
#> $amrut
#> <xy [186 x 2]>
#>       [,1] [,2]
#>  [1,]  57  441 
#>  [2,]  57  431 
#>  [3,]  57  421 
#>  [4,]  57  411 
#>  [5,]  57  401 
#>  [6,] ...  ... 
#>  [7,]  72  551 
#>  [8,]  66  541 
#>  [9,]  61  531 
#> [10,]  58  521 
#> [11,]  56  511 
#> 
#> $ballantines
#> <xy [141 x 2]>
#>       [,1] [,2]
#>  [1,]  38  357 
#>  [2,]  38  341 
#>  [3,]  38  333 
#>  [4,]  38  318 
#>  [5,]  38  310 
#>  [6,] ...  ... 
#>  [7,]  36  483 
#>  [8,]  36  475 
#>  [9,]  38  459 
#> [10,]  38  451 
#> [11,]  38  436 
#> 
#> $bushmills
#> <xy [160 x 2]>
#>       [,1] [,2]
#>  [1,]  72  456 
#>  [2,]  72  441 
#>  [3,]  72  425 
#>  [4,]  72  425 
#>  [5,]  72  410 
#>  [6,] ...  ... 
#>  [7,]  68  595 
#>  [8,]  68  579 
#>  [9,]  68  564 
#> [10,]  68  564 
#> [11,]  69  548 
#> 
#> $chivas
#> <xy [159 x 2]>
#>       [,1] [,2]
#>  [1,]  33  437 
#>  [2,]  31  429 
#>  [3,]  29  412 
#>  [4,]  29  404 
#>  [5,]  29  388 
#>  [6,] ...  ... 
#>  [7,] 118  556 
#>  [8,] 118  548 
#>  [9,] 112  532 
#> [10,] 104  523 
#> [11,]  97  516 
#> 
#> $dalmore
#> <xy [150 x 2]>
#>       [,1] [,2]
#>  [1,]  52  371 
#>  [2,]  47  359 
#>  [3,]  44  346 
#>  [4,]  42  334 
#>  [5,]  42  322 
#>  [6,] ...  ... 
#>  [7,] 130  491 
#>  [8,] 129  479 
#>  [9,] 126  467 
#> [10,] 121  454 
#> [11,] 113  442 
#> 
#> $famousgrouse
#> <xy [164 x 2]>
#>       [,1] [,2]
#>  [1,]  99  313 
#>  [2,]  99  303 
#>  [3,]  99  294 
#>  [4,]  99  284 
#>  [5,]  99  284 
#>  [6,] ...  ... 
#>  [7,] 101  407 
#>  [8,]  98  399 
#>  [9,]  96  389 
#> [10,]  96  380 
#> [11,]  96  370 
#> 
#> $glendronach
#> <xy [192 x 2]>
#>       [,1] [,2]
#>  [1,]  73  435 
#>  [2,]  73  423 
#>  [3,]  74  411 
#>  [4,]  74  411 
#>  [5,]  74  399 
#>  [6,] ...  ... 
#>  [7,]  94  544 
#>  [8,]  85  532 
#>  [9,]  79  519 
#> [10,]  74  507 
#> [11,]  74  507 
#> 
#> $glenmorangie
#> <xy [174 x 2]>
#>       [,1] [,2]
#>  [1,]  53  518 
#>  [2,]  54  501 
#>  [3,]  54  501 
#>  [4,]  54  485 
#>  [5,]  55  468 
#>  [6,] ...  ... 
#>  [7,]  86  649 
#>  [8,]  86  649 
#>  [9,]  76  633 
#> [10,]  68  616 
#> [11,]  62  599 
#> 
#> $highlandpark
#> <xy [164 x 2]>
#>       [,1] [,2]
#>  [1,]  42  371 
#>  [2,]  42  357 
#>  [3,]  42  357 
#>  [4,]  42  343 
#>  [5,]  42  329 
#>  [6,] ...  ... 
#>  [7,]  40  483 
#>  [8,]  40  483 
#>  [9,]  39  469 
#> [10,]  40  455 
#> [11,]  41  441 
#> 
#> $jackdaniels
#> <xy [145 x 2]>
#>       [,1] [,2]
#>  [1,]  63  414 
#>  [2,]  63  401 
#>  [3,]  63  388 
#>  [4,]  63  375 
#>  [5,]  63  362 
#>  [6,] ...  ... 
#>  [7,] 114  547 
#>  [8,] 103  539 
#>  [9,]  90  526 
#> [10,]  80  518 
#> [11,]  73  506 
#> 
#> $jb
#> <xy [169 x 2]>
#>       [,1] [,2]
#>  [1,]  43  531 
#>  [2,]  43  520 
#>  [3,]  42  510 
#>  [4,]  42  488 
#>  [5,]  43  477 
#>  [6,] ...  ... 
#>  [7,]  80  668 
#>  [8,]  69  658 
#>  [9,]  59  647 
#> [10,]  51  636 
#> [11,]  44  617 
#> 
#> $johnniewalker
#> <xy [163 x 2]>
#>       [,1] [,2]
#>  [1,] 133  175 
#>  [2,] 133  171 
#>  [3,] 133  167 
#>  [4,] 133  163 
#>  [5,] 134  155 
#>  [6,] ...  ... 
#>  [7,] 132  227 
#>  [8,] 132  219 
#>  [9,] 132  215 
#> [10,] 132  211 
#> [11,] 133  207 
#> 
#> $magallan
#> <xy [136 x 2]>
#>       [,1] [,2]
#>  [1,]  78  397 
#>  [2,]  78  382 
#>  [3,]  80  375 
#>  [4,]  80  361 
#>  [5,]  81  346 
#>  [6,] ...  ... 
#>  [7,]  81  521 
#>  [8,]  79  513 
#>  [9,]  77  499 
#> [10,]  75  484 
#> [11,]  75  477 
#> 
#> $makersmark
#> <xy [172 x 2]>
#>       [,1] [,2]
#>  [1,]  31  432 
#>  [2,]  23  420 
#>  [3,]  16  408 
#>  [4,]  16  408 
#>  [5,]  13  394 
#>  [6,] ...  ... 
#>  [7,] 101  526 
#>  [8,] 105  511 
#>  [9,] 105  511 
#> [10,] 102  498 
#> [11,]  92  491 
#> 
#> $oban
#> <xy [174 x 2]>
#>       [,1] [,2]
#>  [1,]  74  457 
#>  [2,]  74  448 
#>  [3,]  74  431 
#>  [4,]  74  423 
#>  [5,]  74  414 
#>  [6,] ...  ... 
#>  [7,]  93  576 
#>  [8,]  81  559 
#>  [9,]  78  551 
#> [10,]  75  542 
#> [11,]  74  534 
#> 
#> $oldpotrero
#> <xy [126 x 2]>
#>       [,1] [,2]
#>  [1,]  83  307 
#>  [2,]  77  299 
#>  [3,]  71  291 
#>  [4,]  63  274 
#>  [5,]  60  265 
#>  [6,] ...  ... 
#>  [7,] 129  417 
#>  [8,] 129  408 
#>  [9,] 128  400 
#> [10,] 127  391 
#> [11,] 123  375 
#> 
#> $redbreast
#> <xy [172 x 2]>
#>       [,1] [,2]
#>  [1,] 105  233 
#>  [2,] 103  228 
#>  [3,] 101  224 
#>  [4,]  98  214 
#>  [5,]  98  210 
#>  [6,] ...  ... 
#>  [7,] 147  288 
#>  [8,] 148  283 
#>  [9,] 147  278 
#> [10,] 146  274 
#> [11,] 141  264 
#> 
#> $tamdhu
#> <xy [171 x 2]>
#>       [,1] [,2]
#>  [1,]  49  552 
#>  [2,]  49  540 
#>  [3,]  49  527 
#>  [4,]  49  515 
#>  [5,]  49  503 
#>  [6,] ...  ... 
#>  [7,]  72  698 
#>  [8,]  64  687 
#>  [9,]  52  662 
#> [10,]  49  650 
#> [11,]  47  638 
#> 
#> $wildturkey
#> <xy [180 x 2]>
#>       [,1] [,2]
#>  [1,]  18  569 
#>  [2,]  18  555 
#>  [3,]  18  541 
#>  [4,]  18  527 
#>  [5,]  18  513 
#>  [6,] ...  ... 
#>  [7,]  73  713 
#>  [8,]  59  702 
#>  [9,]  45  690 
#> [10,]  33  679 
#> [11,]  24  665 
#> 
#> $yoichi
#> <xy [118 x 2]>
#>       [,1] [,2]
#>  [1,]  69  384 
#>  [2,]  69  369 
#>  [3,]  69  355 
#>  [4,]  69  340 
#>  [5,]  69  325 
#>  [6,] ...  ... 
#>  [7,]  92  531 
#>  [8,]  80  516 
#>  [9,]  72  501 
#> [10,]  69  487 
#> [11,]  68  472 
#> 
#> attr(,"class")
#> [1] "out"  "coo"  "list"

# Remove 5% of perimeter from each end
coo_trim_both(shapes$cat, n = 0.05)
#> <xy [106 x 2]>
#>       [,1] [,2]
#>  [1,] 194   42 
#>  [2,] 188   42 
#>  [3,] 182   42 
#>  [4,] 176   43 
#>  [5,] 170   43 
#>  [6,] ...  ... 
#>  [7,] 221   73 
#>  [8,] 222   67 
#>  [9,] 224   62 
#> [10,] 230   60 
#> [11,] 232   55