Comments (10)
Actually all possible options (level
, metric
, type
, what
, ...) needs to be NULL
. Definitely worth to mention. I will update the documentation next week.
from landscapemetrics.
Oh...we forgot to adapt sample_lsm()
to the new structure how metrics are selected (basically list_lsm()
). However, list_lsm()
doesn't has the option what = "all"
anymore, but all metrics are selected if nothing is specified at all. Do we want to bring back the "all" option?
Anyways, should work now (ddfa819)
library(landscapemetrics)
data("landscape")
points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE)
points_sp <- sp::SpatialPoints(points)
sample_lsm(landscape,
points = points_sp,
size = 15)
from landscapemetrics.
Thanks @mhesselbarth.
Bringing back the all option is not necessary, but it would be nice to add info that what = NULL means all metrics are calculated...
from landscapemetrics.
One more question:
sample_lsm()
with return_plots = TRUE
gives a tibble with two list columns - one for the landscape summary and one with new rasters. Why is that? Shouldn't it be just the same output as the first one, but with one additional column for rasters?
library(landscapemetrics)
points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE)
sample_lsm(landscape, points = points, size = 15, what = "lsm_l_np")
#> # A tibble: 3 x 8
#> layer plot_id level class id metric value percentage_inside
#> <int> <int> <chr> <int> <int> <chr> <dbl> <dbl>
#> 1 1 1 landscape NA NA np 8 80.
#> 2 1 2 landscape NA NA np 7 74.7
#> 3 1 3 landscape NA NA np 7 64.
sample_lsm(landscape, points = points, size = 15, what = "lsm_l_np", return_plots = TRUE)
#> # A tibble: 3 x 4
#> layer plot_id metrics raster_sample_plots
#> <int> <int> <list> <list>
#> 1 1 1 <tibble [1 × 8]> <S4: RasterLayer>
#> 2 1 2 <tibble [1 × 8]> <S4: RasterLayer>
#> 3 1 3 <tibble [1 × 8]> <S4: RasterLayer>
Created on 2019-01-19 by the reprex package (v0.2.1)
from landscapemetrics.
(Btw, the name return_plots
could be confusing - I assume it would give some kind of figure as an output. How about using return_rasters
instead?)
from landscapemetrics.
Sounds good!
from landscapemetrics.
Done (11df79e)
from landscapemetrics.
One more question:
sample_lsm()
withreturn_plots = TRUE
gives a tibble with two list columns - one for the landscape summary and one with new rasters. Why is that? Shouldn't it be just the same output as the first one, but with one additional column for rasters?library(landscapemetrics) points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE) sample_lsm(landscape, points = points, size = 15, what = "lsm_l_np") #> # A tibble: 3 x 8 #> layer plot_id level class id metric value percentage_inside #> <int> <int> <chr> <int> <int> <chr> <dbl> <dbl> #> 1 1 1 landscape NA NA np 8 80. #> 2 1 2 landscape NA NA np 7 74.7 #> 3 1 3 landscape NA NA np 7 64. sample_lsm(landscape, points = points, size = 15, what = "lsm_l_np", return_plots = TRUE) #> # A tibble: 3 x 4 #> layer plot_id metrics raster_sample_plots #> <int> <int> <list> <list> #> 1 1 1 <tibble [1 × 8]> <S4: RasterLayer> #> 2 1 2 <tibble [1 × 8]> <S4: RasterLayer> #> 3 1 3 <tibble [1 × 8]> <S4: RasterLayer>Created on 2019-01-19 by the reprex package (v0.2.1)
@mhesselbarth @marcosci and what do you think about that?
from landscapemetrics.
The reason why we nested the tibble
was that I thought it becomes quite tricky if you select e.g. a patch-level metric and a class-level metric. In this case, you don't know the number of rows the resulting tibble
has because that depends on the number of patches and classes in each sample plot.
But actually, using the plot_id
this is straightforward. So IMHO, we could just return the tibble
with an extra row (see 9630236; @marcosci please revert if you don't like that).
from landscapemetrics.
Please reopen if someone is not happy with the solution
> points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE)
> sample_lsm(landscape, points = points, size = 15, what = c("lsm_c_ca", "lsm_l_np"), return_raster = TRUE)
# A tibble: 12 x 9
layer plot_id level class id metric value percentage_inside raster_sample_plots
<int> <int> <chr> <int> <int> <chr> <dbl> <dbl> <list>
1 1 1 class 1 NA ca 0.0044 80. <S4: RasterLayer>
2 1 1 class 2 NA ca 0.0051 80. <S4: RasterLayer>
3 1 1 class 3 NA ca 0.0085 80. <S4: RasterLayer>
4 1 1 landscape NA NA np 8 80. <S4: RasterLayer>
5 1 2 class 1 NA ca 0.0016 74.7 <S4: RasterLayer>
6 1 2 class 2 NA ca 0.0054 74.7 <S4: RasterLayer>
7 1 2 class 3 NA ca 0.0098 74.7 <S4: RasterLayer>
8 1 2 landscape NA NA np 7 74.7 <S4: RasterLayer>
9 1 3 class 1 NA ca 0.0006 64. <S4: RasterLayer>
10 1 3 class 2 NA ca 0.0038 64. <S4: RasterLayer>
11 1 3 class 3 NA ca 0.01 64. <S4: RasterLayer>
12 1 3 landscape NA NA np 7 64. <S4: RasterLayer>
from landscapemetrics.
Related Issues (20)
- ..
- Basic package benchmarks
- Dependencies HOT 9
- comparing_tools.Rmd HOT 8
- Adding cell-level aggregation metrics
- sample_lsm help example generates error package conflicts? HOT 2
- Calculating enn_mn between 2 classes instead of 1 HOT 1
- print version of landscapemetrics HOT 4
- options_landscapemetrics(TRUE) causes warnings... HOT 6
- Difference to new FRAGSTATS version HOT 7
- Update show_* functions HOT 1
- Color scale show_correlation
- error with raster-dev HOT 5
- Setting focal class i HOT 1
- 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
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.