calcArea: Calculate the Areas of Polygons

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/PBSmapping.r

Description

Calculate the areas of polygons found in a PolySet.

Usage

1
calcArea (polys, rollup = 3)

Arguments

polys

PolySet to use.

rollup

level of detail in the results; 1 = PIDs only, by summing all the polygons with the same PID, 2 = outer contours only, by subtracting holes from their parent, and 3 = no roll-up.

Details

If rollup equals 1, the results contain an area 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 areas for each unique (PID, SID).

Outer polygons have positive areas and inner polygons negative areas. When polygons are rolled up, the routine sums the positive and negative areas and consequently accounts for holes.

If the PolySet's projection attribute equals "LL", the function projects the PolySet in UTM first. If the PolySet's zone attribute exists, it uses it for the conversion. Otherwise, it computes the mean longitude and uses that value to determine the zone. The longitude range of zone i is -186 + 6i < x <= -180 + 6i degrees.

Value

PolyData with columns PID, SID (may be missing), and area. If the projection equals "LL" or "UTM", the units of area are square kilometres.

Author(s)

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

See Also

calcCentroid, calcLength, calcMidRange, calcSummary, locatePolys.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
local(envir=.PBSmapEnv,expr={
  #--- load the data (if using R)
  if (!is.null(version$language) && (version$language == "R"))
    data(nepacLL,envir=.PBSmapEnv)
  #--- convert LL to UTM so calculation makes sense
  attr(nepacLL, "zone") <- 9
  nepacUTM <- convUL(nepacLL)
  #--- calculate and print the areas
  print(calcArea(nepacUTM))
})

Example output

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

-----------------------------------------------------------
PBS Mapping 2.70.5 -- Copyright (C) 2003-2020 Fisheries and Oceans Canada

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/local/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()'.
-----------------------------------------------------------


convUL: Converting coordinates within the northern hemisphere.
      PID         area
