This function constructs an object of class "fgeo_elevation". It standardizes
the structure of elevation data to always output a dataframe with names gx
,
gy
and elev
.
fgeo_elevation(elev)
One of these:
A dataframe containing elevation data, with columns gx
, gy
, and
elev
, or x
, y
, and elev
(e.g. fgeo.x::elevation$col
).
A ForestGEO-like elevation list with elements xdim
and ydim
giving
plot dimensions, and element col
containing a dataframe as described in
the previous item (e.g. fgeo.x::elevation
).
A dataframe with names x/gx
, y/gy
and elev
.
This function was inspired by David Kenfack.
assert_is_installed("fgeo.x")
# Input: Elevation dataframe
elevation_df <- fgeo.x::elevation$col
fgeo_elevation(elevation_df)
#> # A tibble: 6,565 × 3
#> gx gy elev
#> * <int> <int> <dbl>
#> 1 0 0 364.
#> 2 0 5 364.
#> 3 0 10 363.
#> 4 0 15 363.
#> 5 0 20 363
#> 6 0 25 363.
#> 7 0 30 363.
#> 8 0 35 363.
#> 9 0 40 363.
#> 10 0 45 364.
#> # … with 6,555 more rows
class(elevation_df)
#> [1] "tbl_df" "tbl" "data.frame"
class(fgeo_elevation(elevation_df))
#> [1] "fgeo_elevation" "tbl_df" "tbl" "data.frame"
names(elevation_df)
#> [1] "x" "y" "elev"
names(fgeo_elevation(elevation_df))
#> [1] "gx" "gy" "elev"
# Input: Elevation list
elevation_ls <- fgeo.x::elevation
fgeo_elevation(elevation_ls)
#> # A tibble: 6,565 × 3
#> gx gy elev
#> * <int> <int> <dbl>
#> 1 0 0 364.
#> 2 0 5 364.
#> 3 0 10 363.
#> 4 0 15 363.
#> 5 0 20 363
#> 6 0 25 363.
#> 7 0 30 363.
#> 8 0 35 363.
#> 9 0 40 363.
#> 10 0 45 364.
#> # … with 6,555 more rows
class(elevation_ls)
#> [1] "list"
class(fgeo_elevation(elevation_ls))
#> [1] "fgeo_elevation" "tbl_df" "tbl" "data.frame"
names(elevation_ls)
#> [1] "col" "mat" "xdim" "ydim"
names(fgeo_elevation(elevation_ls))
#> [1] "gx" "gy" "elev"