Description Usage Arguments Value Examples
Calculate summary and spatial statistics across a single matrix or raster.
1 2 3 4 5 6 7 8 9 10 11 12 |
img |
A numeric temperature matrix (such as that returned from
|
id |
The image ID (optional). Useful when iterating over numerous images. |
calc_connectivity |
Whether or not to calculate cthermal connectivity across pixels (slow for large rasters). Defaults to TRUE. |
conn_threshold |
Climate threshold to use for calculation of thermal
connectivity (i.e. the amount of change that organisms would be seeking
to avoid). See |
patches |
Whether to identify hot and cold spots. Defaults to TRUE. |
style |
Style to use when calculating neighbourhood weights using
|
img_proj |
Spatial projection. Optional, but necessary for geographic data to plot correctly. |
img_extent |
Spatial extent. Optional, but necessary for geographic data to plot correctly. |
return_vals |
Which values to return? Any combination of the dataframe
( |
sum_stats |
Summary statistics that should be calculated across
all pixels. Several helper functions are included for use here:
|
A list containing:
df |
A dataframe with one row for each pixel, and variables denoting:
the pixel value (val); the original spatial location of the pixel (x and y);
its patch classification (G_bin) into a hot (1), cold (-1) or no patch (0)
according to the Z value (see |
patches |
A SpatialPolygonsDataFrame of hot and cold patches. Hot patches have a value of 1, and cold patches a value of -1. |
pstats |
A dataframe with patch statistics for hot patches and cold
patches, respectively. See |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ## Not run:
# FLIR temperature matrix ---------------------------------------------------
# Define individual matrix and raster
img <- flir11835$flir_matrix
val_raster <-
raster::raster(img,
xmn=0, xmx=ncol(img),
ymn=0, ymx=nrow(img))
# Define image ID (the photo number in this case)
id <- flir11835$photo_no
# Get stats!
get_stats(img = img,
id = id,
calc_connectivity = TRUE,
conn_threshold = 1.5,
patches = TRUE,
style = "C",
img_proj = NULL,
img_extent = NULL,
return_vals = "pstats",
sum_stats = c("mean", "min","max"))
get_stats(img = val_raster,
id = id,
calc_connectivity = TRUE,
conn_threshold = 1.5,
patches = TRUE,
style = "C",
img_proj = NULL,
img_extent = NULL,
return_vals = "pstats",
sum_stats = c("mean", "min","max"))
# Worldclim2 temperature raster ---------------------------------------------
# Dataset 'sulawesi_temp' represents mean January temperature for the
# island of Sulawesi
# Define projection and extent
img_proj <- raster::projection(sulawesi_temp)
img_extent <- raster::extent(sulawesi_temp)
# Find hot and cold patches
worldclim_results <-
get_stats(img = sulawesi_temp,
id = "sulawesi",
calc_connectivity = FALSE,
style = "C",
img_proj = img_proj,
img_extent = img_extent,
return_vals = c("df", "patches", "pstats"),
sum_stats = c("mean", "min","max"))
# Plot!
df <- worldclim_results$df
patches <- worldclim_results$patches
plot_patches(df, patches, print_plot = TRUE, save_plot = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.