# calcCentroid: Calculate the Centroids of Polygons In PBSmapping: Mapping Fisheries Data and Spatial Analysis Tools

## Description

Calculate the centroids of polygons found in a PolySet.

## Usage

 `1` ```calcCentroid (polys, rollup = 3) ```

## Arguments

 `polys` PolySet to use. `rollup` level of detail in the results; `1` = `PID`s only, `2` = outer contours only, and `3` = no roll-up. When `rollup` equals `1` and `2`, the function appropriately adjusts for polygons with holes.

## Details

If `rollup` equals `1`, the results contain a centroid for each unique `PID` only. When it equals `2`, they contain entries for outer contours only. Finally, setting it to `3` prevents roll-up, and they contain a centroid for each unique (`PID`, `SID`).

## Value

PolyData with columns `PID`, `SID` (may be missing), `X`, and `Y`.

## Author(s)

Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Last modified `Rd: 2013-04-10`

`calcArea`, `calcLength`, `calcMidRange`, `calcSummary`, `locateEvents`, `locatePolys`.

## Examples

 ```1 2 3 4 5 6 7``` ```local(envir=.PBSmapEnv,expr={ #--- load the data (if using R) if (!is.null(version\$language) && (version\$language=="R")) data(nepacLL,envir=.PBSmapEnv) #--- calculate and print the centroids for several polygons print(calcCentroid(nepacLL[is.element(nepacLL\$PID,c(33,39,47)),])) }) ```

### Example output

```sh: 1: cannot create /dev/null: Permission denied

-----------------------------------------------------------

PBS Mapping comes with ABSOLUTELY NO WARRANTY;
for details see the file COPYING.
This is free software, and you are welcome to redistribute
it under certain conditions, as outlined in the above file.

A complete user guide 'PBSmapping-UG.pdf' is located at
/usr/lib/R/site-library/PBSmapping/doc/PBSmapping-UG.pdf

Packaged on 2018-06-05
Pacific Biological Station, Nanaimo

All available PBS packages can be found at
https://github.com/pbs-software

To see demos, type '.PBSfigs()'.
-----------------------------------------------------------

PID         X        Y
1  33 -125.7302 49.64381
2  39 -132.7354 55.52470
3  47 -132.2675 53.44296
```

PBSmapping documentation built on Jan. 15, 2021, 3:41 p.m.