Defines boundary elements in a SpatRaster object.
For categorical traits, boundary elements are defined as cells that neighbor a patch with a different value.
If the trait is quantitative, function will keep a proportion of the cells with the highest boundary intensity values,
with a threshold chosen by the user. If the SpatRaster contains trait values, boundary intensity values can be
calculated (calculate_intensity = T) using a Sobel-Feldman operator.
In some cases, there may be many redundant values for boundary intensity. If the threshold is set to cut off the values
at those points, the actual proportion of cells categorized as boundary elements would differ from the intended
threshold. The function reports the proportion of cells that are boundary elements, so that users can choose a
different value, if necessary.