Comments (5)
Hey,
Thanks for finding this. I think the argument does not get passed on properly. I will try to fix this
from landscapemetrics.
Okay, should be fixed in c5336d1
library(terra)
library(landscapemetrics)
#Create a 10 by 10 raster in which all cells are 1
r = rast(ncol=10, nrow=10)
values(r) = 1
#Randomly assign some of the values to NA
set.seed(123) # For reproducibility
na_matrix = matrix(runif(100) < 0.8, nrow=10, ncol=10)
# Apply NA values to the raster based on the NA matrix
values(r)[na_matrix] = NA
#Assign crs
crs(r) = "EPSG:32633"
# show landscape patch ids
show_patches(landscape = r, class = 1, directions = 4, labels = TRUE)
#> $layer_1
# calculate the area
area_df <- lsm_p_area(landscape = r, directions = 4)
# get raster layer with values
area_ras <- spatialize_lsm(r, what = "lsm_p_area", directions = 4)
# those should be identical and four unique values
unique(area_df$value)
#> [1] 0.2592 0.1296 0.0648 0.1944
unique(area_ras$layer_1$lsm_p_area[])
#> value
#> [1,] NA
#> [2,] 0.1296
#> [3,] 0.0648
#> [4,] 0.2592
#> [5,] 0.1944
# this seems to be correct now
plot(area_ras$layer_1$lsm_p_area, col = viridis::viridis(n = 4, option = "E"))
# compare to function by the package
show_lsm(landscape = r, what = "lsm_p_area", class = 1, directions = 4, labels = TRUE)
#> $layer_1
Created on 2024-02-29 with reprex v2.1.0
Could you please try to install the Github version and see if results are correct now.
from landscapemetrics.
Great, thank you! It's on my list to try the updated version and report back
from landscapemetrics.
I installed the Github version and re-ran my code from above and it now works as expected. Thanks for solving that so quickly!
from landscapemetrics.
Cool 👍 Will close this, please re-open if needed
from landscapemetrics.
Related Issues (20)
- Patch labeling inconsistencies between version 1.3 and 1.5.7 HOT 4
- shape index unexpected behaviour HOT 17
- lsm_l_frac Range HOT 2
- IIASA 2023 work HOT 7
- Issues with FRAGSTATS comparison HOT 1
- Add test landscape with internal NA
- Receive 'length' error when using sample_lsm with polygons HOT 5
- Delete branches HOT 2
- Error in sample_lsm code HOT 10
- Reminder to update CRAN
- Difficulty with the "calculate_lsm" function in the package HOT 2
- calculate_lsm error HOT 4
- Issue in setting y argument for sample_lsm function HOT 1
- Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double' HOT 3
- sample_lsm Issue HOT 4
- sample_lsm percentage_inside issue HOT 6
- Labels for show_patches HOT 1
- 🐛 Issue with patch id in get_centroids
- r studio list_ism issue HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from landscapemetrics.