In this example, we use the rgbif package to search for occurrence (lat/long) data for 1000 species
Install and load rgbif
install.packages("rgbif")
library("rgbif")| #################################### | |
| # Run zonal statistics in parallel # | |
| #################################### | |
| # Clear workspace | |
| rm(list=ls()) | |
| # Libraries | |
| library(raster) | |
| library(gstat) |
| ######################################## | |
| #### Getting started #### | |
| ######################################## | |
| # Make a place holder for the cs_run.exe path | |
| CS_exe <- 'C:/"Program Files"/Circuitscape/cs_run.exe' # Don't forget the "Program Files" problem | |
| # We want to run one of the CS examples found in /examples/, first we need to fix the .ini file | |
| # We first read in the .ini file and then we change the arguments | |
| Example_lines <- readLines("C:/Program Files/Circuitscape/examples/eight_neighbor_example.ini") |
| library(mvtnorm) # to draw multivariate normal outcomes | |
| library(R2jags) # JAGS-R interface | |
| # function that makes distance matrix for a side*side 2D array | |
| dist.matrix <- function(side) | |
| { | |
| row.coords <- rep(1:side, times=side) | |
| col.coords <- rep(1:side, each=side) | |
| row.col <- data.frame(row.coords, col.coords) | |
| D <- dist(row.col, method="euclidean", diag=TRUE, upper=TRUE) |
| #import relevant packages | |
| library(gstat) | |
| library(sp) | |
| library(nlme) | |
| #create simulated data, lat and lon from uniformly distributed variable, exp1 and exp2 from random normal | |
| set.seed(2) | |
| samp.sz<-400 | |
| lat<-runif(samp.sz,-4,4) | |
| lon<-runif(samp.sz,-4,4) |