diff --git a/Boreal_LBMRDataPrep.R b/Boreal_LBMRDataPrep.R index a106c77..c943c31 100644 --- a/Boreal_LBMRDataPrep.R +++ b/Boreal_LBMRDataPrep.R @@ -50,7 +50,7 @@ defineModule(sim, list( expectsInput("seedingAlgorithm", "character", desc = "choose which seeding algorithm will be used among noDispersal, universalDispersal, and wardDispersal, default is wardDispersal"), - expectsInput("shpStudySubRegion", "SpatialPolygonsDataFrame", + expectsInput("shpStudyArea", "SpatialPolygonsDataFrame", desc = "this shape file contains two informaton: Sub study area with fire return interval attribute", sourceURL = NA), # i guess this is study area and fire return interval expectsInput("shpStudyRegionFull", "SpatialPolygonsDataFrame", @@ -416,17 +416,17 @@ Save <- function(sim) { sim$shpStudyRegionFull <- SpaDES.tools::randomPolygon(x = polyCenter, hectares = 10000) } - if (!suppliedElsewhere("shpStudySubRegion", sim)) { - message("'shpStudySubRegion' was not provided by user. Using the same as 'shpStudyRegionFull'") - sim$shpStudySubRegion <- sim$shpStudyRegionFull + if (!suppliedElsewhere("shpStudyArea", sim)) { + message("'shpStudyArea' was not provided by user. Using the same as 'shpStudyRegionFull'") + sim$shpStudyArea <- sim$shpStudyRegionFull } if (!identical(crsUsed, crs(sim$shpStudyRegionFull))) { sim$shpStudyRegionFull <- spTransform(sim$shpStudyRegionFull, crsUsed) #faster without Cache } - if (!identical(crsUsed, crs(sim$shpStudySubRegion))) { - sim$shpStudySubRegion <- spTransform(sim$shpStudySubRegion, crsUsed) #faster without Cache + if (!identical(crsUsed, crs(sim$shpStudyArea))) { + sim$shpStudyArea <- spTransform(sim$shpStudyArea, crsUsed) #faster without Cache } cacheTags = c(currentModule(sim), "function:.inputObjects", "function:spades") @@ -438,7 +438,7 @@ Save <- function(sim) { "NFI_MODIS250m_kNN_Structure_Biomass_TotalLiveAboveGround_v0.zip")), url = extractURL("biomassMap"), destinationPath = dPath, - studyArea = sim$shpStudySubRegion, + studyArea = sim$shpStudyArea, useSAcrs = TRUE, method = "bilinear", datatype = "INT2U", @@ -453,7 +453,7 @@ Save <- function(sim) { archive = asPath("LandCoverOfCanada2005_V1_4.zip"), url = extractURL("LCC2005"), destinationPath = dPath, - studyArea = sim$shpStudySubRegion, + studyArea = sim$shpStudyArea, rasterToMatch = sim$biomassMap, method = "bilinear", datatype = "INT2U", diff --git a/Boreal_LBMRDataPrep.Rmd b/Boreal_LBMRDataPrep.Rmd index fbdc60c..68ff1ba 100644 --- a/Boreal_LBMRDataPrep.Rmd +++ b/Boreal_LBMRDataPrep.Rmd @@ -95,7 +95,7 @@ Plot(shpStudyAreaLarge, addTo = "canadaMap", col = "red") times <- list(start = 0, end = 10) modules <- list("Boreal_LBMRDataPrep") objects <- if (handDrawMap) list("shpStudyAreaLarge" = shpStudyAreaLarge, - "shpStudySubRegion" = shpStudyAreaLarge) else list() + "shpStudyArea" = shpStudyAreaLarge) else list() mySim <- simInit(times = times, params = parameters, modules = modules, objects = objects) diff --git a/R/helpers.R b/R/helpers.R index d9b10f7..b5763b8 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -29,4 +29,4 @@ fasterizeFromSp <- function(sp, raster, fieldName) { fasterize::fasterize(tempSf, raster) } else fasterize::fasterize(tempSf, raster, field = fieldName) -} \ No newline at end of file +}