makeriverdensity: Calculate Kernel Density Using River Distance

View source: R/plotdensity.R

makeriverdensityR Documentation

Calculate Kernel Density Using River Distance

Description

Uses spatial point data (segment and vertex) to calculate a kernel density object to use in the output class plotting method,plot.riverdensity. Scaled kernel density is calculated at approximately regularly-spaced locations, with spacing specified by the user.

If an argument is used in the survey field, kernel densities will be calculated for each unique value of survey, resulting in a separate plot for each.

The purpose of this function is to generate a kernel density object to plot using plot(), see plot.riverdensity.

Usage

makeriverdensity(
  seg,
  vert,
  rivers,
  survey = NULL,
  kernel = "gaussian",
  bw = NULL,
  resolution = NULL
)

Arguments

seg

A vector of river locations (segment)

vert

A vector of river locations (vertex)

rivers

The river network object to use

survey

A vector of survey IDs corresponding to the values of seg and vert. If this argument is used, kernel densities will be calculated for each unique survey, and separate plots will be produced.

kernel

The type of density kernel to use. Allowed types are "gaussian" (normal) and "rect" (rectangular, giving simple density). Defaults to "gaussian".

bw

The kernel bandwidth to use. If kernel is set to "gaussian", this provides the standard deviation of the gaussian (normal) kernel to use. If kernel is set to "rect", this provides the half-width of the rectangular kernel, or the distance to use in simple density. Accepting the default (NULL) will result in the function determining a value to use, based on the total length of the river network and the value of the resolution argument.

resolution

The approximate spacing of the river locations used for kernel density calculation. Accepting the default (NULL) will result in the function determining a value to use, based on the total length of the river network.

Value

A river density object, see riverdensity-class.

Note

It is likely that calculation will be very slow. Use of this function with a river network for which segment routes has not yet been calculated is not recommended.

This function is distance-computation intensive, and may be slow-running if a river network is used that does not have segment routes and/or distance lookup tables for fast distance computation. See buildsegroutes and/or buildlookup for more information.

Author(s)

Matt Tyers

See Also

plot.riverdensity, plotriverdensitypoints

Examples

data(Gulk, fakefish)

Gulk_dens <- makeriverdensity(seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, 
  survey=fakefish$flight.date)
  
# # 10 plots will be created, recommend calling par(mfrow=c(2,5))
plot(x=Gulk_dens)

riverdist documentation built on Aug. 22, 2023, 5:06 p.m.