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

Update tpi calcs in landscape covariates to terra #6

Open
gcperk opened this issue Mar 6, 2023 · 0 comments
Open

Update tpi calcs in landscape covariates to terra #6

gcperk opened this issue Mar 6, 2023 · 0 comments

Comments

@gcperk
Copy link
Contributor

gcperk commented Mar 6, 2023

Landscape covar generation is based on spatial::eco rather than terra. Benchmarking tests show approx double the time required and should be updated to terra package. Initial testing indicated some work needs to be done to adjust the normalization factor :

    tic()
    tp <- spatialEco::tpi(dtm, scale=scale, win=win, normalize=TRUE)
    terra::writeRaster(tp, file.path(outpath, "tpi_se.tif"), overwrite = TRUE)
    toc()
    
    tic()
    sd <- focal(dtm, w = scale, fun = "sd", na.policy = "omit") 
    tpi <- terra::terrain(dtm, v = "TPI", neighbors=8)
    dev <- tpi/sd
    toc()
    terra::writeRaster(dev, file.path(outpath, "tpi_terra.tif"), overwrite = TRUE)

TPI 1) Spatial Eco
image

TPI 2) Terra
image

Thanks to Josh Evans (Ecora for suggested code improvements)

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