Calculate the Areas of Polygons
Calculate the areas of polygons found in a PolySet.
calcArea (polys, rollup = 3)
polys |
PolySet to use. |
rollup |
level of detail in the results; |
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.
Nicholas M. Boers, Associate Professor – Computer Science
MacEwan University, Edmonton AB
Last modified Rd: 2013-04-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)) })
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.