1       0 5.573726e+05
2       1 6.300381e+06
3      15 8.967819e+04
4      33 3.207198e+04
5      39 6.813302e+03
6      47 9.310090e+03
7      60 1.006880e+04
8      67 1.041737e+04
9      68 4.230791e+03
10     74 5.406475e+03
11     88 4.375389e+03
12     89 1.997024e+03
13    109 3.235804e+03
14    133 1.967937e+03
15    148 2.667601e+03
16    155 2.833465e+03
17    158 2.977172e+03
18    173 4.666767e+03
19    178 1.322215e+03
20    192 8.303504e+03
21    225 1.485232e+03
22    228 6.858324e+02
23    263 1.037473e+03
24    272 5.388982e+03
25    281 9.365769e+02
26    292 9.032412e+02
27    296 3.021929e+02
28    347 2.121584e+03
29    375 5.433573e+02
30    384 3.395853e+02
31    389 4.661454e+03
32    390 5.651404e+02
33    394 4.903152e+02
34    397 8.575281e+02
35    440 2.211727e+02
36    453 1.259021e+03
37    480 2.410199e+03
38    501 3.903431e+02
39    527 4.749897e+02
40    543 6.741911e+02
41    545 8.426110e+02
42    554 4.474327e+02
43    555 4.960560e+02
44    586 1.685368e+02
45    598 4.166715e+02
46    616 1.506424e+02
47    622 4.762893e+02
48    624 2.226559e+02
49    625 3.388461e+02
50    635 4.474264e+02
51    650 3.872434e+02
52    698 5.377822e+02
53    709 3.577049e+02
54    723 4.565756e+02
55    726 3.994991e+02
56    831 2.836407e+02
57    850 5.524838e+02
58    880 1.795207e+02
59    889 1.496277e+02
60    893 1.226877e+02
61    896 4.149567e+02
62    914 1.415734e+02
63    929 1.824923e+02
64    935 5.569482e+02
65    939 1.908028e+02
66    952 1.863538e+02
67    969 1.122716e+02
68    983 1.749225e+02
69    995 3.363498e+02
70   1035 1.485838e+02
71   1048 2.537314e+02
72   1070 8.275666e+01
73   1081 1.362039e+02
74   1084 8.968803e+01
75   1088 1.403633e+02
76   1101 1.925266e+02
77   1147 2.838530e+02
78   1162 3.840849e+02
79   1169 4.833114e+02
80   1216 1.624006e+02
81   1248 1.564446e+02
82   1260 1.923819e+02
83   1269 1.424737e+02
84   1297 1.549615e+02
85   1313 1.139319e+02
86   1330 3.174336e+02
87   1341 1.245480e+02
88   1348 8.127416e+01
89   1366 2.441107e+02
90   1375 3.651905e+02
91   1432 1.592560e+02
92   1459 9.369772e+01
93   1475 1.404781e+02
94   1510 1.209488e+02
95   1531 1.787296e+02
96   1533 1.571896e+02
97   1535 3.828714e+02
98   1549 2.001268e+02
99   1574 1.531845e+02
100  1576 1.711557e+02
101  1589 4.736366e+01
102  1602 4.405687e+01
103  1606 1.815225e+02
104  1625 1.591691e+02
105  1628 4.916090e+01
106  1681 7.835432e+01
107  1686 1.917815e+02
108  1748 3.071730e+02
109  1750 2.171260e+02
110  1772 7.963430e+01
111  1781 2.777636e+01
112  1790 6.987035e+01
113  1802 1.839917e+02
114  1828 2.285080e+02
115  1846 6.280899e+01
116  1852 1.097425e+02
117  1858 1.054277e+02
118  1884 2.000053e+02
119  1963 1.638806e+02
120  1983 4.279616e+01
121  2005 7.729500e+01
122  2017 1.226788e+02
123  2043 4.545674e+01
124  2051 6.744456e+01
125  2064 7.152778e+01
126  2091 1.266168e+02
127  2092 5.970632e+01
128  2093 6.986737e+01
129  2094 4.413175e+01
130  2098 9.266481e+01
131  2134 3.787221e+01
132  2171 6.978406e+01
133  2201 1.874381e+02
134  2203 7.573104e+01
135  2229 7.282501e+01
136  2252 2.779003e+02
137  2268 1.040983e+02
138  2270 5.205470e+01
139  2284 7.658677e+01
140  2285 1.105672e+02
141  2308 2.973159e+02
142  2321 9.706004e+01
143  2354 6.316048e+01
144  2361 5.064897e+01
145  2369 1.092948e+02
146  2397 1.021355e+02
147  2426 1.268735e+02
148  2457 9.903798e+01
149  2493 9.828807e+01
150  2558 1.317592e+02
151  2564 9.562046e+01
152  2574 2.572610e+02
153  2587 2.110238e+02
154  2594 8.562556e+01
155  2625 2.852086e+01
156  2627 4.009233e+01
157  2644 2.030539e+02
158  2685 3.716949e+01
159  2711 7.977117e+01
160  2758 2.174435e+01
161  2761 9.857905e+01
162  2767 3.420482e+02
163  2780 7.688430e+01
164  2815 9.043574e+01
165  2866 8.965021e+01
166  2924 7.670630e+01
167  2934 5.675788e+01
168  2945 8.488019e+01
169  2953 6.723468e+01
170  3039 6.069655e+01
171  3055 3.668715e+01
172  3075 2.853238e+02
173  3101 5.681644e+01
174  3124 5.076207e+01
175  3151 3.398757e+01
176  3157 7.535407e+01
177  3160 8.599291e+01
178  3249 2.137674e+01
179  3276 3.407856e+01
180  3298 1.676920e+02
181  3324 6.699849e+01
182  3340 1.807175e+01
183  3346 4.329742e+01
184  3368 4.989213e+01
185  3412 2.123455e+02
186  3416 1.183378e+02
187  3417 8.149021e+01
188  3443 6.435648e+01
189  3449 2.479154e+01
190  3481 3.768658e+01
191  3486 3.951770e+01
192  3494 2.602719e+01
193  3520 3.071191e+01
194  3526 2.932781e+01
195  3540 1.082972e+02
196  3545 3.765096e+01
197  3547 6.554107e+01
198  3569 1.054616e+01
199  3613 8.057048e+01
200  3665 1.414316e+01
201  3675 5.015346e+01
202  3752 5.692447e+01
203  3762 2.337425e+01
204  3840 2.345740e+01
205  3853 7.811320e+01
206  3857 1.545414e+01
207  3893 2.947421e+01
208  3902 5.071695e+01
209  3938 2.691686e+01
210  3956 5.359758e+01
211  3990 5.209052e+01
212  4014 1.733781e+01
213  4016 4.331889e+01
214  4031 9.364575e+01
215  4033 5.866637e+01
216  4067 1.172859e+01
217  4116 2.160759e+01
218  4155 8.368403e+01
219  4174 4.633602e+01
220  4208 2.122579e+01
221  4230 5.070725e+01
222  4243 1.325691e+02
223  4258 2.249161e+01
224  4266 2.348937e+01
225  4301 8.764771e+01
226  4313 2.021719e+01
227  4314 3.396173e+01
228  4321 2.564443e+01
229  4333 1.400711e+01
230  4357 5.985708e+01
231  4368 7.097564e+01
232  4383 3.256971e+01
233  4386 3.925581e+01
234  4387 1.023865e+02
235  4401 2.637316e+01
236  4413 2.398978e+01
237  4435 3.168449e+01
238  4469 1.772959e+01
239  4527 1.500613e+01
240  4558 9.354776e+00
241  4590 3.765428e+01
242  4592 1.298150e+01
243  4601 1.512858e+01
244  4638 4.413062e+01
245  4655 3.517287e+01
246  4660 3.255914e+01
247  4670 5.305580e+01
248  4704 9.153083e+00
249  4723 3.546890e+01
250  4736 1.375909e+01
251  4748 3.647044e+00
252  4775 3.042028e+01
253  4787 1.039639e+01
254  4850 1.055836e+02
255  4872 5.016819e+01
256  4904 4.203985e+01
257  4933 3.541231e+01
258  4944 1.332630e+01
259  5003 3.920170e+01
260  5021 3.036075e+01
261  5029 3.750542e+01
262  5054 1.727310e+01
263  5055 3.587677e+01
264  5108 5.012782e+01
265  5111 1.638795e+01
266  5116 7.654524e+00
267  5117 3.685234e+01
268  5146 1.637545e+01
269  5160 1.940546e+01
270  5161 1.891367e+01
271  5165 3.187403e+01
272  5190 1.969428e+01
273  5196 2.507502e+01
274  5266 1.380056e+01
275  5386 1.408562e+01
276  5426 1.715997e+01
277  5477 2.048511e+01
278  5479 6.687978e+01
279  5503 5.008863e+01
280  5515 8.876092e+01
281  5519 2.237233e+01
282  5536 4.558622e+01
283  5539 3.251385e+01
284  5552 1.784966e+01
285  5563 9.164193e+00
286  5570 3.597950e+01
287  5628 4.706172e+01
288  5637 1.353463e+01
289  5672 1.836638e+01
290  5681 6.039673e+01
291  5714 3.108194e+01
292  5718 3.864404e+01
293  5732 4.022620e+01
294  5738 2.167851e+01
295  5771 2.092330e+01
296  5833 1.196190e+01
297  5859 2.920587e+01
298  5930 4.839857e+01
299  5955 2.064087e+01
300  6000 1.449475e+01
301  6004 4.730319e+00
302  6060 3.598082e+01
303  6090 3.794923e+01
304  6096 2.294223e+01
305  6137 2.234553e+01
306  6149 1.355277e+01
307  6167 3.696385e+00
308  6170 1.261890e+01
309  6182 4.650806e+01
310  6220 2.537743e+01
311  6229 1.470413e+01
312  6233 1.210070e+01
313  6241 1.146304e+01
314  6267 4.611001e+01
315  6315 5.215054e+00
316  6339 7.525347e+00
317  6352 2.709960e+00
318  6403 6.020523e+00
319  6414 2.311502e+01
320  6417 5.544204e+00
321  6434 7.138071e+00
322  6437 1.658727e+01
323  6471 2.382578e+01
324  6482 2.845043e+01
325  6483 2.610735e+01
326  6523 2.022405e+01
327  6555 1.674877e+01
328  6556 2.753762e+01
329  6559 5.370775e+01
330  6560 3.368400e+00
331  6573 3.591710e+01
332  6607 4.889175e+01
333  6656 1.074749e+01
334  6674 3.134614e+01
335  6712 2.964491e+00
336  6719 6.591210e+00
337  6725 5.551746e+00
338  6737 9.994421e+00
339  6762 1.271415e+01
340  6787 2.175074e+01
341  6820 2.453901e+01
342  6839 8.986792e+00
343  6869 1.793736e+01
344  6884 3.274904e+00
345  6892 9.335097e+00
346  6895 3.565771e+01
347  6909 8.640863e+00
348  6918 6.076977e+01
349  6919 1.239409e+01
350  6945 8.953700e+00
351  7003 4.509687e+00
352  7006 3.402677e+01
353  7033 1.273709e+01
354  7064 6.161227e+00
355  7075 2.141128e+01
356  7082 4.674368e+00
357  7084 2.170611e+01
358  7108 2.087927e+01
359  7113 2.247923e+01
360  7135 4.841725e+00
361  7143 7.388099e+00
362  7144 2.666942e+01
363  7151 5.038029e+01
364  7162 1.594451e+01
365  7175 1.931469e+01
366  7182 6.582530e+00
367  7218 1.796210e+01
368  7220 1.775018e+01
369  7227 3.466416e+00
370  7286 9.208656e+00
371  7351 7.422380e+00
372  7360 5.345301e+00
373  7365 4.905683e+00
374  7519 1.627346e+01
375  7533 1.199310e+01
376  7534 4.547350e+00
377  7556 3.501450e+01
378  7560 4.440211e+00
379  7579 7.854336e+00
380  7581 1.537270e+01
381  7583 8.566389e+00
382  7599 2.072543e+01
383  7658 7.786387e+00
384  7791 2.273828e+01
385  7794 2.209823e+01
386  7818 6.852093e+00
387  7831 5.767418e+00
388  7864 7.064188e+00
389  7903 1.240081e+01
390  7929 8.050660e+00
391  7972 1.371476e+01
392  7975 2.760582e+01
393  8017 2.434301e+01
394  8024 6.853771e+00
395  8054 1.737916e+01
396  8057 6.204336e+00
397  8067 1.505619e+00
398  8073 1.422877e+01
399  8097 6.083653e+00
400  8144 5.674133e+00
401  8161 8.600489e+00
402  8162 9.522520e+00
403  8221 1.401223e+01
404  8249 9.299116e+00
405  8254 8.417962e+00
406  8272 1.821246e+01
407  8280 5.829984e+00
408  8391 1.738204e+01
409  8397 3.729041e+01
410  8401 9.153001e+00
411  8485 1.086285e+01
412  8506 2.199247e+01
413  8561 2.004195e+01
414  8565 6.336475e+00
415  8586 7.764588e+00
416  8660 1.740742e+00
417  8679 6.152503e+00
418  8685 1.115215e+01
419  8702 5.795322e+00
420  8707 4.271897e+00
421  8777 1.092486e+01
422  8779 6.425602e+00
423  8782 1.186125e+01
424  8839 5.008113e+00
425  8841 2.046333e+01
426  8849 8.749042e+00
427  8893 1.214685e+01
428  8896 1.163188e+01
429  8920 7.857386e+00
430  8956 8.841112e+00
431  9000 8.595464e+00
432  9014 1.166269e+01
433  9016 6.453700e+00
434  9043 7.714008e+00
435  9054 5.984765e+00
436  9055 5.733886e+00
437  9059 9.380208e+00
438  9067 9.337227e+00
439  9077 5.107981e+01
440  9149 1.799562e+01
441  9157 4.517511e+01
442  9181 6.000011e+00
443  9183 3.357655e+00
444  9309 1.773748e+01
445  9363 4.474953e+00
446  9383 3.558104e+00
447  9407 1.850928e+01
448  9413 7.479692e+00
449  9422 7.345400e+00
450  9436 7.388800e+00
451  9461 1.250739e+01
452  9478 3.014177e+00
453  9507 1.312864e+01
454  9511 1.130357e+01
455  9530 2.678091e+00
456  9546 2.614580e+00
457  9573 3.301257e+00
458  9593 7.864571e+00
459  9675 1.886705e+01
460  9687 6.397339e+00
461  9689 1.861781e+01
462  9715 7.198189e+00
463  9764 1.277108e+01
464  9822 8.126804e+00
465  9829 1.077233e+01
466  9843 9.153711e+00
467  9845 5.961398e+00
468  9853 1.522566e+01
469  9875 1.303774e+01
470  9879 1.737669e+00
471  9909 2.532630e+01
472  9933 7.791660e+00
473  9937 4.946819e+00
474  9940 1.830740e+00
475  9989 8.426466e+00
476  9994 6.237857e+00
477 10048 3.696878e+01
478 10064 1.268319e+01
479 10069 1.922207e+01
480 10083 4.132837e+00
481 10099 2.328433e+01
482 10186 7.404168e+00
483 10237 4.266537e+00
484 10262 2.279309e+00
485 10280 1.036542e+01
486 10311 2.569079e+00
487 10318 9.054260e+00
488 10350 1.173348e+01
489 10371 3.756576e+00
490 10380 4.513798e+00
491 10384 1.779953e+01
492 10414 3.750307e+00
493 10469 2.845845e+00
494 10470 1.161657e+01
495 10476 1.732901e+01

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