r-spatialecology/landscapemetrics

save show_x as a raster file

Closed this issue · 7 comments

Hello,
I was wondering if there is a way to save the results of the show_x function, for example show_cores, as a georeferenced tif raster file?

Thanks!

Hey,

Have a look at get_patches(), I think that is what you are looking for...

Thank you,
Well, That will let me save it as a raster, but it only shows me the patches> However, if I want to save as a georeferenced tiff file the same result I get from "show_cores", i.e, the core area of the patches, how could I implement that with get_patches?

Oh, I missed that you are only interested in the core areas. In this case, you can combine get_patches() to get all patches of a certain class and then get_boundaries() to label edge and core cells.

Alternatively, spatialize_lsm() might be interesting for you.

library(landscapemetrics)
library(raster)

# get patches of all classes
lsm_classes <- get_patches(landscape = landscape)

# core and boundary cells of e.g., class 1
core_cls_1 <- get_boundaries(lsm_classes$layer_1$class_1)[[1]]

# plot
plot(core_cls_1, col = c("white", "blue"), colNA = "grey")

Created on 2022-11-29 with reprex v2.0.2

Thank you very much!
Any idea of how I could do a similar thing for "show_lsm" using what="lsm_p_area"?

Thats what spatialize_lsm() is for

Great! Thank you!

Please re-open if you have further questions but will close for now.