==1762623== Memcheck, a memory error detector
==1762623== Copyright (C) 2002-2026, and GNU GPL'd, by Julian Seward et al.
==1762623== Using Valgrind-3.27.1 and LibVEX; rerun with -h for copyright info
==1762623== Command: /data/localhost/ripley/R/R-devel-vg/bin/exec/R --vanilla
==1762623==
R Under development (unstable) (2026-09-28 r90591) -- "Unsuffered Consequences"
Copyright (C) 2026 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> pkgname <- "ICESat2VegR"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> library('ICESat2VegR')
--1762623-- Warning: zero subprog, missing DW_AT_abstract_origin in DW_TAG_inlined_subroutine in /data/localhost/ripley/.cache/debuginfod_client/4d5d043a0523276e24ea966c0d032c14524e1947/debuginfo
##----------------------------------------------------------------##
## ICESat2VegR package, version 0.0.3, Released 2026-09-28 13:30:02 UTC #
##----------------------------------------------------------------##
This package is developed by Carlos A. Silva (c.silva@ufl.edu),
Caio Hamamura (caiohamamura@gmail.com),
Cesar Alvites (c.alvitesdiaz@ufl.edu) and
Alexander J. Gaskins (alexandergaskins@ufl.edu) from the Forest Biometrics
Remote Sensing and AI Lab (SilvaLab) at the University of Florida.
ICESat2VegR is based upon work supported by NASA's Ice, Cloud, and
Land Elevation Satellite (ICESat2), Carbon Monitoring System (CMS),
and Commercial Smallsat Data Scientific Analysis (CSDSA) under
grants No. 80NSSC23K0941, 80NSSC23K1257, and 80NSSC24K0055.
Have a fantastic day filled with positivity and productivity! :)
##----------------------------------------------------------------##
Attaching package: ‘ICESat2VegR’
The following object is masked from ‘package:graphics’:
clip
The following object is masked from ‘package:base’:
sample
>
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("ATL03_ATL08_compute_seg_attributes_dt_segStat")
> ### * ATL03_ATL08_compute_seg_attributes_dt_segStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_compute_seg_attributes_dt_segStat
> ### Title: Statistics of ATL03 and ATL08 labeled photons at the segment
> ### level
> ### Aliases: ATL03_ATL08_compute_seg_attributes_dt_segStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying ATL03 and ATL08 file path
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 labeled photons
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ # Computing the max canopy height at 30 m segments
+ atl03_atl08_dt_seg <- ATL03_ATL08_segment_create(atl03_atl08_dt, segment_length = 30)
+
+ max_canopy <- ATL03_ATL08_compute_seg_attributes_dt_segStat(atl03_atl08_dt_seg,
+ list_expr = max(ph_h),
+ ph_class = c(2, 3),
+ beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"),
+ quality_ph = 0,
+ night_flag = 0
+ )
+
+ head(max_canopy)
+
+ # Computing a series of canopy height statistics from customized list expressions
+ canopy_metrics <- ATL03_ATL08_compute_seg_attributes_dt_segStat(atl03_atl08_dt_seg,
+ list_expr = list(
+ max_ph_elevation = max(h_ph),
+ h_canopy = quantile(ph_h, 0.98),
+ n_canopy = sum(classed_pc_flag == 2),
+ n_top_canopy = sum(classed_pc_flag == 3)
+ ),
+ ph_class = c(2, 3),
+ beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"),
+ quality_ph = 0,
+ night_flag = 0 # there are no night photons in this dataset
+ )
+
+ head(canopy_metrics)
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_LAS")
> ### * ATL03_ATL08_photons_attributes_dt_LAS
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_LAS
> ### Title: Export Merged ICESat-2 ATL03/ATL08 Photon Data to LAS Files
> ### Aliases: ATL03_ATL08_photons_attributes_dt_LAS
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ outdir <- tempdir()
+
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(
+ atl03_h5,
+ atl08_h5
+ )
+
+ ATL03_ATL08_photons_attributes_dt_LAS(
+ atl03_atl08_dt,
+ output = file.path(outdir, "output.las"),
+ normalized = TRUE
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
====================================================
The provided data will be split into 1 UTM zone(s)
====================================================
EPSG: 32613, saved as /tmp/RtmpjpK0Fz/output_32613.las
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_clipBox")
> ### * ATL03_ATL08_photons_attributes_dt_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_clipBox
> ### Title: Clip joined ATL03 and ATL08 photons by bounding extent
> ### Aliases: ATL03_ATL08_photons_attributes_dt_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR")
+
+ atl08_path <- system.file("extdata", "atl08_clip.h5",
+ package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Joining ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # 1) Using a numeric bounding box: xmin ymin xmax ymax
+ bbox <- c(-106.571, 41.531, -106.569, 41.540)
+
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = bbox
+ )
+ head(atl03_atl08_dt_clip)
+
+ # 2) Using a SpatExtent (example)
+ ext <- terra::ext(-106.57, -106.569, 41.531, 41.540)
+ atl03_atl08_dt_clip_ext <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = ext
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_clipGeometry")
> ### * ATL03_ATL08_photons_attributes_dt_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_clipGeometry
> ### Title: Clip Joined ATL03 and ATL08 by Geometry
> ### Aliases: ATL03_ATL08_photons_attributes_dt_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path)
+
+ # Joining ATL03 and ATL08 photon attributes
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # Specifying the path to the shapefile
+ clip_obj_filepath <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR")
+
+ # Reading shapefile as a SpatVector object
+ clip_obj <- terra::vect(clip_obj_filepath)
+
+ # Clipping ATL08 terrain attributes by geometry
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipGeometry(
+ atl03_atl08_dt,
+ clip_obj,
+ split_by = "id"
+ )
+ head(atl03_atl08_dt_clip)
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_gridStat")
> ### * ATL03_ATL08_photons_attributes_dt_gridStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_gridStat
> ### Title: Statistics of ATL03 and ATL08 photon attributes
> ### Aliases: ATL03_ATL08_photons_attributes_dt_gridStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # ATL03 file path
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # ATL08 file path
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ # Computing the mean of ph_h attribute at 0.0002 degree grid cell
+ mean_ph_h <- ATL03_ATL08_photons_attributes_dt_gridStat(atl03_atl08_dt,
+ func = mean(ph_h),
+ res = 0.0002
+ )
+
+ plot(mean_ph_h)
+
+ # Define your own function
+ mySetOfMetrics <- function(x) {
+ metrics <- list(
+ min = min(x), # Min of x
+ max = max(x), # Max of x
+ mean = mean(x), # Mean of x
+ sd = sd(x) # Sd of x
+ )
+ return(metrics)
+
+ # Computing a series of ph_h stats at 0.0002 degree grid cell from customized function
+ ph_h_metrics <- ATL03_ATL08_photons_attributes_dt_gridStat(atl03_atl08_dt,
+ func = mySetOfMetrics(ph_h), res = 0.0002
+ )
+
+ plot(ph_h_metrics)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_join")
> ### * ATL03_ATL08_photons_attributes_dt_join
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_join
> ### Title: Join ATL03 and ATL08 photons attributes
> ### Aliases: ATL03_ATL08_photons_attributes_dt_join
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 file
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_attributes_dt_polyStat")
> ### * ATL03_ATL08_photons_attributes_dt_polyStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_attributes_dt_polyStat
> ### Title: Statistics of ATL03 and ATL08 joined photons attributes within a
> ### given area
> ### Aliases: ATL03_ATL08_photons_attributes_dt_polyStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ # ATL03 file path
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # ATL08 file path
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # Specifying the path to shapefile
+ polygon_filepath <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR")
+
+ # Reading shapefile as sf object
+ polygon <- terra::vect(polygon_filepath)
+
+ # Clipping ATL08 terrain attributes by Geometry
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipGeometry(atl03_atl08_dt,
+ polygon, split_by = "id")
+
+ # Computing the maximum ph_h by polygon id
+ max_ph_h <- ATL03_ATL08_photons_attributes_dt_polyStat(atl03_atl08_dt_clip,
+ func = max(ph_h), poly_id = "poly_id")
+ head(max_ph_h)
+
+ # Define your own function
+ mySetOfMetrics <- function(x) {
+ metrics <- list(
+ min = min(x), # Min of x
+ max = max(x), # Max of x
+ mean = mean(x), # Mean of x
+ sd = sd(x) # Sd of x
+ )
+ return(metrics)
+
+ # Computing a series of ph_h statistics from customized function
+ ph_h_metrics <- ATL03_ATL08_photons_attributes_dt_polyStat(
+ atl03_atl08_dt_clip,
+ func = mySetOfMetrics(ph_h),
+ poly_id = "poly_id"
+ )
+
+ head(ph_h_metrics)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_seg_dt_fitground")
> ### * ATL03_ATL08_photons_seg_dt_fitground
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_seg_dt_fitground
> ### Title: Fit and estimate ground elevation for photons or arbitrary
> ### distances from the track beginning
> ### Aliases: ATL03_ATL08_photons_seg_dt_fitground
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ # Converting to seg_dt class (required input for fitground)
+ atl03_atl08_seg_dt <- ATL03_ATL08_segment_create(
+ atl03_atl08_dt,
+ segment_length = 30
+ )
+
+ # Example 1: ATBD adaptive smoothing window + linear interpolation
+ # at each photon location along the track.
+ # Returns a list with $x (dist_ph_along) and $y (ground elevation in meters).
+ # NAs appear at photon locations outside the smoothed ground range.
+ ground_approx <- ATL03_ATL08_photons_seg_dt_fitground(
+ atl03_atl08_seg_dt,
+ interpolation_func = approx,
+ xout_parameter_name = "xout"
+ )
+ head(ground_approx$x) # photon distances along track (meters)
+ head(ground_approx$y) # interpolated ground elevations (meters)
+
+ # Example 2: Return an interpolation function (approxfun) for
+ # querying ground elevation at arbitrary distances along the track.
+ # xout_parameter_name = NA skips prediction at photon locations
+ # and returns the interpolation function directly.
+ ground_fun <- ATL03_ATL08_photons_seg_dt_fitground(
+ atl03_atl08_seg_dt,
+ interpolation_func = approxfun,
+ xout_parameter_name = NA
+ )
+ # Query ground elevation at custom distances along track (meters)
+ ground_fun(c(100, 200, 300))
+
+ # Example 3: Fixed 5 m smoothing window using mean instead of median
+ ground_mean <- ATL03_ATL08_photons_seg_dt_fitground(
+ atl03_atl08_seg_dt,
+ smoothing_window = 5,
+ smoothing_func = mean,
+ interpolation_func = approx,
+ xout_parameter_name = "xout"
+ )
+ head(ground_mean$y)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_photons_seg_dt_height_normalize")
> ### * ATL03_ATL08_photons_seg_dt_height_normalize
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_photons_seg_dt_height_normalize
> ### Title: Normalize photon heights relative to estimated ground elevation
> ### Aliases: ATL03_ATL08_photons_seg_dt_height_normalize
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ # Converting to seg_dt class (required input)
+ atl03_atl08_seg_dt <- ATL03_ATL08_segment_create(
+ atl03_atl08_dt,
+ segment_length = 30
+ )
+
+ # Example 1: Normalize photon heights using default ATBD smoothing window
+ atl03_atl08_seg_dt_norm <- ATL03_ATL08_photons_seg_dt_height_normalize(
+ atl03_atl08_seg_dt,
+ interpolation_func = approx,
+ xout_parameter_name = "xout"
+ )
+ head(atl03_atl08_seg_dt_norm)
+
+ # Example 2: Fixed 5 m smoothing window using mean aggregation
+ # Recreate seg_dt since ph_h was modified in place by the previous call
+ atl03_atl08_seg_dt <- ATL03_ATL08_segment_create(
+ atl03_atl08_dt,
+ segment_length = 30
+ )
+ atl03_atl08_seg_dt_norm2 <- ATL03_ATL08_photons_seg_dt_height_normalize(
+ atl03_atl08_seg_dt,
+ smoothing_window = 5,
+ smoothing_func = mean,
+ interpolation_func = approx,
+ xout_parameter_name = "xout"
+ )
+ head(atl03_atl08_seg_dt_norm2)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_seg_attributes_dt_clipBox")
> ### * ATL03_ATL08_seg_attributes_dt_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_seg_attributes_dt_clipBox
> ### Title: Clip joined ATL03/ATL08 segment attributes by bounding extent
> ### Aliases: ATL03_ATL08_seg_attributes_dt_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08 segment attributes
+ atl08_seg_dt <- ATL08_seg_attributes_dt(atl08_h5)
+ head(atl08_seg_dt)
+
+ # Example 1: Clip using a numeric bounding box (xmin, ymin, xmax, ymax)
+ bbox <- c(-106.571, 41.532, -106.570, 41.537)
+ atl08_seg_clip <- ATL03_ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_dt,
+ clip_obj = bbox
+ )
+ head(atl08_seg_clip)
+ nrow(atl08_seg_clip)
+
+ # Example 2: Clip using a terra SpatExtent object
+ library(terra)
+ ext_obj <- terra::ext(bbox)
+ atl08_seg_clip2 <- ATL03_ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_dt,
+ clip_obj = ext_obj
+ )
+ head(atl08_seg_clip2)
+ nrow(atl08_seg_clip2)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
terra 1.9.50
Attaching package: ‘terra’
The following object is masked from ‘package:ICESat2VegR’:
extract
>
>
>
> cleanEx()
detaching ‘package:terra’
> nameEx("ATL03_ATL08_seg_attributes_dt_clipGeometry")
> ### * ATL03_ATL08_seg_attributes_dt_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_seg_attributes_dt_clipGeometry
> ### Title: Clip joined ATL03/ATL08 segment attributes by geometry
> ### Aliases: ATL03_ATL08_seg_attributes_dt_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08 segment attributes
+ atl08_seg_dt <- ATL08_seg_attributes_dt(atl08_h5)
+ head(atl08_seg_dt)
+
+ # Reading polygon from shapefile
+ polygon_filepath <- system.file("extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+ polygon <- terra::vect(polygon_filepath)
+
+ # Example 1: Clip by polygon geometry
+ atl08_seg_clip_geom <- ATL03_ATL08_seg_attributes_dt_clipGeometry(
+ atl08_seg_dt,
+ clip_obj = polygon
+ )
+ head(atl08_seg_clip_geom)
+ nrow(atl08_seg_clip_geom)
+
+ # Example 2: Clip by polygon geometry and add polygon id column
+ atl08_seg_clip_geom2 <- ATL03_ATL08_seg_attributes_dt_clipGeometry(
+ atl08_seg_dt,
+ clip_obj = polygon,
+ split_by = "id"
+ )
+ head(atl08_seg_clip_geom2)
+ nrow(atl08_seg_clip_geom2)
+
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_seg_cover_dt_compute")
> ### * ATL03_ATL08_seg_cover_dt_compute
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_seg_cover_dt_compute
> ### Title: Compute canopy cover from ATL03/ATL08 classified photons
> ### Aliases: ATL03_ATL08_seg_cover_dt_compute
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ # Converting to seg_dt class (required input)
+ atl03_atl08_seg_dt <- ATL03_ATL08_segment_create(
+ atl03_atl08_dt,
+ segment_length = 30
+ )
+
+ # Computing canopy cover metrics per segment
+ cover <- ATL03_ATL08_seg_cover_dt_compute(atl03_atl08_seg_dt)
+ head(cover[, c("segment_id", "cover", "n_g", "n_v")])
+
+ # Computing cover with a custom reflectance ratio (rho_v/rho_g = 1.5)
+ cover2 <- ATL03_ATL08_seg_cover_dt_compute(
+ atl03_atl08_seg_dt,
+ reflectance_ratio = 1.5
+ )
+ head(cover2[, c("segment_id", "cover", "n_g", "n_v")])
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_ATL08_segment_create")
> ### * ATL03_ATL08_segment_create
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_ATL08_segment_create
> ### Title: Compute segments id for a given segment length
> ### Aliases: ATL03_ATL08_segment_create
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ICESat-2 ATL03 and ATL08 data
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ICESat-2 ATL08 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ atl03_atl08_dt_seg <- ATL03_ATL08_segment_create(atl03_atl08_dt,
+ segment_length = 30,
+ centroid = "mean",
+ output = NA,
+ overwrite = FALSE
+ )
+
+ head(atl03_atl08_dt_seg)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_h5_clipBox")
> ### * ATL03_h5_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_h5_clipBox
> ### Title: Clip ICESat-2 ATL03 HDF5 Data Using a Bounding Extent
> ### Aliases: ATL03_h5_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("ATL03_h5_clipGeometry")
> ### * ATL03_h5_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_h5_clipGeometry
> ### Title: Clip ICESat-2 ATL03 HDF5 Data Using Geometry-Based Boundaries
> ### Aliases: ATL03_h5_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("ATL03_photons_attributes_dt")
> ### * ATL03_photons_attributes_dt
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_photons_attributes_dt
> ### Title: ATL03 photon attributes
> ### Aliases: ATL03_photons_attributes_dt
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file(
+ "extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path)
+
+ atl03_photons_dt <- ATL03_photons_attributes_dt(
+ atl03_h5,
+ beam = c("gt1r"),
+ attributes = c("quality_ph", "dist_ph_along", "ph_id_count")
+ )
+ head(atl03_photons_dt)
+
+ close(atl03_h5)
+
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_photons_attributes_dt_LAS")
> ### * ATL03_photons_attributes_dt_LAS
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_photons_attributes_dt_LAS
> ### Title: Export ICESat-2 ATL03 Photon Data to LAS Files
> ### Aliases: ATL03_photons_attributes_dt_LAS
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ atl03_dt <- ATL03_photons_attributes_dt(atl03_h5, beam = "gt1r")
+
+ outdir <- tempdir()
+
+ ATL03_photons_attributes_dt_LAS(
+ atl03_dt,
+ file.path(outdir, "atl03_photons.las")
+ )
+
+ close(atl03_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
====================================================
The provided data will be split into 1 UTM zone(s)
====================================================
EPSG: 32613, saved as /tmp/RtmpjpK0Fz/atl03_photons_32613.las
>
>
>
> cleanEx()
> nameEx("ATL03_photons_attributes_dt_clipBox")
> ### * ATL03_photons_attributes_dt_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_photons_attributes_dt_clipBox
> ### Title: Clip ATL03 photons by bounding extent
> ### Aliases: ATL03_photons_attributes_dt_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR")
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5)
+
+ # 1) Using a numeric bbox: xmin ymin xmax ymax
+ bbox <- c(-106.57, 41.53, -106.5698, 41.54)
+ atl03_clip_bbox <- ATL03_photons_attributes_dt_clipBox(
+ atl03_photons_dt = atl03_photons_dt,
+ clip_obj = bbox
+ )
+
+ # 2) Using a SpatExtent
+ # library(terra)
+ # ext <- terra::ext(-106.57, -106.5698, 41.53, 41.54)
+ # atl03_clip_ext <- ATL03_photons_attributes_dt_clipBox(
+ # atl03_photons_dt = atl03_photons_dt,
+ # clip_obj = ext
+ # )
+
+ close(atl03_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_photons_attributes_dt_clipGeometry")
> ### * ATL03_photons_attributes_dt_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_photons_attributes_dt_clipGeometry
> ### Title: Clip ATL03 photons by Coordinates
> ### Aliases: ATL03_photons_attributes_dt_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # ATL03 file path
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Extracting ATL03 photon attributes
+ atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5)
+
+ # Specifying the path to shapefile
+ clip_obj_filepath <-
+ system.file(
+ "extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ # Reading shapefile as sf object
+ clip_obj <- terra::vect(clip_obj_filepath)
+
+ # Clipping ATL03 photon attributes by Geometry
+ atl03_photons_dt_clip <-
+ ATL03_photons_attributes_dt_clipGeometry(atl03_photons_dt, clip_obj, split_by = "id")
+
+ head(atl03_photons_dt_clip)
+
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL03_read")
> ### * ATL03_read
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_read
> ### Title: Read ICESat-2 ATL03 data
> ### Aliases: ATL03_read
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specify the path to an ATL03 file
+ atl03_path <- system.file(
+ "extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Read ICESat-2 ATL03 data (HDF5 file)
+ ATL03 <- ATL03_read(atl03_path = atl03_path)
+ close(ATL03)
+
+ }
>
>
>
> cleanEx()
> nameEx("ATL03_seg_metadata_dt")
> ### * ATL03_seg_metadata_dt
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL03_seg_metadata_dt
> ### Title: ATL03 geolocation segment metadata
> ### Aliases: ATL03_seg_metadata_dt
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file(
+ "extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path)
+
+ # Extract ATL03 geolocation segment metadata
+ atl03_segment_dt <- ATL03_seg_metadata_dt(atl03_h5)
+
+ head(atl03_segment_dt)
+ close(atl03_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL08_h5_clipBox")
> ### * ATL08_h5_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_h5_clipBox
> ### Title: Clip ICESat-2 ATL08 HDF5 Data Using a Bounding Extent
> ### Aliases: ATL08_h5_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("ATL08_h5_clipGeometry")
> ### * ATL08_h5_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_h5_clipGeometry
> ### Title: Clips ICESat-2 ATL08 data
> ### Aliases: ATL08_h5_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # ATL08 file path
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ output <- tempfile(fileext = ".h5")
+
+ vect_path <- system.file("extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ clip_obj <- terra::vect(vect_path)
+
+ # Clipping ATL08 photons by boundary box extent
+ atl08_photons_dt_clip <- ATL08_h5_clipGeometry(
+ atl08_h5,
+ output,
+ clip_obj,
+ split_by = "id"
+ )
+
+ close(atl08_h5)
+ }
Clipping gt1r (1/1)
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|================== | 26%
|
|============================= | 41%
|
|======================================= | 56%
|
|================================================= | 70%
|
|============================================================ | 85%
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("ATL08_photons_attributes_dt")
> ### * ATL08_photons_attributes_dt
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_photons_attributes_dt
> ### Title: ATL08 computed photons attributes
> ### Aliases: ATL08_photons_attributes_dt
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path)
+
+ # Extracting ATL08 classified photons and heights
+ atl08_photons <- ATL08_photons_attributes_dt(atl08_h5 = atl08_h5)
+
+ head(atl08_photons)
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL08_photons_attributes_dt_LAS")
> ### * ATL08_photons_attributes_dt_LAS
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_photons_attributes_dt_LAS
> ### Title: Export ICESat-2 ATL08 photon attributes to LAS files
> ### Aliases: ATL08_photons_attributes_dt_LAS
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # ATL08 photon attributes alone have no geolocation; join with ATL03 first
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ atl08_photons <- data.table::data.table(
+ longitude = atl03_atl08_dt$lon_ph,
+ latitude = atl03_atl08_dt$lat_ph,
+ ph_h = atl03_atl08_dt$ph_h
+ )
+
+ ATL08_photons_attributes_dt_LAS(
+ atl08_dt = atl08_photons,
+ output = tempfile(fileext = ".las")
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
====================================================
The provided data will be split into 1 UTM zone(s)
====================================================
EPSG: 32613, saved as /tmp/RtmpjpK0Fz/file1ae53f4333cd58_32613.las
>
>
>
> cleanEx()
> nameEx("ATL08_read-character-method")
> ### * ATL08_read-character-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_read,character-method
> ### Title: Read ICESat-2 ATL08 data from a local HDF5 file
> ### Aliases: ATL08_read,character-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specify the path to an example ATL08 file
+ atl08_path <- system.file(
+ "extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Read ICESat-2 ATL08 data (HDF5 file)
+ atl08 <- ATL08_read(atl08_path = atl08_path)
+ close(atl08)
+
+ }
>
>
>
> cleanEx()
> nameEx("ATL08_read")
> ### * ATL08_read
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_read
> ### Title: Read ICESat-2 ATL08 data
> ### Aliases: ATL08_read
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specify the path to an example ATL08 file
+ atl08_path <- system.file(
+ "extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Read ICESat-2 ATL08 data (HDF5 file)
+ atl08 <- ATL08_read(atl08_path = atl08_path)
+ close(atl08)
+
+ }
>
>
>
> cleanEx()
> nameEx("ATL08_seg_attributes_dt")
> ### * ATL08_seg_attributes_dt
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt
> ### Title: ATL08 Terrain and Canopy Attributes
> ### Aliases: ATL08_seg_attributes_dt
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08-derived terrain and canopy attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+ head(atl08_seg_att_dt)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL08_seg_attributes_dt_LAS")
> ### * ATL08_seg_attributes_dt_LAS
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt_LAS
> ### Title: Export ICESat-2 ATL08 Segment Data to LAS Files
> ### Aliases: ATL08_seg_attributes_dt_LAS
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ outputLas <- tempfile(fileext = ".las")
+
+ ATL08_seg_attributes_dt_LAS(
+ atl08_dt,
+ outputLas
+ )
+
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
====================================================
The provided data will be split into 1 UTM zone(s)
====================================================
EPSG: 32613, saved as /tmp/RtmpjpK0Fz/file1ae53f620a0a4a_32613.las
>
>
>
> cleanEx()
> nameEx("ATL08_seg_attributes_dt_clipBox")
> ### * ATL08_seg_attributes_dt_clipBox
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt_clipBox
> ### Title: Clip ATL08 terrain and canopy attributes by bounding extent
> ### Aliases: ATL08_seg_attributes_dt_clipBox
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to the ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path)
+
+ # Extracting ATL08-derived segment attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ # 1) Using a numeric bounding box: xmin ymin xmax ymax
+ bbox <- c(-103.7604, 59.4672, -103.7600, 59.4680)
+
+ atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_att_dt = atl08_seg_att_dt,
+ clip_obj = bbox
+ )
+
+ # 2) Using a SpatExtent
+ ext <- terra::ext(-103.7604, -103.7600, 59.4672, 59.4680)
+ atl08_seg_att_dt_clip_ext <- ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_att_dt = atl08_seg_att_dt,
+ clip_obj = ext
+ )
+
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL08_seg_attributes_dt_clipGeometry")
> ### * ATL08_seg_attributes_dt_clipGeometry
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt_clipGeometry
> ### Title: Clip ATL08 Terrain and Canopy Attributes by Geometry
> ### Aliases: ATL08_seg_attributes_dt_clipGeometry
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08-derived terrain and canopy attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ clip_obj_path <- system.file("extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ if (require(terra)) {
+ polygon <- terra::vect(clip_obj_path)
+
+ head(atl08_seg_att_dt)
+ # Clipping ATL08 Terrain and Canopy Attributes by Geometry
+ atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipGeometry(
+ atl08_seg_att_dt,
+ polygon,
+ split_by = "id"
+ )
+
+ hasLeaflet <- require(leaflet)
+
+ if (hasLeaflet) {
+ leaflet() %>%
+ addCircleMarkers(atl08_seg_att_dt_clip$longitude,
+ atl08_seg_att_dt_clip$latitude,
+ radius = 1,
+ opacity = 1,
+ color = "red"
+ ) %>%
+ addScaleBar(options = list(imperial = FALSE)) %>%
+ addPolygons(
+ data = polygon, weight = 1, col = "white",
+ opacity = 1, fillOpacity = 0
+ ) %>%
+ addProviderTiles(providers$Esri.WorldImagery,
+ options = providerTileOptions(minZoom = 3, maxZoom = 17)
+ )
+ }
+ close(atl08_h5)
+ }
+
+ }
|
| | 0%
|
|======================================================================| 100%
Loading required package: terra
terra 1.9.50
Attaching package: ‘terra’
The following object is masked from ‘package:ICESat2VegR’:
extract
Loading required package: leaflet
>
>
>
> cleanEx()
detaching ‘package:leaflet’, ‘package:terra’
> nameEx("ATL08_seg_attributes_dt_gridStat")
> ### * ATL08_seg_attributes_dt_gridStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt_gridStat
> ### Title: Statistics of ATL08 terrain and canopy attributes at grid level
> ### Aliases: ATL08_seg_attributes_dt_gridStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08-derived terrain and canopy attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ # Computing mean h_canopy at 0.0001 degree grid cell
+ library(terra)
+ mean_h_canopy <- ATL08_seg_attributes_dt_gridStat(
+ atl08_seg_att_dt,
+ func = mean(h_canopy),
+ res = 0.0001
+ )
+ terra::plot(mean_h_canopy)
+
+ # Define a custom set of metrics
+ mySetOfMetrics <- function(x) {
+ metrics <- list(
+ min = min(x, na.rm = TRUE),
+ max = max(x, na.rm = TRUE),
+ mean = mean(x, na.rm = TRUE),
+ sd = sd(x, na.rm = TRUE)
+ )
+ return(metrics)
+
+ # Computing h_canopy statistics at 0.05 degree grid cell
+ h_canopy_metrics <- ATL08_seg_attributes_dt_gridStat(
+ atl08_seg_att_dt,
+ func = mySetOfMetrics(h_canopy),
+ res = 0.05
+ )
+ terra::plot(h_canopy_metrics)
+
+ close(atl08_h5)
+ }
+ }
|
| | 0%
|
|======================================================================| 100%
terra 1.9.50
Attaching package: ‘terra’
The following object is masked from ‘package:ICESat2VegR’:
extract
>
>
>
> cleanEx()
detaching ‘package:terra’
> nameEx("ATL08_seg_attributes_dt_polyStat")
> ### * ATL08_seg_attributes_dt_polyStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_dt_polyStat
> ### Title: Statistics of ATL08 Terrain and Canopy Attributes by Geometry
> ### Aliases: ATL08_seg_attributes_dt_polyStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file(
+ "extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08 terrain and canopy attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ # Specifying the path to shapefile
+ polygon_filepath <- system.file(
+ "extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ # Reading shapefile as sf object
+ polygon <- terra::vect(polygon_filepath)
+
+ # Clipping ATL08 terrain and canopy attributes by Geometry
+ atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipGeometry(
+ atl08_seg_att_dt,
+ polygon,
+ split_by = "id"
+ )
+
+ # Computing the max h_canopy by polygon id
+ max_h_canopy <- ATL08_seg_attributes_dt_polyStat(
+ atl08_seg_att_dt_clip,
+ func = max(h_canopy),
+ poly_id = "poly_id"
+ )
+ head(max_h_canopy)
+
+ # Define your own function
+ mySetOfMetrics <- function(x) {
+ metrics <- list(
+ min = min(x), # Min of x
+ max = max(x), # Max of x
+ mean = mean(x), # Mean of x
+ sd = sd(x) # Sd of x
+ )
+ return(metrics)
+ }
+
+ # Computing a series of canopy statistics from customized function
+ h_canopy_metrics <- ATL08_seg_attributes_dt_polyStat(
+ atl08_seg_att_dt_clip,
+ func = mySetOfMetrics(h_canopy),
+ poly_id = "poly_id"
+ )
+
+ head(h_canopy_metrics)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("ATL08_seg_attributes_h5_gridStat")
> ### * ATL08_seg_attributes_h5_gridStat
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATL08_seg_attributes_h5_gridStat
> ### Title: Rasterize ATL08 canopy attributes from h5 files at large scale
> ### Aliases: ATL08_seg_attributes_h5_gridStat
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("ATLAS_dataDownload")
> ### * ATLAS_dataDownload
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATLAS_dataDownload
> ### Title: Download ICESat-2 ATL03/ATL08 data
> ### Aliases: ATLAS_dataDownload
>
> ### ** Examples
>
> ## Not run:
> ##D urls <- c(
> ##D "https://example.com/path/to/ATL03_001.h5",
> ##D "https://example.com/path/to/ATL08_001.h5"
> ##D )
> ##D status <- ATLAS_dataDownload(urls,
> ##D outdir = "data",
> ##D retries = 5,
> ##D backoff = 2)
> ##D subset(status, status == "failed")
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("ATLAS_dataFinder")
> ### * ATLAS_dataFinder
>
> flush(stderr()); flush(stdout())
>
> ### Name: ATLAS_dataFinder
> ### Title: ICESat-2 ATL03 and ATL08 data finder for either direct download
> ### or cloud computing
> ### Aliases: ATLAS_dataFinder
>
> ### ** Examples
>
> # ICESat-2 data finder is a web service provided by NASA
> # usually the request takes more than 5 seconds
>
> # Specifying bounding box coordinates
> lower_left_lon <- -96.0
> lower_left_lat <- 40.0
> upper_right_lon <- -96.5
> upper_right_lat <- 40.5
>
> # Specifying the date range
> daterange <- c("2022-05-01", "2022-05-02")
>
> # Extracting the path to ICESat-2 ATLAS data for the specified boundary box coordinates
> # for data download
>
> # Shouldn't be tested because it relies on a web service which might be down
>
> ## Not run:
> ##D ATLAS02b_list <- ATLAS_dataFinder(
> ##D short_name = "ATL08",
> ##D lower_left_lon,
> ##D lower_left_lat,
> ##D upper_right_lon,
> ##D upper_right_lat,
> ##D version = "007",
> ##D daterange = daterange
> ##D )
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("GDALOpen")
> ### * GDALOpen
>
> flush(stderr()); flush(stdout())
>
> ### Name: GDALOpen
> ### Title: Open GDAL raster
> ### Aliases: GDALOpen
>
> ### ** Examples
>
> # Create a small raster to open
> ds_path <- tempfile(fileext = ".tif")
> ds <- createDataset(
+ raster_path = ds_path,
+ nbands = 1,
+ datatype = GDALDataType$GDT_Int32,
+ projstring = "EPSG:4326",
+ ul_lat = -15, ul_lon = -45, lr_lat = -25, lr_lon = -35,
+ res = c(0.01, -0.01),
+ nodata = -1
+ )
> ds$Close()
>
> # Reopen the raster read-only
> ds2 <- GDALOpen(ds_path)
> ds2$Close()
>
>
>
> cleanEx()
> nameEx("ICESat2VegR_configure")
> ### * ICESat2VegR_configure
>
> flush(stderr()); flush(stdout())
>
> ### Name: ICESat2VegR_configure
> ### Title: Configure Python environment for ICESat2VegR cloud features
> ### Aliases: ICESat2VegR_configure
>
> ### ** Examples
>
> ## Not run:
> ##D # Basic configuration using defaults
> ##D ICESat2VegR_configure()
> ##D
> ##D # Use existing conda env named "icesat2"
> ##D ICESat2VegR_configure(envname = "icesat2")
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("addEEImage")
> ### * addEEImage
>
> flush(stderr()); flush(stdout())
>
> ### Name: addEEImage
> ### Title: Add an Earth Engine Image to a leaflet map
> ### Aliases: addEEImage
>
> ### ** Examples
>
> ## Not run:
> ##D # Initialize Earth Engine (use your own project id)
> ##D Sys.setenv(EE_PROJECT = "your-ee-project-id")
> ##D ee_initialize()
> ##D
> ##D # Harmonized Landsat-Sentinel (HLS) surface reflectance collection
> ##D collection_id <- "NASA/HLS/HLSL30/v002"
> ##D ee_collection <- ee$ImageCollection(collection_id)
> ##D
> ##D # Mask cloud, cloud-shadow and adjacent-cloud pixels (Fmask bits 1-3)
> ##D cloudMask <- 2^1 + 2^2 + 2^3
> ##D hlsMask <- function(image) {
> ##D image$updateMask(!(image[["Fmask"]] & cloudMask))
> ##D }
> ##D
> ##D # Cloud-free median composite over two summer seasons
> ##D image <- c(
> ##D ee_collection$filterDate("2020-04-01", "2020-07-31")$map(hlsMask),
> ##D ee_collection$filterDate("2021-04-01", "2021-07-31")$map(hlsMask)
> ##D )$filter("CLOUD_COVERAGE < 30")$median()
> ##D
> ##D # Show the RGB composite (bands 3-2-1) on an interactive map
> ##D if (require("leaflet")) {
> ##D leaflet() %>%
> ##D addEEImage(
> ##D image,
> ##D bands = c(3, 2, 1),
> ##D min_value = 0.001,
> ##D max_value = 0.2
> ##D ) %>%
> ##D setView(lng = -82.2345, lat = 29.6552, zoom = 10)
> ##D }
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("aspect")
> ### * aspect
>
> flush(stderr()); flush(stdout())
>
> ### Name: aspect
> ### Title: Compute terrain aspect (degrees) from a DEM image
> ### Aliases: aspect
>
> ### ** Examples
>
> ## Not run:
> ##D ee <- reticulate::import("ee")
> ##D dem <- ee$Image("NASA/NASADEM_HGT/001")
> ##D asp <- aspect(dem)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_dt-ANY-method")
> ### * clip-icesat2.atl03_dt-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_dt,ANY-method
> ### Title: Clip ATL03 photons by Coordinates
> ### Aliases: clip,icesat2.atl03_dt,ANY-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # ATL03 file path
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Extracting ATL03 photon attributes
+ atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5)
+
+ # Specifying the path to shapefile
+ clip_obj_filepath <-
+ system.file(
+ "extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ # Reading shapefile as sf object
+ clip_obj <- terra::vect(clip_obj_filepath)
+
+ # Clipping ATL03 photon attributes by Geometry
+ atl03_photons_dt_clip <-
+ ATL03_photons_attributes_dt_clipGeometry(atl03_photons_dt, clip_obj, split_by = "id")
+
+ head(atl03_photons_dt_clip)
+
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_dt-SpatExtent-method")
> ### * clip-icesat2.atl03_dt-SpatExtent-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_dt,SpatExtent-method
> ### Title: Clip ATL03 photons by bounding extent
> ### Aliases: clip,icesat2.atl03_dt,SpatExtent-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5)
+
+ # 1) Using a numeric bbox: xmin ymin xmax ymax
+ bbox <- c(-106.57, 41.53, -106.5698, 41.54)
+ atl03_clip_bbox <- ATL03_photons_attributes_dt_clipBox(
+ atl03_photons_dt = atl03_photons_dt,
+ clip_obj = bbox
+ )
+
+ # 2) Using a SpatExtent
+ ext <- terra::ext(-106.57, -106.5698, 41.53, 41.54)
+ atl03_clip_ext <- ATL03_photons_attributes_dt_clipBox(
+ atl03_photons_dt = atl03_photons_dt,
+ clip_obj = ext
+ )
+
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_dt-numeric-method")
> ### * clip-icesat2.atl03_dt-numeric-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_dt,numeric-method
> ### Title: Clip ATL03 photons by bounding extent
> ### Aliases: clip,icesat2.atl03_dt,numeric-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5)
+
+ # 1) Using a numeric bbox: xmin ymin xmax ymax
+ bbox <- c(-106.57, 41.53, -106.5698, 41.54)
+ atl03_clip_bbox <- ATL03_photons_attributes_dt_clipBox(
+ atl03_photons_dt = atl03_photons_dt,
+ clip_obj = bbox
+ )
+
+ # 2) Using a SpatExtent
+ ext <- terra::ext(-106.57, -106.5698, 41.53, 41.54)
+ atl03_clip_ext <- ATL03_photons_attributes_dt_clipBox(
+ atl03_photons_dt = atl03_photons_dt,
+ clip_obj = ext
+ )
+
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_h5-ANY-method")
> ### * clip-icesat2.atl03_h5-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_h5,ANY-method
> ### Title: Clip ICESat-2 ATL03 HDF5 Data Using Geometry-Based Boundaries
> ### Aliases: clip,icesat2.atl03_h5,ANY-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_h5-SpatExtent-method")
> ### * clip-icesat2.atl03_h5-SpatExtent-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_h5,SpatExtent-method
> ### Title: Clip ICESat-2 ATL03 HDF5 Data Using a Bounding Extent
> ### Aliases: clip,icesat2.atl03_h5,SpatExtent-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03_h5-numeric-method")
> ### * clip-icesat2.atl03_h5-numeric-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03_h5,numeric-method
> ### Title: Clip ICESat-2 ATL03 HDF5 Data Using a Bounding Extent
> ### Aliases: clip,icesat2.atl03_h5,numeric-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03atl08_dt-ANY-method")
> ### * clip-icesat2.atl03atl08_dt-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03atl08_dt,ANY-method
> ### Title: Clip Joined ATL03 and ATL08 by Geometry
> ### Aliases: clip,icesat2.atl03atl08_dt,ANY-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path)
+
+ # Joining ATL03 and ATL08 photon attributes
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # Specifying the path to the shapefile
+ clip_obj_filepath <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR")
+
+ # Reading shapefile as a SpatVector object
+ clip_obj <- terra::vect(clip_obj_filepath)
+
+ # Clipping ATL08 terrain attributes by geometry
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipGeometry(
+ atl03_atl08_dt,
+ clip_obj,
+ split_by = "id"
+ )
+ head(atl03_atl08_dt_clip)
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03atl08_dt-SpatExtent-method")
> ### * clip-icesat2.atl03atl08_dt-SpatExtent-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03atl08_dt,SpatExtent-method
> ### Title: Clip joined ATL03 and ATL08 photons by bounding extent
> ### Aliases: clip,icesat2.atl03atl08_dt,SpatExtent-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl08_path <- system.file("extdata", "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Joining ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # 1) Using a numeric bounding box: xmin ymin xmax ymax
+ bbox <- c(-103.7604, 59.4672, -103.7600, 59.4680)
+
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = bbox
+ )
+ head(atl03_atl08_dt_clip)
+
+ # 2) Using a SpatExtent (example)
+ ext <- terra::ext(-103.7604, -103.7600, 59.4672, 59.4680)
+ atl03_atl08_dt_clip_ext <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = ext
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl03atl08_dt-numeric-method")
> ### * clip-icesat2.atl03atl08_dt-numeric-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl03atl08_dt,numeric-method
> ### Title: Clip joined ATL03 and ATL08 photons by bounding extent
> ### Aliases: clip,icesat2.atl03atl08_dt,numeric-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 and ATL08 files
+ atl03_path <- system.file("extdata", "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl08_path <- system.file("extdata", "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 and ATL08 data (h5 files)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Joining ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+ head(atl03_atl08_dt)
+
+ # 1) Using a numeric bounding box: xmin ymin xmax ymax
+ bbox <- c(-103.7604, 59.4672, -103.7600, 59.4680)
+
+ atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = bbox
+ )
+ head(atl03_atl08_dt_clip)
+
+ # 2) Using a SpatExtent (example)
+ ext <- terra::ext(-103.7604, -103.7600, 59.4672, 59.4680)
+ atl03_atl08_dt_clip_ext <- ATL03_ATL08_photons_attributes_dt_clipBox(
+ atl03_atl08_dt = atl03_atl08_dt,
+ clip_obj = ext
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl08_dt-ANY-method")
> ### * clip-icesat2.atl08_dt-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl08_dt,ANY-method
> ### Title: Clip ATL08 Terrain and Canopy Attributes by Geometry
> ### Aliases: clip,icesat2.atl08_dt,ANY-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL08-derived terrain and canopy attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ clip_obj_path <- system.file("extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+
+ if (require(terra)) {
+ polygon <- terra::vect(clip_obj_path)
+
+ head(atl08_seg_att_dt)
+ # Clipping ATL08 Terrain and Canopy Attributes by Geometry
+ atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipGeometry(atl08_seg_att_dt,
+ polygon,
+ split_by = "id"
+ )
+
+ hasLeaflet <- require(leaflet)
+
+ if (hasLeaflet) {
+ leaflet() %>%
+ addCircleMarkers(atl08_seg_att_dt_clip$longitude,
+ atl08_seg_att_dt_clip$latitude,
+ radius = 1,
+ opacity = 1,
+ color = "red"
+ ) %>%
+ addScaleBar(options = list(imperial = FALSE)) %>%
+ addPolygons(
+ data = polygon, weight = 1, col = "white",
+ opacity = 1, fillOpacity = 0
+ ) %>%
+ addProviderTiles(providers$Esri.WorldImagery,
+ options = providerTileOptions(minZoom = 3, maxZoom = 17)
+ )
+ }
+ }
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
Loading required package: terra
terra 1.9.50
Attaching package: ‘terra’
The following object is masked from ‘package:ICESat2VegR’:
extract
Loading required package: leaflet
>
>
>
> cleanEx()
detaching ‘package:leaflet’, ‘package:terra’
> nameEx("clip-icesat2.atl08_dt-numeric-method")
> ### * clip-icesat2.atl08_dt-numeric-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl08_dt,numeric-method
> ### Title: Clip ATL08 terrain and canopy attributes by bounding extent
> ### Aliases: clip,icesat2.atl08_dt,numeric-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to the ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path)
+
+ # Extracting ATL08-derived segment attributes
+ atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5)
+
+ # 1) Using a numeric bounding box: xmin ymin xmax ymax
+ bbox <- c(-103.7604, 59.4672, -103.7600, 59.4680)
+
+ atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_att_dt = atl08_seg_att_dt,
+ clip_obj = bbox
+ )
+
+ # 2) Using a SpatExtent
+ ext <- terra::ext(-103.7604, -103.7600, 59.4672, 59.4680)
+ atl08_seg_att_dt_clip_ext <- ATL08_seg_attributes_dt_clipBox(
+ atl08_seg_att_dt = atl08_seg_att_dt,
+ clip_obj = ext
+ )
+
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl08_h5-ANY-method")
> ### * clip-icesat2.atl08_h5-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl08_h5,ANY-method
> ### Title: Clips ICESat-2 ATL08 data
> ### Aliases: clip,icesat2.atl08_h5,ANY-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl08_h5-SpatExtent-method")
> ### * clip-icesat2.atl08_h5-SpatExtent-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl08_h5,SpatExtent-method
> ### Title: Clip ICESat-2 ATL08 HDF5 Data Using a Bounding Extent
> ### Aliases: clip,icesat2.atl08_h5,SpatExtent-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+
+ }
NULL
>
>
>
> cleanEx()
> nameEx("clip-icesat2.atl08_h5-numeric-method")
> ### * clip-icesat2.atl08_h5-numeric-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: clip,icesat2.atl08_h5,numeric-method
> ### Title: Clip ICESat-2 ATL08 HDF5 Data Using a Bounding Extent
> ### Aliases: clip,icesat2.atl08_h5,numeric-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+
+ }
NULL
>
>
>
> cleanEx()
> nameEx("createDataset")
> ### * createDataset
>
> flush(stderr()); flush(stdout())
>
> ### Name: createDataset
> ### Title: Creates a new GDALDataset
> ### Aliases: createDataset
>
> ### ** Examples
>
> # Parameters
> raster_path <- tempfile(fileext = ".tif")
> ul_lat <- -15
> ul_lon <- -45
> lr_lat <- -25
> lr_lon <- -35
> res <- c(0.01, -0.01)
> datatype <- GDALDataType$GDT_Int32
> nbands <- 1
> projstring <- "EPSG:4326"
> nodata <- -1
> co <- c("TILED=YES", "BLOCKXSIZE=512", "BLOCKYSIZE=512", "COMPRESSION=LZW")
>
> # Create a new raster dataset
> ds <- createDataset(
+ raster_path = raster_path,
+ nbands = nbands,
+ datatype = datatype,
+ projstring = projstring,
+ lr_lat = lr_lat,
+ ul_lat = ul_lat,
+ ul_lon = ul_lon,
+ lr_lon = lr_lon,
+ res = res,
+ nodata = nodata,
+ co = co
+ )
>
> # Get the GDALRasterBand for ds
> band <- ds[[1]]
>
> # Set some dummy values
> band[[0, 0]] <- 1:(512 * 512)
>
> ds$Close()
>
>
>
> cleanEx()
> nameEx("dot-as_ee_geom")
> ### * dot-as_ee_geom
>
> flush(stderr()); flush(stdout())
>
> ### Name: .as_ee_geom
> ### Title: Convert R geometry objects to an Earth Engine geometry
> ### Aliases: .as_ee_geom
>
> ### ** Examples
>
> ## Not run:
> ##D ee <- reticulate::import("ee", delay_load = FALSE)
> ##D
> ##D # 1) From sf polygon
> ##D library(sf)
> ##D poly <- st_as_sfc(st_bbox(c(
> ##D xmin = -82.4, xmax = -82.2,
> ##D ymin = 29.6, ymax = 29.8
> ##D ), crs = 4326))
> ##D
> ##D ee_geom1 <- .as_ee_geom(poly)
> ##D
> ##D
> ##D # 2) From terra::SpatVector
> ##D library(terra)
> ##D v <- vect(system.file("extdata", "clip_geom.shp", package = "ICESat2VegR"))
> ##D ee_geom2 <- .as_ee_geom(v, buffer_m = 30)
> ##D
> ##D
> ##D # 3) From numeric extent (xmin, ymin, xmax, ymax)
> ##D bbox_vec <- c(-82.4, 29.6, -82.2, 29.8)
> ##D ee_geom3 <- .as_ee_geom(bbox_vec)
> ##D
> ##D
> ##D # 4) From data.frame of points
> ##D df <- data.frame(
> ##D lon = c(-82.3, -82.25),
> ##D lat = c(29.65, 29.7)
> ##D )
> ##D ee_geom4 <- .as_ee_geom(df, buffer_m = 1000)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("dot-ee_ping")
> ### * dot-ee_ping
>
> flush(stderr()); flush(stdout())
>
> ### Name: .ee_ping
> ### Title: Check if Google Earth Engine is initialized
> ### Aliases: .ee_ping
>
> ### ** Examples
>
> ## Not run:
> ##D library(reticulate)
> ##D ee <- import("ee", delay_load = FALSE)
> ##D
> ##D # Will error if EE is not authenticated/initialized
> ##D .ee_ping(ee)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("dt_to_las")
> ### * dt_to_las
>
> flush(stderr()); flush(stdout())
>
> ### Name: dt_to_las
> ### Title: Convert ICESat-2 ATL03 and ATL08 data.table objects to LAS files
> ### Aliases: dt_to_las
>
> ### ** Examples
>
> library(data.table)
Attaching package: ‘data.table’
The following object is masked from ‘package:base’:
%notin%
>
> dt <- data.table(
+ lon = runif(1000, -52.5, -52.4),
+ lat = runif(1000, -15.9, -15.8),
+ h = runif(1000, 0, 35)
+ )
>
> dt_to_las(dt, tempfile(fileext = ".las"))
====================================================
The provided data will be split into 1 UTM zone(s)
====================================================
EPSG: 32722, saved as /tmp/RtmpjpK0Fz/file1ae53f1af996df_32722.las
>
>
>
>
> cleanEx()
detaching ‘package:data.table’
> nameEx("ee_build_AlphaEarth_embedding_terrain_stack")
> ### * ee_build_AlphaEarth_embedding_terrain_stack
>
> flush(stderr()); flush(stdout())
>
> ### Name: ee_build_AlphaEarth_embedding_terrain_stack
> ### Title: Stack Alpha Earth embedding and terrain ancillary layers
> ### Aliases: ee_build_AlphaEarth_embedding_terrain_stack
>
> ### ** Examples
>
> ## Not run:
> ##D # Requires Google Earth Engine authentication
> ##D # Note: USGS 3DEP terrain data covers the United States only.
> ##D # Outside the US, NASADEM is used as a global fallback.
> ##D Sys.setenv(EE_PROJECT = "your-ee-project-id")
> ##D ICESat2VegR::ee_initialize()
> ##D
> ##D library(sf)
> ##D aoi <- st_as_sfc(st_bbox(c(
> ##D xmin = -82.4, xmax = -82.2,
> ##D ymin = 29.6, ymax = 29.8
> ##D ), crs = 4326))
> ##D
> ##D ee_geom <- ICESat2VegR::.as_ee_geom(aoi)
> ##D
> ##D # Build the embedding + terrain stack for 2025
> ##D predictors <- ee_build_AlphaEarth_embedding_terrain_stack(
> ##D geom = ee_geom,
> ##D start_year = 2025,
> ##D end_year = 2025
> ##D )
> ##D
> ##D # Visualize RGB embedding bands using leaflet
> ##D predictors_rgb <- predictors$select(c("A00", "A20", "A40"))
> ##D
> ##D centroid_lon <- mean(terra::ext(terra::vect(aoi))[c(1, 2)])
> ##D centroid_lat <- mean(terra::ext(terra::vect(aoi))[c(3, 4)])
> ##D
> ##D leaflet::leaflet() |>
> ##D ICESat2VegR::addEEImage(
> ##D predictors_rgb,
> ##D bands = c("A00", "A20", "A40"),
> ##D group = "RGB Embedding",
> ##D min = -0.2,
> ##D max = 0.2
> ##D ) |>
> ##D leaflet::setView(
> ##D lng = centroid_lon,
> ##D lat = centroid_lat,
> ##D zoom = 15
> ##D ) |>
> ##D leaflet::addLayersControl(
> ##D overlayGroups = "RGB Embedding",
> ##D options = leaflet::layersControlOptions(collapsed = FALSE)
> ##D )
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("ee_build_hls_s1c_terrain_stack")
> ### * ee_build_hls_s1c_terrain_stack
>
> flush(stderr()); flush(stdout())
>
> ### Name: ee_build_hls_s1c_terrain_stack
> ### Title: Build HLS, Sentinel-1C and terrain ancillary stack in Earth
> ### Engine
> ### Aliases: ee_build_hls_s1c_terrain_stack
>
> ### ** Examples
>
> ## Not run:
> ##D # Requires Google Earth Engine authentication
> ##D Sys.setenv(EE_PROJECT = "your-ee-project-id")
> ##D ICESat2VegR::ee_initialize()
> ##D
> ##D library(sf)
> ##D library(terra)
> ##D
> ##D # AOI in Ocala National Forest, Florida
> ##D aoi <- st_as_sfc(st_bbox(c(
> ##D xmin = -81.8, xmax = -81.6,
> ##D ymin = 29.1, ymax = 29.3
> ##D ), crs = 4326))
> ##D
> ##D # Build the full ancillary stack (244 bands)
> ##D stack <- ee_build_hls_s1c_terrain_stack(
> ##D x = aoi,
> ##D start_date = "2024-03-01",
> ##D end_date = "2024-06-01",
> ##D cloud_max = 10
> ##D )
> ##D
> ##D # Check available bands
> ##D names(stack)
> ##D
> ##D # Compute AOI centroid for map view
> ##D centroid_lon <- mean(terra::ext(terra::vect(aoi))[c(1, 2)])
> ##D centroid_lat <- mean(terra::ext(terra::vect(aoi))[c(3, 4)])
> ##D
> ##D # Visualize true color RGB
> ##D leaflet::leaflet() |>
> ##D leaflet::addProviderTiles("Esri.WorldImagery") |>
> ##D ICESat2VegR::addEEImage(
> ##D stack$select(c("red", "green", "blue")),
> ##D bands = c("red", "green", "blue"),
> ##D group = "True Color",
> ##D min = 0,
> ##D max = 0.3
> ##D ) |>
> ##D leaflet::addControl(
> ##D html = "True Color
red / green / blue",
> ##D position = "bottomleft"
> ##D ) |>
> ##D leaflet::setView(lng = centroid_lon, lat = centroid_lat, zoom = 11) |>
> ##D leaflet::addLayersControl(
> ##D overlayGroups = "True Color",
> ##D options = leaflet::layersControlOptions(collapsed = FALSE)
> ##D )
> ##D
> ##D # Visualize false color (nir, red, green)
> ##D leaflet::leaflet() |>
> ##D leaflet::addProviderTiles("Esri.WorldImagery") |>
> ##D ICESat2VegR::addEEImage(
> ##D stack$select(c("nir", "red", "green")),
> ##D bands = c("nir", "red", "green"),
> ##D group = "False Color",
> ##D min = 0,
> ##D max = 0.3
> ##D ) |>
> ##D leaflet::addControl(
> ##D html = "False Color
nir / red / green",
> ##D position = "bottomleft"
> ##D ) |>
> ##D leaflet::setView(lng = centroid_lon, lat = centroid_lat, zoom = 11) |>
> ##D leaflet::addLayersControl(
> ##D overlayGroups = "False Color",
> ##D options = leaflet::layersControlOptions(collapsed = FALSE)
> ##D )
> ##D
> ##D # Visualize NDVI
> ##D leaflet::leaflet() |>
> ##D leaflet::addProviderTiles("Esri.WorldImagery") |>
> ##D ICESat2VegR::addEEImage(
> ##D stack$select("ndvi"),
> ##D bands = "ndvi",
> ##D group = "NDVI",
> ##D min = 0,
> ##D max = 0.8
> ##D ) |>
> ##D leaflet::addControl(
> ##D html = "NDVI",
> ##D position = "bottomleft"
> ##D ) |>
> ##D leaflet::setView(lng = centroid_lon, lat = centroid_lat, zoom = 11) |>
> ##D leaflet::addLayersControl(
> ##D overlayGroups = "NDVI",
> ##D options = leaflet::layersControlOptions(collapsed = FALSE)
> ##D )
> ##D
> ##D # Force Landsat HLS only
> ##D stack_landsat <- ee_build_hls_s1c_terrain_stack(
> ##D x = aoi,
> ##D start_date = "2024-03-01",
> ##D end_date = "2024-06-01",
> ##D hls_collection_id = "NASA/HLS/HLSL30/v002"
> ##D )
> ##D names(stack_landsat)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("ext_to_ee")
> ### * ext_to_ee
>
> flush(stderr()); flush(stdout())
>
> ### Name: ext_to_ee
> ### Title: Convert a terra extent or spatial object to an Earth Engine
> ### Rectangle
> ### Aliases: ext_to_ee
>
> ### ** Examples
>
> ## Not run:
> ##D library(terra)
> ##D
> ##D # Create an extent over Gainesville, FL
> ##D bb <- ext(c(-82.4, -82.2, 29.6, 29.8))
> ##D
> ##D # Convert to EE geometry
> ##D aoi <- ext_to_ee(bb)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("fit_metrics")
> ### * fit_metrics
>
> flush(stderr()); flush(stdout())
>
> ### Name: fit_metrics
> ### Title: Model fit metrics
> ### Aliases: fit_metrics
>
> ### ** Examples
>
> observed <- c(178, 33, 60, 80, 104, 204, 146)
> predicted <- c(184, 28.5, 55, 85, 105, 210, 155)
> fit_metrics(observed, predicted,
+ plotstat = TRUE, legend = "topleft", unit = "Mg/ha",
+ xlab = "Observed AGBD (Mg/ha)", ylab = "Predicted AGBD (Mg/ha)", pch = 16)
stat value unit
1 rmse 5.6600101 Mg/ha
2 rmseR 4.9217479 %
3 mae 5.2142857 Mg/ha
4 maeR 4.5341615 %
5 bias 2.5000000 Mg/ha
6 biasR 2.1739130 %
7 r 0.9987787
8 adj_r2 0.9970707
>
>
>
> cleanEx()
> nameEx("fit_model")
> ### * fit_model
>
> flush(stderr()); flush(stdout())
>
> ### Name: fit_model
> ### Title: Fit a Random Forest with optional resampling, tuning, and
> ### progress bars
> ### Aliases: fit_model
>
> ### ** Examples
>
> set.seed(42)
> n <- 200
> x <- data.frame(NDVI = runif(n, 0.2, 0.9),
+ EVI = runif(n, 0.1, 0.8),
+ NBR = runif(n, -0.5, 0.9),
+ SLP = runif(n, 0, 30))
> y <- with(x, 5 + 20*NDVI + 10*EVI^1.5 - 0.05*SLP + rnorm(n, 0, 2))
>
> # Full-data fit (no resampling)
> fit_none <- fit_model(x, y, rf_args = list(ntree = 400, mtry = 2))
> fit_none$stats_train
stat value unit
1 rmse 1.08888246
2 rmseR 5.88584452 %
3 mae 0.85704791
4 maeR 4.63268620 %
5 bias 0.02226463
6 biasR 0.12034920 %
7 r 0.97971573
8 adj_r2 0.95964010
>
> # LOOCV
> ## Don't show:
> # Make it smaller for CRAN checks
> x <- x[1:20, ]
> y <- y[1:20]
> ## End(Don't show)
> fit_loocv <- fit_model(x, y, test = list(method = "loocv"))
LOOCV (20 steps)
|
| | 0%
|
|==== | 5%
|
|======= | 10%
|
|========== | 15%
|
|============== | 20%
|
|================== | 25%
|
|===================== | 30%
|
|======================== | 35%
|
|============================ | 40%
|
|================================ | 45%
|
|=================================== | 50%
|
|====================================== | 55%
|
|========================================== | 60%
|
|============================================== | 65%
|
|================================================= | 70%
|
|==================================================== | 75%
|
|======================================================== | 80%
|
|============================================================ | 85%
|
|=============================================================== | 90%
|
|================================================================== | 95%
|
|======================================================================| 100%
> fit_loocv$stats_test
stat value unit
1 rmse 3.1184756
2 rmseR 15.9512515 %
3 mae 2.5215634
4 maeR 12.8979979 %
5 bias -0.1705160
6 biasR -0.8722027 %
7 r 0.8329743
8 adj_r2 0.6768376
>
> # 5-fold CV
> fit_k_fold <- fit_model(x, y, test = list(method = "k-fold", k = 5, seed = 42))
K-fold CV (k=5) (5 steps)
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
> fit_k_fold$stats_test
stat value unit
1 rmse 3.8603997
2 rmseR 19.7462522 %
3 mae 3.0337225
4 maeR 15.5177325 %
5 bias -0.3997963
6 biasR -2.0449899 %
7 r 0.6563940
8 adj_r2 0.3992338
>
> # Train/Test split
> fit_split <- fit_model(x, y, test = list(method = "split", test_size = 0.25, seed = 42))
> fit_split$stats_test
stat value unit
1 rmse 2.4756290
2 rmseR 13.5630132 %
3 mae 2.3926414
4 maeR 13.1083561 %
5 bias 0.4946385
6 biasR 2.7099329 %
7 r 0.8025151
8 adj_r2 0.5253739
>
> # Bootstrap (with tuning and .632 correction)
> ntree <- 400
> iterations <- 300
> ## Don't show:
> # Smaller tree and iterations for checks
> ntree <- 50
> iterations <- 10
> ## End(Don't show)
> fit_boot <- fit_model(
+ x, y,
+ rf_args = list(ntree = ntree),
+ test = list(method = "bootstrap", iterations = iterations, correction = TRUE),
+ tune = list(enable = TRUE, search = "random", n_random = 12)
+ )
Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
Bootstrap (10 iterations) (10 steps)
|
| | 0%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|======= | 10%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|============== | 20%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|===================== | 30%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|============================ | 40%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|=================================== | 50%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|========================================== | 60%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|================================================= | 70%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|======================================================== | 80%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|=============================================================== | 90%Tuning randomForest (12 steps)
|
| | 0%
|
|====== | 8%
|
|============ | 17%
|
|================== | 25%
|
|======================= | 33%
|
|============================= | 42%
|
|=================================== | 50%
|
|========================================= | 58%
|
|=============================================== | 67%
|
|==================================================== | 75%
|
|========================================================== | 83%
|
|================================================================ | 92%
|
|======================================================================| 100%
|
|======================================================================| 100%
>
> # K-fold CV with saved models
> fit_k <- fit_model(x, y, test = list(method = "k-fold", k = 5, seed = 42), list_test_models = TRUE)
K-fold CV (k=5) (5 steps)
|
| | 0%
|
|============== | 20%
|
|============================ | 40%
|
|========================================== | 60%
|
|======================================================== | 80%
|
|======================================================================| 100%
> length(fit_k$models_test) # one model per fold
[1] 5
>
>
>
>
> cleanEx()
> nameEx("formulaCalculate")
> ### * formulaCalculate
>
> flush(stderr()); flush(stdout())
>
> ### Name: formulaCalculate
> ### Title: Calculate raster values based on a formula
> ### Aliases: formulaCalculate
>
> ### ** Examples
>
> # Parameters
> raster_path <- file.path(tempdir(), "output.tif")
> ul_lat <- -15
> ul_lon <- -45
> lr_lat <- -25
> lr_lon <- -35
> res <- c(0.01, -0.01)
> datatype <- GDALDataType$GDT_Int32
> nbands <- 2
> projstring <- "EPSG:4326"
> nodata <- -1
> co <- c("TILED=YES", "BLOCKXSIZE=512", "BLOCKYSIZE=512", "COMPRESSION=LZW")
>
> # Create a new raster dataset
> ds <- createDataset(
+ raster_path = raster_path,
+ nbands = nbands,
+ datatype = datatype,
+ projstring = projstring,
+ lr_lat = lr_lat,
+ ul_lat = ul_lat,
+ ul_lon = ul_lon,
+ lr_lon = lr_lon,
+ res = res,
+ nodata = nodata,
+ co = co
+ )
>
> # Get the GDALRasterBand for ds
> band <- ds[[1]]
>
> # The updateBand can be the same
> # using a different one just for testing
> updateBand <- ds[[2]]
>
> # Set some dummy values
> band[[0, 0]] <- 1:(512 * 512)
>
> # Calculate the double - 10
> formulaCalculate(
+ formula = ~ x * 2 - 10,
+ data = list(x = band),
+ updateBand = updateBand
+ )
Calculating block 1/4 (25.00%)
Calculating block 2/4 (50.00%)
Calculating block 3/4 (75.00%)
Calculating block 4/4 (100.00%)
>
> ds$Close()
>
>
>
>
> cleanEx()
> nameEx("geomSampling")
> ### * geomSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: geomSampling
> ### Title: Get observations sampled within polygon features
> ### Aliases: geomSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Load polygon shapefile
+ polygon_filepath <- system.file("extdata",
+ "clip_geom.shp",
+ package = "ICESat2VegR"
+ )
+ polygon <- terra::vect(polygon_filepath)
+
+ # Sample 2 observations per polygon feature
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(
+ atl08_dt,
+ method = geomSampling(size = 2, geom = polygon, split_id = "id")
+ )
+ head(sampled)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("gridSampling")
> ### * gridSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: gridSampling
> ### Title: Get samples stratified by grid cells of specified size
> ### Aliases: gridSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Sample 2 observations per 0.01 degree grid cell
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(
+ atl08_dt,
+ method = gridSampling(size = 2, grid_size = 0.01)
+ )
+ head(sampled)
+
+ # Chain grid sampling with random sampling within each cell
+ set.seed(1)
+ sampled_chain <- ICESat2VegR::sample(
+ atl08_dt,
+ method = gridSampling(
+ size = 2,
+ grid_size = 0.01,
+ chainSampling = randomSampling(2)
+ )
+ )
+ head(sampled_chain)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("map_create")
> ### * map_create
>
> flush(stderr()); flush(stdout())
>
> ### Name: map_create
> ### Title: Create a prediction map in Google Earth Engine using a fitted
> ### Random Forest model
> ### Aliases: map_create
>
> ### ** Examples
>
> ## Not run:
> ##D Sys.setenv(EE_PROJECT = "your-ee-project-id")
> ##D ICESat2VegR::ee_initialize()
> ##D
> ##D library(sf)
> ##D library(randomForest)
> ##D
> ##D # -- AOI as simple bounding box --------------------------------
> ##D aoi <- sf::st_as_sfc(sf::st_bbox(c(
> ##D xmin = -82.4, xmax = -82.2,
> ##D ymin = 29.6, ymax = 29.8
> ##D ), crs = 4326))
> ##D ee_geom <- ICESat2VegR::.as_ee_geom(aoi)
> ##D
> ##D # -- Build embedding + terrain stack ---------------------------
> ##D stack <- ee_build_AlphaEarth_embedding_terrain_stack(
> ##D geom = ee_geom,
> ##D start_year = 2025,
> ##D end_year = 2025
> ##D )
> ##D
> ##D # -- Synthetic training data using stack band names ------------
> ##D # In practice, use real ICESat-2 extracted values
> ##D set.seed(42)
> ##D n <- 200
> ##D predictor_cols <- head(names(stack), 10)
> ##D
> ##D X <- as.data.frame(matrix(
> ##D rnorm(n * length(predictor_cols)),
> ##D nrow = n,
> ##D ncol = length(predictor_cols),
> ##D dimnames = list(NULL, predictor_cols)
> ##D ))
> ##D
> ##D # Synthetic canopy height response
> ##D y <- 5 + 2 * X[[1]] + 3 * X[[2]] + rnorm(n, sd = 1)
> ##D
> ##D # -- Fit Random Forest model -----------------------------------
> ##D rf_model <- randomForest(x = X, y = y, ntree = 100)
> ##D rf_model
> ##D
> ##D # -- Create prediction map in GEE ------------------------------
> ##D pred <- map_create(
> ##D model = rf_model,
> ##D stack = stack,
> ##D aoi = ee_geom,
> ##D mode = "auto"
> ##D )
> ##D
> ##D # pred is an ee$Image with one band: "prediction_layer"
> ##D class(pred)
> ##D names(pred)
> ##D pred
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("map_download")
> ### * map_download
>
> flush(stderr()); flush(stdout())
>
> ### Name: map_download
> ### Title: map_download: create task -> start -> (monitor) ->
> ### download/return id
> ### Aliases: map_download
>
> ### ** Examples
>
> ## Not run:
> ##D out <- map_download(
> ##D ee_image = img, method = "drive", region = aoi, scale = 10,
> ##D file_name_prefix = "my_pred", dsn = "pred.tif",
> ##D drive_folder = "EE_Exports", monitor = TRUE
> ##D )
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("map_view")
> ### * map_view
>
> flush(stderr()); flush(stdout())
>
> ### Name: map_view
> ### Title: Compose a leaflet map from multiple layers (EE rasters and/or
> ### vectors)
> ### Aliases: map_view
>
> ### ** Examples
>
> ## Not run:
> ##D m <- map_view(list(
> ##D list(type="ee_image", x=img, bands="prediction_layer", aoi=aoi,
> ##D group="Prediction", min_value=0, max_value=30,
> ##D legend=list(title="Height (m)", auto="quantile")),
> ##D list(type="vector", vect=polys_sf, group="Sites", color_field="site")
> ##D ))
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("plot")
> ### * plot
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot,icesat2.atl03atl08_dt,missing-method
> ### Title: Plot photons from ATL03 and ATL08 joined products
> ### Aliases: plot,icesat2.atl03atl08_dt,missing-method
> ### plot,icesat2.atl03atl08_dt,character-method
> ### plot,icesat2.atl03_seg_dt,missing-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 file
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ plot(
+ atl03_atl08_dt,
+ "ph_h",
+ pch = 16, cex = 0.5,
+ beam = "gt1r",
+ colors = c("gray", "#bd8421", "forestgreen", "green")
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 file
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Specifying the path to ATL08 file
+ atl08_path <- system.file("extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Reading ATL08 data (h5 file)
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+
+ # Extracting ATL03 and ATL08 photons and heights
+ atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5)
+
+ plot(
+ atl03_atl08_dt,
+ "h_ph",
+ colors = c("gray", "#bd8421", "forestgreen", "green"),
+ pch = 16, cex = 0.5
+ )
+
+ close(atl03_h5)
+ close(atl08_h5)
+ }
|
| | 0%
|
|================== | 25%
|
|=================================== | 50%
|
|==================================================== | 75%
|
|======================================================================| 100%
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # Specifying the path to ATL03 file
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ # Reading ATL03 data (h5 file)
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ # Extracting atl03 and atl03 photons and heights
+ atl03_photons_dt <- ATL03_seg_metadata_dt(
+ atl03_h5 = atl03_h5,
+ attributes = c(
+ "reference_photon_lon",
+ "reference_photon_lat",
+ "segment_dist_x",
+ "h_ph"
+ )
+ )
+
+ plot(
+ atl03_photons_dt,
+ col = "gray",
+ pch = 16,
+ cex = 0.5
+ )
+
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("plot.varSel")
> ### * plot.varSel
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot.varSel
> ### Title: Plot variable importance for 'varSel' objects
> ### Aliases: plot.varSel
>
> ### ** Examples
>
> require(randomForest)
Loading required package: randomForest
randomForest 4.7-1.2
Type rfNews() to see new features/changes/bug fixes.
>
> data(airquality)
> airquality <- na.omit(airquality)
>
> xdata <- airquality[, 2:6]
> ydata <- airquality[, 1]
>
> ntree = 200
> ## Don't show:
> ntree = 10
> ## End(Don't show)
> vs <- varSel(xdata, ydata, ntree = ntree, min.imp = 0.2)
Missing importance ranges: 0.5-0.74
Warning in varSel(xdata, ydata, ntree = ntree, min.imp = 0.2) :
The 0.25-0.49 threshold has <= 1 parameter and cannot be evaluated
Warning in varSel(xdata, ydata, ntree = ntree, min.imp = 0.2) :
The 0.75-1.00 threshold has <= 1 parameter and cannot be evaluated
>
> ## Selected variables only
> plot(vs, which = "sel.importance")
>
> ## All variables, highlighting selected ones, with inferno palette
> if (requireNamespace("viridis", quietly = TRUE)) {
+ plot(vs, which = "importance", palette = viridis::inferno)
+ }
>
>
>
>
> cleanEx()
detaching ‘package:randomForest’
> nameEx("plot_icesat2_orbit_animation")
> ### * plot_icesat2_orbit_animation
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot_icesat2_orbit_animation
> ### Title: Plot ICESat-2 orbital tracks as a 3D globe animation
> ### Aliases: plot_icesat2_orbit_animation
>
> ### ** Examples
>
> ## Not run:
> ##D plot_icesat2_orbit_animation()
> ##D
> ##D atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
> ##D atl03_h5 <- ATL03_read(atl03_path = atl03_path)
> ##D rgt_line <- rgt_extract(h5 = atl03_h5, line = TRUE)
> ##D
> ##D plot_icesat2_orbit_animation(
> ##D rgt = rgt_line,
> ##D launch = TRUE
> ##D )
> ##D
> ##D close(atl03_h5)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("predict_h5-ANY-icesat2.atl03_seg_dt-character-method")
> ### * predict_h5-ANY-icesat2.atl03_seg_dt-character-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: predict_h5,ANY,icesat2.atl03_seg_dt,character-method
> ### Title: S4 method for predicting using HDF5 file as output
> ### Aliases: predict_h5,ANY,icesat2.atl03_seg_dt,character-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file(
+ "extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_seg_dt <- ATL03_seg_metadata_dt(atl03_h5)
+
+ linear_model <- stats::lm(h_ph ~ segment_ph_cnt, data = atl03_seg_dt)
+ output_h5 <- tempfile(fileext = ".h5")
+
+ predicted_h5 <- predict_h5(linear_model, atl03_seg_dt, output_h5)
+
+ # List datasets
+ predicted_h5$ls()$name
+
+ # See predicted values
+ head(predicted_h5[["prediction"]][])
+
+ # Close the file
+ close(predicted_h5)
+ close(atl03_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("predict_h5-ANY-icesat2.atl08_dt-character-method")
> ### * predict_h5-ANY-icesat2.atl08_dt-character-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: predict_h5,ANY,icesat2.atl08_dt,character-method
> ### Title: S4 method for predicting using HDF5 file as output
> ### Aliases: predict_h5,ANY,icesat2.atl08_dt,character-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file(
+ "extdata",
+ "atl08_clip.h5",
+ package = "ICESat2VegR"
+ )
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+ linear_model <- stats::lm(h_canopy ~ canopy_openness, data = atl08_dt)
+ output_h5 <- tempfile(fileext = ".h5")
+ predicted_h5 <- predict_h5(linear_model, atl08_dt, output_h5)
+
+ # List datasets
+ predicted_h5$ls()$name
+
+ # See predicted values
+ head(predicted_h5[["prediction"]][])
+
+ # Close the file
+ close(predicted_h5)
+
+ # Close the input ICESat-2 file as well
+ close(atl08_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("predict_h5")
> ### * predict_h5
>
> flush(stderr()); flush(stdout())
>
> ### Name: predict_h5
> ### Title: Model prediction over data.tables using HDF5 file as output
> ### Aliases: predict_h5
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file(
+ "extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_seg_dt <- ATL03_seg_metadata_dt(atl03_h5)
+
+ linear_model <- stats::lm(h_ph ~ segment_ph_cnt, data = atl03_seg_dt)
+ output_h5 <- tempfile(fileext = ".h5")
+ predicted_h5 <- predict_h5(linear_model, atl03_seg_dt, output_h5)
+
+ # List datasets
+ predicted_h5$ls()$name
+
+ # See predicted values
+ head(predicted_h5[["prediction"]][])
+
+ # Close the file
+ close(predicted_h5)
+
+ # Close the input ICESat-2 file as well
+ close(atl03_h5)
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("randomSampling")
> ### * randomSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: randomSampling
> ### Title: Pure random sampling method
> ### Aliases: randomSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Sample 5 random observations
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(atl08_dt, method = randomSampling(5))
+ head(sampled)
+
+ # Sample 50% of observations
+ set.seed(1)
+ sampled_pct <- ICESat2VegR::sample(atl08_dt, method = randomSampling(0.5))
+ nrow(sampled_pct)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("rasterSampling")
> ### * rasterSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: rasterSampling
> ### Title: Get observations sampled by raster class
> ### Aliases: rasterSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Create a raster over the data extent
+ r <- terra::rast(
+ xmin = min(atl08_dt$longitude),
+ xmax = max(atl08_dt$longitude),
+ ymin = min(atl08_dt$latitude),
+ ymax = max(atl08_dt$latitude),
+ resolution = 0.005,
+ crs = "EPSG:4326"
+ )
+ terra::values(r) <- sample(1:3, terra::ncell(r), replace = TRUE)
+
+ # Sample 2 observations per raster class
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(
+ atl08_dt,
+ method = rasterSampling(size = 2, raster = r)
+ )
+ head(sampled)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
Warning in `[.data.table`(dt, , `:=`(raster_group, as.factor(v_rast[, 2]))) :
A shallow copy of this data.table was taken so that := can add or remove 1 columns by reference. At an earlier point, this data.table was copied by R (or was created manually using structure() or similar). Avoid names<- and attr<- which in R currently (and oddly) may copy the whole data.table. Use set* syntax instead to avoid copying: ?set, ?setnames and ?setattr. It's also not unusual for data.table-agnostic packages to produce tables affected by this issue. If this message doesn't help, please report your use case to the data.table issue tracker so the root cause can be fixed or this message improved.
>
>
>
> cleanEx()
> nameEx("rasterize_h5")
> ### * rasterize_h5
>
> flush(stderr()); flush(stdout())
>
> ### Name: rasterize_h5
> ### Title: Rasterizes the model prediction saved in the HDF5 file
> ### Aliases: rasterize_h5
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ }
NULL
>
>
>
> cleanEx()
> nameEx("rgt_extract")
> ### * rgt_extract
>
> flush(stderr()); flush(stdout())
>
> ### Name: rgt_extract
> ### Title: Extract Reference Ground Track from ICESat-2 ATL03 or ATL08 Data
> ### Aliases: rgt_extract
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl03_path <- system.file("extdata",
+ "atl03_clip.h5",
+ package = "ICESat2VegR"
+ )
+
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+
+ rgt_line <- rgt_extract(h5 = atl03_h5, line = TRUE)
+
+ rgt_extract(
+ h5 = atl03_h5,
+ line = TRUE,
+ output = file.path(tempdir(), "atl03_rgt.kml")
+ )
+
+ close(atl03_h5)
+
+ }
>
>
>
> cleanEx()
> nameEx("sample_ATL_granules_by_year")
> ### * sample_ATL_granules_by_year
>
> flush(stderr()); flush(stdout())
>
> ### Name: sample_ATL_granules_by_year
> ### Title: Sample ICESat-2 ATL granule URLs by year
> ### Aliases: sample_ATL_granules_by_year
>
> ### ** Examples
>
> urls <- c(
+ "https://example.org/ATL03_20200101000000_001.h5",
+ "https://example.org/ATL03_20200102000000_002.h5",
+ "https://example.org/ATL03_20210101000000_003.h5"
+ )
>
> sample_df <- sample_ATL_granules_by_year(urls, n_per_year = 1, seed = 42)
> sample_df
year url
1 2020 https://example.org/ATL03_20200101000000_001.h5
2 2021 https://example.org/ATL03_20210101000000_003.h5
>
>
>
>
> cleanEx()
> nameEx("slope")
> ### * slope
>
> flush(stderr()); flush(stdout())
>
> ### Name: slope
> ### Title: Compute terrain slope (degrees) from a DEM image
> ### Aliases: slope
>
> ### ** Examples
>
> ## Not run:
> ##D ee <- reticulate::import("ee")
> ##D dem <- ee$Image("NASA/NASADEM_HGT/001")
> ##D slp <- slope(dem)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("spacedSampling")
> ### * spacedSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: spacedSampling
> ### Title: Get observations with a minimum radius distance between samples
> ### Aliases: spacedSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Sample up to 5 observations with minimum 0.01 degree spacing
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(
+ atl08_dt,
+ method = spacedSampling(size = 5, radius = 0.01)
+ )
+ head(sampled)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
==1762623== Mismatched new/delete size value: 4
==1762623== at 0x4845FEC: operator delete(void*, unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:1146)
==1762623== by 0x111D0AE24: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:22)
==1762623== by 0x111D0AE6D: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:27)
==1762623== by 0x52A11A: R_RunWeakRefFinalizer (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1522)
==1762623== by 0x52A37F: RunFinalizers.isra.0 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1589)
==1762623== by 0x52F0D4: R_RunPendingFinalizers (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1625)
==1762623== by 0x52F0D4: R_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:3094)
==1762623== by 0x52F0D4: do_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2131)
==1762623== by 0x4D91BD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== Address 0x1141dc160 is 0 bytes inside a block of size 36 alloc'd
==1762623== at 0x48439B2: operator new[](unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:717)
==1762623== by 0x111D0B052: ANNIndex::ANNIndex(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, int) (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:16)
==1762623== by 0x111D3C218: get_new_impl<0, 1> (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:209)
==1762623== by 0x111D3C218: get_new (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:199)
==1762623== by 0x111D3C218: Rcpp::class_::newInstance(SEXPREC**, int) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/module/class.h:138)
==1762623== by 0x113F8D88: class__newInstance(SEXPREC*) (/tmp/Rtmpyd9vpr/R.INSTALL3b61c41e95a0d8/Rcpp/src/module.cpp:143)
==1762623== by 0x4953B8: do_External (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:576)
==1762623== by 0x4DEE4C: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8085)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== by 0x4E4ACD: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1230)
==1762623==
==1762623== Mismatched free() / delete / delete []
==1762623== at 0x4846053: operator delete(void*, unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:1146)
==1762623== by 0x111D0AE24: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:22)
==1762623== by 0x111D0AE6D: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:27)
==1762623== by 0x52A11A: R_RunWeakRefFinalizer (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1522)
==1762623== by 0x52A37F: RunFinalizers.isra.0 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1589)
==1762623== by 0x52F0D4: R_RunPendingFinalizers (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1625)
==1762623== by 0x52F0D4: R_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:3094)
==1762623== by 0x52F0D4: do_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2131)
==1762623== by 0x4D91BD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== Address 0x1141dc160 is 0 bytes inside a block of size 36 alloc'd
==1762623== at 0x48439B2: operator new[](unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:717)
==1762623== by 0x111D0B052: ANNIndex::ANNIndex(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, int) (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:16)
==1762623== by 0x111D3C218: get_new_impl<0, 1> (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:209)
==1762623== by 0x111D3C218: get_new (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:199)
==1762623== by 0x111D3C218: Rcpp::class_::newInstance(SEXPREC**, int) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/module/class.h:138)
==1762623== by 0x113F8D88: class__newInstance(SEXPREC*) (/tmp/Rtmpyd9vpr/R.INSTALL3b61c41e95a0d8/Rcpp/src/module.cpp:143)
==1762623== by 0x4953B8: do_External (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:576)
==1762623== by 0x4DEE4C: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8085)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== by 0x4E4ACD: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1230)
==1762623==
==1762623== Mismatched new/delete size value: 8
==1762623== at 0x4845FEC: operator delete(void*, unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:1146)
==1762623== by 0x111D0AE37: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:23)
==1762623== by 0x111D0AE6D: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:27)
==1762623== by 0x52A11A: R_RunWeakRefFinalizer (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1522)
==1762623== by 0x52A37F: RunFinalizers.isra.0 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1589)
==1762623== by 0x52F0D4: R_RunPendingFinalizers (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1625)
==1762623== by 0x52F0D4: R_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:3094)
==1762623== by 0x52F0D4: do_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2131)
==1762623== by 0x4D91BD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== Address 0x1141dc1d0 is 0 bytes inside a block of size 72 alloc'd
==1762623== at 0x48439B2: operator new[](unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:717)
==1762623== by 0x111D0B063: ANNIndex::ANNIndex(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, int) (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:17)
==1762623== by 0x111D3C218: get_new_impl<0, 1> (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:209)
==1762623== by 0x111D3C218: get_new (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:199)
==1762623== by 0x111D3C218: Rcpp::class_::newInstance(SEXPREC**, int) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/module/class.h:138)
==1762623== by 0x113F8D88: class__newInstance(SEXPREC*) (/tmp/Rtmpyd9vpr/R.INSTALL3b61c41e95a0d8/Rcpp/src/module.cpp:143)
==1762623== by 0x4953B8: do_External (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:576)
==1762623== by 0x4DEE4C: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8085)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== by 0x4E4ACD: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1230)
==1762623==
==1762623== Mismatched free() / delete / delete []
==1762623== at 0x4846053: operator delete(void*, unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:1146)
==1762623== by 0x111D0AE37: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:23)
==1762623== by 0x111D0AE6D: ANNIndex::~ANNIndex() (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:27)
==1762623== by 0x52A11A: R_RunWeakRefFinalizer (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1522)
==1762623== by 0x52A37F: RunFinalizers.isra.0 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1589)
==1762623== by 0x52F0D4: R_RunPendingFinalizers (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:1625)
==1762623== by 0x52F0D4: R_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:3094)
==1762623== by 0x52F0D4: do_gc (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2131)
==1762623== by 0x4D91BD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== Address 0x1141dc1d0 is 0 bytes inside a block of size 72 alloc'd
==1762623== at 0x48439B2: operator new[](unsigned long) (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:717)
==1762623== by 0x111D0B063: ANNIndex::ANNIndex(Rcpp::Vector<14, Rcpp::PreserveStorage>, Rcpp::Vector<14, Rcpp::PreserveStorage>, int) (/data/localhost/ripley/R/packages/tests-vg/ICESat2VegR/src/ANNIndex.cpp:17)
==1762623== by 0x111D3C218: get_new_impl<0, 1> (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:209)
==1762623== by 0x111D3C218: get_new (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Module.h:199)
==1762623== by 0x111D3C218: Rcpp::class_::newInstance(SEXPREC**, int) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/module/class.h:138)
==1762623== by 0x113F8D88: class__newInstance(SEXPREC*) (/tmp/Rtmpyd9vpr/R.INSTALL3b61c41e95a0d8/Rcpp/src/module.cpp:143)
==1762623== by 0x4953B8: do_External (/data/localhost/ripley/R/svn/R-devel/src/main/dotcode.c:576)
==1762623== by 0x4DEE4C: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8085)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533)
==1762623== by 0x4E4341: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518)
==1762623== by 0x4E470A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167)
==1762623== by 0x4E65A6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398)
==1762623== by 0x4E733F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314)
==1762623== by 0x4E4918: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333)
==1762623== by 0x4E4918: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278)
==1762623== by 0x4E4ACD: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1230)
==1762623==
>
>
>
> cleanEx()
> nameEx("stratifiedSampling")
> ### * stratifiedSampling
>
> flush(stderr()); flush(stdout())
>
> ### Name: stratifiedSampling
> ### Title: Get samples stratified by a variable binning histogram
> ### Aliases: stratifiedSampling
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR")
+ atl08_h5 <- ATL08_read(atl08_path = atl08_path)
+ atl08_dt <- ATL08_seg_attributes_dt(atl08_h5)
+
+ # Sample 2 observations per h_canopy stratum
+ set.seed(1)
+ sampled <- ICESat2VegR::sample(
+ atl08_dt,
+ method = stratifiedSampling(size = 2, variable = "h_canopy")
+ )
+ head(sampled)
+
+ close(atl08_h5)
+ }
|
| | 0%
|
|======================================================================| 100%
Warning in saneSample(dt, size) :
Not enough samples within group, truncated to 1 samples
Warning in saneSample(dt, size) :
Not enough samples within group, truncated to 1 samples
Warning in saneSample(dt, size) :
Not enough samples within group, truncated to 1 samples
Warning in saneSample(dt, size) :
Not enough samples within group, truncated to 1 samples
>
>
>
> cleanEx()
> nameEx("sub-sub-icesat2.granules_cloud-ANY-ANY-method")
> ### * sub-sub-icesat2.granules_cloud-ANY-ANY-method
>
> flush(stderr()); flush(stdout())
>
> ### Name: [[,icesat2.granules_cloud,ANY,ANY-method
> ### Title: Extract Granules
> ### Aliases: [[,icesat2.granules_cloud,ANY,ANY-method
>
> ### ** Examples
>
> ## Not run:
> ##D lower_left_lon <- -83.26
> ##D lower_left_lat <- 31.95
> ##D upper_right_lon <- -83.11
> ##D upper_right_lat <- 32.46
> ##D
> ##D daterange <- c("2019-04-12", "2019-05-03")
> ##D
> ##D ATL08_granules_cloud <- ATLAS_dataFinder(
> ##D short_name = "ATL08",
> ##D lower_left_lon,
> ##D lower_left_lat,
> ##D upper_right_lon,
> ##D upper_right_lat,
> ##D version = "007",
> ##D daterange = daterange,
> ##D persist = TRUE,
> ##D cloud_computing = TRUE
> ##D )
> ##D
> ##D ATL08_h5_cloud <- ATL08_read(ATL08_granules_cloud[1])
> ##D
> ##D ATL08_h5_cloud[['gt1l']]
> ##D close(ATL08_h5_cloud)
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("to_vect")
> ### * to_vect
>
> flush(stderr()); flush(stdout())
>
> ### Name: to_vect
> ### Title: Convert ICESat-2 classes, data.frame/data.table, and sf to
> ### terra::SpatVector
> ### Aliases: to_vect to_vect,data.frame-method to_vect,data.table-method
> ### to_vect,icesat2.atl03_seg_dt-method to_vect,icesat2.atl08_dt-method
> ### to_vect,icesat2.atl03atl08_dt-method to_vect,icesat2.atl03_dt-method
> ### to_vect,icesat2.atl03_atl08_seg_dt-method to_vect,sf-method
>
> ### ** Examples
>
> if (requireNamespace("hdf5r", quietly = TRUE)) {
+ # ICESat2VegR examples (package objects keep their classes):
+ atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR")
+ atl03_h5 <- ATL03_read(atl03_path = atl03_path)
+ atl03_segment_dt <- ATL03_seg_metadata_dt(atl03_h5 = atl03_h5)
+ atl03_segment_vect <- to_vect(atl03_segment_dt)
+ terra::plot(atl03_segment_vect, col = atl03_segment_vect$segment_ph_cnt)
+ close(atl03_h5)
+
+ # Plain data.frame / data.table usage:
+ df <- data.frame(longitude = c(-84, -84.1), latitude = c(29.6, 29.7), z = 1:2)
+ v <- to_vect(df)
+ v2 <- to_vect(df, lon = "longitude", lat = "latitude", crs = "EPSG:4326")
+
+ }
|
| | 0%
|
|======================================================================| 100%
>
>
>
> cleanEx()
> nameEx("varSel")
> ### * varSel
>
> flush(stderr()); flush(stdout())
>
> ### Name: varSel
> ### Title: Random Forest Variable Selection (Breiman-only)
> ### Aliases: varSel
>
> ### ** Examples
>
> require(randomForest)
Loading required package: randomForest
randomForest 4.7-1.2
Type rfNews() to see new features/changes/bug fixes.
>
> data(airquality)
> airquality <- na.omit(airquality)
>
> xdata <- airquality[, 2:6]
> ydata <- airquality[, 1]
> ntree <- 500
> ## Don't show:
> # Lightweight version for R CMD check
> xdata <- airquality[1:50, 2:6]
> ydata <- airquality[1:50, 1]
> ntree <- 50
> ## End(Don't show)
> ## Regression example with MIR scaling and importance cutoff
> vs.regress <- varSel(
+ xdata = xdata,
+ ydata = ydata,
+ imp.scale = "mir",
+ ntree = ntree,
+ min.imp = 0.2
+ )
Warning in varSel(xdata = xdata, ydata = ydata, imp.scale = "mir", ntree = ntree, :
The 0.00-0.24 threshold has <= 1 parameter and cannot be evaluated
Warning in varSel(xdata = xdata, ydata = ydata, imp.scale = "mir", ntree = ntree, :
The 0.50-0.74 threshold has <= 1 parameter and cannot be evaluated
Warning in varSel(xdata = xdata, ydata = ydata, imp.scale = "mir", ntree = ntree, :
The 0.75-1.00 threshold has <= 1 parameter and cannot be evaluated
>
> vs.regress$selvars
[1] "Solar.R" "Wind" "Temp" "Month"
>
> ## Plot all variables, highlighting selected ones
> plot(vs.regress, which = "importance")
>
>
>
>
> cleanEx()
detaching ‘package:randomForest’
> nameEx("vect_as_ee")
> ### * vect_as_ee
>
> flush(stderr()); flush(stdout())
>
> ### Name: vect_as_ee
> ### Title: Convert vector data to Google Earth Engine FeatureCollection (no
> ### rgee)
> ### Aliases: vect_as_ee
>
> ### ** Examples
>
> ## Not run:
> ##D # -- Prerequisites (Python side):
> ##D # import ee; ee.Initialize()
> ##D #
> ##D # Example with sf POINTS
> ##D library(sf)
> ##D pts <- st_as_sf(data.frame(
> ##D id = 1:3,
> ##D x = c(-84.02171, -84.02025, -84.02026),
> ##D y = c(31.29891, 31.31945, 31.31938)
> ##D ), coords = c("x","y"), crs = "EPSG:4326")
> ##D
> ##D # In-memory FeatureCollection:
> ##D fc <- vect_as_ee(pts, via = "getInfo")
> ##D
> ##D # Export to an EE asset (monitor until done):
> ##D # fc_asset <- vect_as_ee(
> ##D # pts,
> ##D # via = "getInfo_to_asset",
> ##D # assetId = "users/you/demo_points",
> ##D # overwrite = TRUE,
> ##D # monitoring = TRUE
> ##D # )
> ## End(Not run)
>
>
>
>
> cleanEx()
> nameEx("write_geojson")
> ### * write_geojson
>
> flush(stderr()); flush(stdout())
>
> ### Name: write_geojson
> ### Title: Safely write a GeoJSON file from a lon/lat table
> ### Aliases: write_geojson
>
> ### ** Examples
>
> pts <- data.frame(
+ id = 1:3,
+ lon = c(-82.35, -82.34, -82.33),
+ lat = c( 29.65, 29.66, 29.67)
+ )
>
> write_geojson(pts, tempfile(fileext = ".geojson"))
>
>
>
>
> ### *