calcArea {PBSmapping} | R Documentation |
Calculates the areas of polygons found in a PolySet.
calcArea (polys, rollup = 3)
polys |
PolySet to use. |
rollup |
level of detail in the results; 1 = PID s
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. |
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.
PolyData with columns PID
, SID
(may be
missing), and area
. If the projection equals "LL"
or
"UTM"
, the units of area are square kilometres.
calcCentroid
,
calcLength
,
calcMidRange
,
calcSummary
,
locatePolys
.
#--- load the data (if using R) if (!is.null(version$language) && (version$language == "R")) data(nepacLL) #--- convert LL to UTM so calculation makes sense attr(nepacLL, "zone") <- 9 nepacUTM <- convUL(nepacLL) #--- calculate and print the areas print(calcArea(nepacUTM))