GithubHelp home page GithubHelp logo

Comments (5)

rhijmans avatar rhijmans commented on August 11, 2024 1

This change in "raster" fixes that. I still need to see if that breaks some other package. You can also work around it by assuring that the raster data have a crs. And since the next version of landscapemetrics won't use raster anymore, the problem should also disappear for that reason alone.

from raster.

rhijmans avatar rhijmans commented on August 11, 2024

I cannot reproduce this. Can you make sure you are using the current version of R and the "landscapemetrics" and "terra" packages? Both print messages when you load them, but you do not show them (you should include them when showing your code), like this:

library(landscapemetrics)
#Starting from v2.0.0, landscapemetrics does not support the 'raster' or 'sp' packages.
#    They are replaced by 'terra' and 'sf', respectively. More information
#    about the 'terra' package can be found here: https://rspatial.org/index.html.
library(terra)
#terra 1.7.32

Also, what is your operating system? What is your version of GDAL?

gdal()
#[1] "3.6.2"

from raster.

jszhao avatar jszhao commented on August 11, 2024

I am running R on Windows 11.

> library(landscapemetrics)
Starting from v2.0.0, landscapemetrics does not support the 'raster' or 'sp' packages.
    They are replaced by 'terra' and 'sf', respectively. More information
    about the 'terra' package can be found here: https://rspatial.org/index.html.
> library(terra)
terra 1.7.29
> gdal()
[1] "3.6.2"

I have located the problem. The following code could reproduce the problem in R console:

library(landscapemetrics)
library(terra)

# The following line cause the problem. Maybe I should report it to landscapemetrics package.
options_landscapemetrics(to_disk = TRUE)

r <- rast(landscape)
z <- spatialize_lsm(r, what = c("lsm_p_area", "lsm_p_circle"))
zz <- rast(lapply(z$layer_1, rast))
plot(zz)
writeRaster(zz, filename = "lsm.tif", overwrite = TRUE)

from raster.

jszhao avatar jszhao commented on August 11, 2024

The problem is that when set options_landscapemetrics(to_disk = TRUE), landscapemetrics write the layer z$layer_1$lsm_p_area to a temp file with extension .grd/.gri, and rast does not recognize it. That seems a format recognized by raster package.

from raster.

jszhao avatar jszhao commented on August 11, 2024

Thanks a lot. I have installed the latest version of raster from github. It fixes the problem.

from raster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.