##set up site-pair table using the southwest data set
sppData <- southwest[, c(1,2,14,13)]
envTab <- southwest[, c(2:ncol(southwest))]
# remove soils (no rasters for these)
envTab <- envTab[,-c(2:6)]
sitePairTab <- formatsitepair(sppData, 2, XColumn="Long", YColumn="Lat", sppColumn="species",
siteColumn="site", predData=envTab)
# create GDM
gdmMod <- gdm(sitePairTab, geo=TRUE)
##predict GDM
predDiss <- predict(gdmMod, sitePairTab)
##time example
rastFile <- system.file("./extdata/swBioclims.grd", package="gdm")
envRast <- terra::rast(rastFile)
##make some fake climate change data
futRasts <- envRast
##reduce winter precipitation by 25%
futRasts[[3]] <- futRasts[[3]]*0.75
timePred <- predict(gdmMod, envRast, time=TRUE, predRasts=futRasts)
terra::plot(timePred)
Run the code above in your browser using DataLab