# set working directory
setwd("E:/WILD401/LAB4")
#install packages and load libraries
install.packages("raster")
install.packages("adehabitatMA")
library(raster)
library(sp)
library(adehabitatMA)
#Read in the the Canada.gri file using the raster function!
library(raster)
## Warning: package 'raster' was built under R version 4.1.3
## Loading required package: sp
## Warning: package 'sp' was built under R version 4.1.3
canada <- raster("Canada Land Cover.gri")
#Let's summarize the raster map file
canada
## class : RasterLayer
## dimensions : 2863, 3424, 9802912 (nrow, ncol, ncell)
## resolution : 1000, 1000 (x, y)
## extent : -833000, 2591000, 1559000, 4422000 (xmin, xmax, ymin, ymax)
## crs : +proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +ellps=sphere +units=m +no_defs
## source : Canada Land Cover.grd
## names : NA_export02
## values : 0, 19 (min, max)
#makes a set of colours for our plot
colours = c("white","darkgreen", "darkolivegreen", "chartreuse3", "chartreuse", "forestgreen", "green3", "darkgoldenrod3", "goldenrod1", "darkorange", "gold1", "lightgoldenrod3", "khaki3", "darkseagreen", "saddlebrown", "yellow", "slategray", "red3", "deepskyblue4", "white")
#set plot margins
par(mar = c(4,4,1,10))
#plots our raster Canada, using our list of colours.
plot<-plot(canada, col = colours, xlab = "Longitude (m)", ylab = "Latitude (m)", legend = FALSE)
## 2.4 Load in land cover classes:
#```{r eval=FALSE}
land.cover.classes <- read.csv("Land_Cover_Classes.csv")
#create a column “ID” that numbers our land cover classes
colnames(land.cover.classes)[1] <- "ID"
land.cover.classes #Take a look at the land cover classes
## ID Class_name
## 1 0
## 2 1 Temperate or sub-polar needleleaf forest
## 3 2 Sub-polar taiga needleleaf forest
## 4 3 Tropical or sub-tropical broadleaf evergreen
## 5 4 Tropical or sub-tropical broadleaf deciduous
## 6 5 Temperate or sub-polar broadleaf deciduous
## 7 6 Mixed Forest
## 8 7 Tropical or sub-tropical shrubland
## 9 8 Temperate or sub-polar shrubland
## 10 9 Tropical or sub-tropical grassland
## 11 10 Temperate or sub-polar grassland
## 12 11 Sub-polar or polar shrubland-lichen-moss
## 13 12 Sub-polar or polar grassland-lichen-moss
## 14 13 Sub-polar or polar barren-lichen-moss
## 15 14 Wetland
## 16 15 Cropland
## 17 16 Barren Lands
## 18 17 Urban and Built-up
## 19 18 Water
## 20 19 Snow and Ice
## 2.5 Add land cover classes to map and create a legend
#```{r eval=FALSE}
par(xpd = TRUE)
legend(x=2600000, y=4500000,legend=land.cover.classes[c(-1,-4,-5,-8,-10),"Class_name"],fill=colours[c(-1,-4,-5,-8,-9)],cex = 0.6)
# creates object habitat.available, by turning frequency of pixels in “canada” into as.data.frame()
habitat.available <- as.data.frame(freq(canada))
colnames(habitat.available)[1] <- "ID" # “colnames() function retrieves or sets the column names of matrix”
habitat.available
## ID count
## 1 0 4044004
## 2 1 920966
## 3 2 199379
## 4 5 309804
## 5 6 422708
## 6 8 461137
## 7 10 254212
## 8 11 79745
## 9 12 453330
## 10 13 205577
## 11 14 147492
## 12 15 482242
## 13 16 380877
## 14 17 28691
## 15 18 1319875
## 16 19 92873
#merge() merges two data frames by common columns or row names. Here, x is land cover classes, and y is the available habitat. Merges them by their common ID
hab.avail.merge <- merge(x = land.cover.classes, y = habitat.available, by ="ID")
hab.avail.merge
## ID Class_name count
## 1 0 4044004
## 2 1 Temperate or sub-polar needleleaf forest 920966
## 3 2 Sub-polar taiga needleleaf forest 199379
## 4 5 Temperate or sub-polar broadleaf deciduous 309804
## 5 6 Mixed Forest 422708
## 6 8 Temperate or sub-polar shrubland 461137
## 7 10 Temperate or sub-polar grassland 254212
## 8 11 Sub-polar or polar shrubland-lichen-moss 79745
## 9 12 Sub-polar or polar grassland-lichen-moss 453330
## 10 13 Sub-polar or polar barren-lichen-moss 205577
## 11 14 Wetland 147492
## 12 15 Cropland 482242
## 13 16 Barren Lands 380877
## 14 17 Urban and Built-up 28691
## 15 18 Water 1319875
## 16 19 Snow and Ice 92873
habitat.available.prop <- within(hab.avail.merge[-1,], {prop.available <- count/sum(count)})
#within() evaluates an R expression in an environment constructed from data,possibly modifying (a copy of) the original data. Here we create habitat.available.prop by adding to habitat.avail.merge, a column that is the calculation of count/sum(count)aka. Proportion and calls it prop.available
habitat.available.prop
## ID Class_name count prop.available
## 2 1 Temperate or sub-polar needleleaf forest 920966 0.159920249
## 3 2 Sub-polar taiga needleleaf forest 199379 0.034620973
## 4 5 Temperate or sub-polar broadleaf deciduous 309804 0.053795615
## 5 6 Mixed Forest 422708 0.073400721
## 6 8 Temperate or sub-polar shrubland 461137 0.080073688
## 7 10 Temperate or sub-polar grassland 254212 0.044142396
## 8 11 Sub-polar or polar shrubland-lichen-moss 79745 0.013847243
## 9 12 Sub-polar or polar grassland-lichen-moss 453330 0.078718049
## 10 13 Sub-polar or polar barren-lichen-moss 205577 0.035697219
## 11 14 Wetland 147492 0.025611105
## 12 15 Cropland 482242 0.083738445
## 13 16 Barren Lands 380877 0.066137018
## 14 17 Urban and Built-up 28691 0.004982021
## 15 18 Water 1319875 0.229188416
## 16 19 Snow and Ice 92873 0.016126842
#Matrix setting probabilities for each land cover type
probs <- matrix(c(0,0,1,2,2,1.5,3,0,4,0,5,0.75,6,0.75,7,0,8,0.1,9,0,10,0.1,11,0,12,0,13,0,14,0.2,15,0,16,0,17,0,18,0,19,0), nrow = 20, ncol = 2, byrow = TRUE)
probs
## [,1] [,2]
## [1,] 0 0.00
## [2,] 1 2.00
## [3,] 2 1.50
## [4,] 3 0.00
## [5,] 4 0.00
## [6,] 5 0.75
## [7,] 6 0.75
## [8,] 7 0.00
## [9,] 8 0.10
## [10,] 9 0.00
## [11,] 10 0.10
## [12,] 11 0.00
## [13,] 12 0.00
## [14,] 13 0.00
## [15,] 14 0.20
## [16,] 15 0.00
## [17,] 16 0.00
## [18,] 17 0.00
## [19,] 18 0.00
## [20,] 19 0.00
#get values! Values() is shorthand for getvalues(), which returns all values or the values for a number of rows of a Raster* object. Values returned for a RasterLayer are a vector. Here, we create probs.2 as the values created by reclassifying raster cells in Canada by probs
probs.2 <- values(reclassify(canada, probs))
#we create probs.3
probs.3 <- probs.2/sum(probs.2)
#we create moose.loc.cells, which are a sample from probs.3 sample() “takes a sample of the specified size from the elements of x using either with or with out replacement”
moose.locs.cells <- sample(1:ncell(canada), 100, prob = probs.3)
#xyFromCell() “get[s] coordinates of the center of raster cells for a row, column, or cell number of a Raster* object”. Basically we are extracting coordinates from Canada moose locations we made
moose.locs.xy <- xyFromCell(canada, moose.locs.cells)
#we create lc.classes.canada, which is a list of values (not an object) made from land.cover.classes.
lc.classes.canada<-land.cover.classes[c(-1,-4,-5,-8,-10),"Class_name"]
lc.classes.canada
## [1] "Temperate or sub-polar needleleaf forest"
## [2] "Sub-polar taiga needleleaf forest"
## [3] "Temperate or sub-polar broadleaf deciduous"
## [4] " Mixed Forest"
## [5] "Temperate or sub-polar shrubland"
## [6] "Temperate or sub-polar grassland"
## [7] "Sub-polar or polar shrubland-lichen-moss"
## [8] "Sub-polar or polar grassland-lichen-moss"
## [9] "Sub-polar or polar barren-lichen-moss"
## [10] "Wetland"
## [11] "Cropland"
## [12] "Barren Lands"
## [13] "Urban and Built-up"
## [14] "Water"
## [15] "Snow and Ice"
#we set our colours
colours.canada <- colours[c(-1,-4,-5,-8,-9)]
colours.canada
## [1] "darkgreen" "darkolivegreen" "forestgreen" "green3"
## [5] "darkorange" "gold1" "lightgoldenrod3" "khaki3"
## [9] "darkseagreen" "saddlebrown" "yellow" "slategray"
## [13] "red3" "deepskyblue4" "white"
#we make our margins
par(mar = c(5,5,1,10))
#we plot Canada again
plot(canada, col = colours, xlab = "Longitude (m)", ylab = "Latitude (m)", legend = FALSE)
par(xpd = TRUE) #xpd=true allows things to be drawn outside the plot margins
legend(x=2600000, y = 4500000, legend = lc.classes.canada, fill = colours.canada, cex = 0.6)
#we put moose on the map
points(moose.locs.xy, pch = 18)
canada.spdf <- as(canada, "SpatialPixelsDataFrame")
moose.locs.xy.proj <- SpatialPoints(moose.locs.xy, proj4string = CRS("+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"))
library(adehabitatMA)
## Warning: package 'adehabitatMA' was built under R version 4.1.3
## Registered S3 methods overwritten by 'adehabitatMA':
## method from
## print.SpatialPixelsDataFrame sp
## print.SpatialPixels sp
##
## Attaching package: 'adehabitatMA'
## The following object is masked from 'package:raster':
##
## buffer
habitat.used <- join(moose.locs.xy.proj, canada.spdf) #we join moose locations to canada spatial
habitat.used.2 <-table(land.cover.classes[habitat.used+1,"Class_name"]) #builds a “contingency table”
habitat.used.2[-1]
##
## Sub-polar taiga needleleaf forest
## 13
## Temperate or sub-polar broadleaf deciduous
## 5
## Temperate or sub-polar grassland
## 1
## Temperate or sub-polar needleleaf forest
## 73
## Wetland
## 1
HSR <- function(habitat.available.df, habitat.used.vec, class.label){ #Column identifying habitat class must have the label "class"
# Function to calculate habitat selection ratios
table.use <- table(habitat.used.vec)
prop.used <- table.use / 100
prop.used.df <- data.frame(class = names(prop.used), prop.used = as.vector(prop.used))
colnames(prop.used.df)[1] <- class.label
used.avail.cmb <- merge(habitat.available.df, prop.used.df, by = class.label)
output <- within(used.avail.cmb, {selection.ratio <- prop.used / prop.available})
return(output)
}
habitat.ratios <- HSR(habitat.available.prop, habitat.used, "ID")
habitat.ratios
## ID Class_name count prop.available prop.used
## 1 1 Temperate or sub-polar needleleaf forest 920966 0.15992025 0.73
## 2 2 Sub-polar taiga needleleaf forest 199379 0.03462097 0.13
## 3 5 Temperate or sub-polar broadleaf deciduous 309804 0.05379562 0.05
## 4 6 Mixed Forest 422708 0.07340072 0.07
## 5 10 Temperate or sub-polar grassland 254212 0.04414240 0.01
## 6 14 Wetland 147492 0.02561111 0.01
## selection.ratio
## 1 4.5647753
## 2 3.7549493
## 3 0.9294438
## 4 0.9536691
## 5 0.2265396
## 6 0.3904556
par(mar = c(5,5,1,1)) #set margins
plot(canada, col = colours, xlab = "Longitude (m)", ylab = "Latitude (m)", legend = FALSE) #plot canada
par(xpd = TRUE) #set up legends
legend(x=2600000, y = 4500000, legend = lc.classes.canada, fill = colours.canada, cex = 0.6) #make legend
extent <- extent(1250000,2100000,1900000,3000000)
quebec <- crop(canada, extent)
par(mar = c(4,4,1,10))
plot(quebec, col = colours, xlab = "Longitude (m)", ylab = "Latitude (m)", legend = FALSE)
par(xpd = TRUE)
legend(x=2500000, y = 2970000, legend = lc.classes.canada, fill = colours.canada, cex = 0.6)
## 7.3 Collar moose in Quebec
probs.que <- matrix(c(0,0,1,1.5,2,1.5,3,0,4,0,5,1,6,2,7,0,8,0.7,9,0,10,0.5,11,0,12,0,13,0,14,0.3,15,0.1,16,0,17,0.1,18,0,19,0), nrow = 20, ncol = 2, byrow= TRUE) #Set probabilities for each habitat type
probs.que.2 <- values(reclassify(quebec, probs.que))
probs.que.3 <- probs.que.2/sum(probs.que.2)
moose.locs.cells.que <- sample(1:ncell(quebec), 100, prob = probs.que.3)
moose.locs.xy.que <- xyFromCell(quebec, moose.locs.cells.que)
moose.locs.xy.proj.que <- SpatialPoints(moose.locs.xy.que, proj4string = CRS("+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"))
## 7.4 Plot locations of collared moose
plot(quebec, col = colours, xlab = "Longitude (m)", ylab = "Latitude (m)", legend = FALSE)
par(xpd = TRUE)
legend(x=2500000, y = 2970000, legend = land.cover.classes[c(-1,-4,-5,-8,-10),"Class_name"], fill = colours[c(-1,-4,-5,-8,-9)], cex = 0.5)
plot(moose.locs.xy.proj.que, add = TRUE, pch = 16)
## 7.5 Quantify available habitat in Quebec
habitat.available.que <- freq(quebec) #find frequency of raster cells in Quebec
habitat.available.cmb.que <- cbind(habitat.available.que, land.cover.classes[
c(-4,-5,-8,-10),]) [,-3] #combines habitat.available.que and land.cover.classes
habitat.available.prop.que <- within(habitat.available.cmb.que[-1,], {prop.available <- count/sum(count)}) #adds proportions to table
habitat.available.prop.que[,-1]
## count Class_name prop.available
## 2 190829 Temperate or sub-polar needleleaf forest 2.203492e-01
## 3 46127 Sub-polar taiga needleleaf forest 5.326259e-02
## 6 68934 Temperate or sub-polar broadleaf deciduous 7.959770e-02
## 7 169591 Mixed Forest 1.958258e-01
## 9 24025 Temperate or sub-polar shrubland 2.774153e-02
## 11 5550 Temperate or sub-polar grassland 6.408554e-03
## 12 19743 Sub-polar or polar shrubland-lichen-moss 2.279713e-02
## 13 92775 Sub-polar or polar grassland-lichen-moss 1.071268e-01
## 14 18704 Sub-polar or polar barren-lichen-moss 2.159740e-02
## 15 34688 Wetland 4.005404e-02
## 16 11427 Cropland 1.319469e-02
## 17 2404 Barren Lands 2.775885e-03
## 18 1454 Urban and Built-up 1.678926e-03
## 19 179776 Water 2.075863e-01
## 20 3 Snow and Ice 3.464083e-06
library(adehabitatHR)
## Warning: package 'adehabitatHR' was built under R version 4.1.3
## Loading required package: deldir
## Warning: package 'deldir' was built under R version 4.1.3
## deldir 1.0-6 Nickname: "Mendacious Cosmonaut"
##
## The syntax of deldir() has had an important change.
## The arguments have been re-ordered (the first three
## are now "x, y, z") and some arguments have been
## eliminated. The handling of the z ("tags")
## argument has been improved.
##
## The "dummy points" facility has been removed.
## This facility was a historical artefact, was really
## of no use to anyone, and had hung around much too
## long. Since there are no longer any "dummy points",
## the structure of the value returned by deldir() has
## changed slightly. The arguments of plot.deldir()
## have been adjusted accordingly; e.g. the character
## string "wpoints" ("which points") has been
## replaced by the logical scalar "showpoints".
## The user should consult the help files.
## Loading required package: ade4
## Warning: package 'ade4' was built under R version 4.1.3
## Loading required package: adehabitatLT
## Warning: package 'adehabitatLT' was built under R version 4.1.3
## Loading required package: CircStats
## Warning: package 'CircStats' was built under R version 4.1.3
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following objects are masked from 'package:raster':
##
## area, select
## Loading required package: boot
moose.locs.xy.proj.df.que <- as(moose.locs.xy.proj.que, "SpatialPointsDataFrame")
quebec.sp <- as(quebec, "SpatialPixelsDataFrame")
habitat.used.que <- join(moose.locs.xy.proj.df.que, quebec.sp)
habitat.used.2.que <- table(land.cover.classes[habitat.used.que+1, "Class_name"])
habitat.used.2.que
##
## Mixed Forest
## 38
## Sub-polar taiga needleleaf forest
## 8
## Temperate or sub-polar broadleaf deciduous
## 3
## Temperate or sub-polar needleleaf forest
## 47
## Temperate or sub-polar shrubland
## 3
## Wetland
## 1
habitat.ratios.que <- HSR(habitat.available.prop.que, habitat.used.que, "value")
habitat.ratios.que
## value count Class_name prop.available
## 1 1 190829 Temperate or sub-polar needleleaf forest 0.22034918
## 2 2 46127 Sub-polar taiga needleleaf forest 0.05326259
## 3 5 68934 Temperate or sub-polar broadleaf deciduous 0.07959770
## 4 6 169591 Mixed Forest 0.19582578
## 5 8 24025 Temperate or sub-polar shrubland 0.02774153
## 6 14 34688 Wetland 0.04005404
## prop.used selection.ratio
## 1 0.47 2.1329782
## 2 0.08 1.5019923
## 3 0.03 0.3768953
## 4 0.38 1.9405004
## 5 0.03 1.0814110
## 6 0.01 0.2496627
gouin <- raster("Gouin Land Cover.gri")
#sets our colours for the raster image
colours.gou <- c("darkgreen", "darkolivegreen", "chartreuse1", "green", "darkolivegreen1", "gold3", "darkseagreen", "darkseagreen3", "brown", "darkorange", "darkred", "deepskyblue4")
{#set margins
par(mar = c(4,4,1,7))
#first plot
plot(gouin, col = colours.gou, xlab = "Longitude (m)", ylab = "Latitude (m)",legend = FALSE)
#legend margin
par(xpd = NA)
# produce legend
legend(x=1750000, y = 2290000, legend = land.cover.classes[c(-1,-4,-5,-8,-10,-14,-17,-20),"Class_name"], fill = colours.gou, cex = 0.6)
}
## 8.2 Collar moose
probs.gou.day <- matrix(c(1,2,2,2,5,0.5,6,0.5,8,0.2,10,0.1,11,0,12,0,14,2,15,0,17,0,18,2), nrow = 12, ncol = 2, byrow = TRUE)
probs.gou.day.2 <- values(reclassify(gouin, probs.gou.day))
probs.gou.day.3 <- probs.gou.day.2/sum(probs.gou.day.2)
moose.locs.cells.gou.day <- sample(1:ncell(gouin), 100, prob = probs.gou.day.3)
moose.locs.xy.gou.day <- xyFromCell(gouin, moose.locs.cells.gou.day)
moose.locs.xy.proj.gou.day <- SpatialPoints(moose.locs.xy.gou.day, proj4string = CRS("+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"))
{par(mar = c(4,4,1,7))
plot(gouin, col = colours.gou, xlab = "Longitude (m)", ylab = "Latitude (m)",legend = FALSE)
par(xpd = NA)
legend(x=1750000, y = 2290000, legend = land.cover.classes[c(-1,-4,-5,-8,-10,-14,-17,-20),"Class_name"], fill = colours.gou, cex = 0.6)
plot(moose.locs.xy.proj.gou.day, add = TRUE, pch = 16)
}
## 8.3 Quantify available habitat
habitat.available.gou <- freq(gouin)
habitat.available.cmb.gou <- cbind(habitat.available.gou, land.cover.classes[c(-1,-4,-5,-8,-10,-14,-17,-20),]) [,-3]
habitat.available.prop.gou <- within(habitat.available.cmb.gou,{prop.available <- count/sum(count)})
habitat.available.prop.gou[,-1]
## count Class_name prop.available
## 2 13485 Temperate or sub-polar needleleaf forest 4.009693e-01
## 3 4 Sub-polar taiga needleleaf forest 1.189379e-04
## 6 3270 Temperate or sub-polar broadleaf deciduous 9.723172e-02
## 7 11797 Mixed Forest 3.507776e-01
## 9 1739 Temperate or sub-polar shrubland 5.170825e-02
## 11 166 Temperate or sub-polar grassland 4.935922e-03
## 12 42 Sub-polar or polar shrubland-lichen-moss 1.248848e-03
## 13 3 Sub-polar or polar grassland-lichen-moss 8.920341e-05
## 15 1059 Wetland 3.148880e-02
## 16 11 Cropland 3.270792e-04
## 18 2 Urban and Built-up 5.946894e-05
## 19 2053 Water 6.104487e-02
moose.locs.xy.proj.df.gou.day <- as(moose.locs.xy.proj.gou.day, "SpatialPointsDataFrame")
gouin.sp <- as(gouin, "SpatialPixelsDataFrame")
habitat.used.gou.day <- join(moose.locs.xy.proj.df.gou.day, gouin.sp)
habitat.used.2.gou.day <- table(land.cover.classes[habitat.used.gou.day+1, "Class_name"])
habitat.used.2.gou.day
##
## Mixed Forest
## 10
## Temperate or sub-polar broadleaf deciduous
## 5
## Temperate or sub-polar needleleaf forest
## 65
## Temperate or sub-polar shrubland
## 1
## Water
## 10
## Wetland
## 9
habitat.ratios.gou.day <- HSR(habitat.available.prop.gou, habitat.used.gou.day, "value")
habitat.ratios.gou.day
## value count Class_name prop.available
## 1 1 13485 Temperate or sub-polar needleleaf forest 0.40096934
## 2 5 3270 Temperate or sub-polar broadleaf deciduous 0.09723172
## 3 6 11797 Mixed Forest 0.35077756
## 4 8 1739 Temperate or sub-polar shrubland 0.05170825
## 5 14 1059 Wetland 0.03148880
## 6 18 2053 Water 0.06104487
## prop.used selection.ratio
## 1 0.65 1.6210716
## 2 0.05 0.5142355
## 3 0.10 0.2850810
## 4 0.01 0.1933928
## 5 0.09 2.8581586
## 6 0.10 1.6381393
probs.gou.nig <- matrix(c(1,0.5,2,0.5,5,2,6,2,8,2,10,2,11,0,12,0,14,0.5,15,0,17,0,18,0), nrow = 12, ncol = 2, byrow = TRUE)
probs.gou.nig.2 <- values(reclassify(gouin, probs.gou.nig))
probs.gou.nig.3 <- probs.gou.nig.2/sum(probs.gou.nig.2)
moose.locs.cells.gou.nig <- sample(1:ncell(gouin), 100, prob = probs.gou.nig.3)
moose.locs.xy.gou.nig <- xyFromCell(gouin, moose.locs.cells.gou.nig)
moose.locs.xy.proj.gou.nig <- SpatialPoints(moose.locs.xy.gou.nig, proj4string = CRS("+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"))
par(mar = c(4,4,1,7))
plot(gouin, col = colours.gou, xlab = "Longitude (m)", ylab = "Latitude (m)",legend = FALSE)
par(xpd = NA)
legend(x=1750000, y = 2290000, legend = land.cover.classes[c(-1,-4,-5,-8,-10,-14,-17,-20),"Class_name"], fill = colours.gou, cex = 0.6)
plot(moose.locs.xy.proj.gou.nig, add = TRUE, pch = 16)
#review
habitat.available.prop.gou[,-1]
## count Class_name prop.available
## 2 13485 Temperate or sub-polar needleleaf forest 4.009693e-01
## 3 4 Sub-polar taiga needleleaf forest 1.189379e-04
## 6 3270 Temperate or sub-polar broadleaf deciduous 9.723172e-02
## 7 11797 Mixed Forest 3.507776e-01
## 9 1739 Temperate or sub-polar shrubland 5.170825e-02
## 11 166 Temperate or sub-polar grassland 4.935922e-03
## 12 42 Sub-polar or polar shrubland-lichen-moss 1.248848e-03
## 13 3 Sub-polar or polar grassland-lichen-moss 8.920341e-05
## 15 1059 Wetland 3.148880e-02
## 16 11 Cropland 3.270792e-04
## 18 2 Urban and Built-up 5.946894e-05
## 19 2053 Water 6.104487e-02
moose.locs.xy.proj.df.gou.nig <- as(moose.locs.xy.proj.gou.nig, "SpatialPointsDataFrame")
gouin.sp <- as(gouin, "SpatialPixelsDataFrame")
habitat.used.gou.nig <- join(moose.locs.xy.proj.df.gou.nig, gouin.sp)
habitat.used.2.gou.nig <- table(land.cover.classes[habitat.used.gou.nig+1, "Class_name"])
habitat.used.2.gou.nig
##
## Mixed Forest
## 69
## Temperate or sub-polar broadleaf deciduous
## 11
## Temperate or sub-polar grassland
## 2
## Temperate or sub-polar needleleaf forest
## 10
## Temperate or sub-polar shrubland
## 7
## Wetland
## 1
habitat.ratios.gou.nig <- HSR(habitat.available.prop.gou, habitat.used.gou.nig, "value")
habitat.ratios.gou.nig
## value count Class_name prop.available
## 1 1 13485 Temperate or sub-polar needleleaf forest 0.400969344
## 2 5 3270 Temperate or sub-polar broadleaf deciduous 0.097231721
## 3 6 11797 Mixed Forest 0.350777556
## 4 8 1739 Temperate or sub-polar shrubland 0.051708245
## 5 10 166 Temperate or sub-polar grassland 0.004935922
## 6 14 1059 Wetland 0.031488805
## prop.used selection.ratio
## 1 0.10 0.2493956
## 2 0.11 1.1313180
## 3 0.69 1.9670586
## 4 0.07 1.3537493
## 5 0.02 4.0519277
## 6 0.01 0.3175732