This function can return a crown map as either a raster or a SpatialPolygonsDataFrame,
as defined using the format
argument. For most analytical purposes, it is preferable to have
crown outlines as polygons. However, polygonal crown maps take up significantly more disk space, and take
longer to process. It is advisable to run this function using a raster output first, in order to check
its results and adjust parameters.
Using the 'polygons' output format
provides the added benefit of transferring
treetop attributes (such as height) to the newly created polygons. The area of each crown will also
automatically be calculated and added to the polygons' data under the crownArea field. Furthermore,
"orphaned" segments (i.e.: outlines without an associated treetop) will be removed when
format
is set to 'polygons'.
By default, polygonal crown outlines are produced internally using the the rasterToPolygons
function from
the raster package. This function is problematic due to it being 1) very slow and 2) leaking memory
when applied to multiple datasets. An alternative is provided for users who've installed OSGeo4W and Python.
By setting the OSGeoPath
path to the OSGeo4W installation directory (usually 'C:\OSGeo4W64'), the function will
use the gdal_polygonize.py GDAL utility to generate polygonal crown outlines instead.