Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create standAgeMaps by default from cohortData #77

Open
Tracked by #92
achubaty opened this issue Feb 22, 2023 · 1 comment
Open
Tracked by #92

create standAgeMaps by default from cohortData #77

achubaty opened this issue Feb 22, 2023 · 1 comment

Comments

@achubaty
Copy link
Collaborator

We've been producing these after-the-fact for downstream users, using code like the following:

## make annual standAgeMaps from cohortData
  lapply(2011:2100, function(year) {
    cohortData <- qs::qread(file = file.path(resultsDir, paste0("cohortData_", year, "_year", year, ".qs")))
    cohortData[, bWeightedAge := floor(sum(age * B) / sum(B) / 10) * 10, .(pixelGroup)]
    cohortDataReduced <- cohortData[, c("pixelGroup", "bWeightedAge")]
    cohortDataReduced <- unique(cohortDataReduced)
    pixelGroupMap <- raster(file.path(resultsDir, paste0("pixelGroupMap_", year, "_year", year, ".tif")))
    names(pixelGroupMap) <- "pixelGroup"
    standAgeMap <- rasterizeReduced(cohortDataReduced, pixelGroupMap, "bWeightedAge", mapCode = "pixelGroup")
    writeRaster(standAgeMap, filename = file.path(resultsDir, paste0("standAgeMap_", year, ".tif")), overwrite = TRUE)
    TRUE
  })

We should produce these during the simulation - possibly in this module, or in another Biomass_ module.

@achubaty
Copy link
Collaborator Author

standAgeMapGenerator() was added to LandR in v1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant