Title: | NASA's Ice, Cloud, and Elevation Satellite (ICESat-2) Data Analysis for Land and Vegetation Applications |
---|---|
Description: | Set of tools for downloading, reading, visualizing, processing and exporting NASA's ICESat-2 ATL03 (Global Geolocated Photon Data) and ATL08 (Land and Vegetation Height) products for Land and Vegetation Applications. |
Authors: | Carlos Alberto Silva [aut, cph], Caio Hamamura [aut, cph, cre] |
Maintainer: | Caio Hamamura <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.0.1 |
Built: | 2025-01-21 06:51:24 UTC |
Source: | https://github.com/carlos-alberto-silva/ICESat2VegR |
This method subsets the granules
slot of an icesat2.granules_cloud
object.
## S4 method for signature 'icesat2.granules_cloud,ANY,ANY,ANY' x[i, j, ..., drop = TRUE]
## S4 method for signature 'icesat2.granules_cloud,ANY,ANY,ANY' x[i, j, ..., drop = TRUE]
x |
An object of class |
i |
Subset index. |
j |
Unused, just to match the generic signature. |
... |
Additional arguments (not used). |
drop |
Unused, just to match the generic signature. |
An object of class icesat2.granule_cloud
.
This method extracts a single element from the granules
slot of an icesat2.granules_cloud
object.
## S4 method for signature 'icesat2.granules_cloud,ANY,ANY' x[[i, j, ...]]
## S4 method for signature 'icesat2.granules_cloud,ANY,ANY' x[[i, j, ...]]
x |
An object of class |
i |
Extraction index. |
j |
Unused, just to match the generic signature. |
... |
Additional arguments (not used). |
An object of class icesat2.granule_cloud
.
## Not run: granule <- new("icesat2.granules_cloud") extracted_granule <- granule[[1]] ## End(Not run)
## Not run: granule <- new("icesat2.granules_cloud") extracted_granule <- granule[[1]] ## End(Not run)
This function gives access to the GDALRasterBand using [[i]], where i is the band index to return.
## S3 method for class 'GDALDataset' x[[slice]]
## S3 method for class 'GDALDataset' x[[slice]]
x |
GDALDatset. Automatically obtained from GDALDataset[[]] call. |
slice |
Integer. The index for the band to access. |
An object of GDALRasterBand R6 class.
This function gives access to the GDALRasterBand using [[i]], where i is the band index to return.
## S3 method for class 'GDALRasterBand' x[[blockX, blockY]]
## S3 method for class 'GDALRasterBand' x[[blockX, blockY]]
x |
GDALRasterBand. Automatically obtained from GDALDataset[[]] call. |
blockX |
Integer. The x index for block to access. |
blockY |
Integer. The y index for block to access. |
Nothing, this is a setter
This function gives access to the GDALRasterBand using [[i]], where i is the band index to return.
## S3 replacement method for class 'GDALRasterBand' x[[blockX, blockY]] <- value
## S3 replacement method for class 'GDALRasterBand' x[[blockX, blockY]] <- value
x |
GDALRasterBand. Automatically obtained from GDALDataset[[]] call. |
blockX |
Integer. The x index for block to access. |
blockY |
Integer. The y index for block to access. |
value |
Integer. The value buffer to write |
Nothing, this is a setter
Adds Earth Engine Image class to leaflet
addEEImage( map, x, bands, min_value = 0, max_value = 1, palette = c("red", "green"), ... )
addEEImage( map, x, bands, min_value = 0, max_value = 1, palette = c("red", "green"), ... )
map |
|
x |
Earth Engine Image open with |
bands |
define the bands that should be used for visualization, default NULL, will use the available bands from the Image. |
min_value |
The minimum value to represent for visualization purposes |
max_value |
The maximum value to represent for visualization purposes |
palette |
A |
... |
Other parameters to be passed to |
A leaflet::leaflet
/htmlwidget
with the Earth Engine image added.
## Not run: collection_id <- "NASA/HLS/HLSL30/v002" ee_collection <- ee$ImageCollection(collection_id) cloudMask <- 2^1 + 2^2 + 2^3 hlsMask <- function(image) { image$updateMask( !(image[["Fmask"]] & cloudMask) ) } image <- c( ee_collection$filterDate("2020-04-01", "2020-07-31")$map(hlsMask), ee_collection$filterDate("2021-04-01", "2021-07-31")$map(hlsMask) )$filter("CLOUD_COVERAGE < 30")$median() if (require("leaflet")) { leaflet() %>% addEEImage( image, bands = list(3, 2, 1), min_value = 0.001, max_value = 0.2 ) %>% setView(lng = -82.2345, lat = 29.6552, zoom = 10) } ## End(Not run)
## Not run: collection_id <- "NASA/HLS/HLSL30/v002" ee_collection <- ee$ImageCollection(collection_id) cloudMask <- 2^1 + 2^2 + 2^3 hlsMask <- function(image) { image$updateMask( !(image[["Fmask"]] & cloudMask) ) } image <- c( ee_collection$filterDate("2020-04-01", "2020-07-31")$map(hlsMask), ee_collection$filterDate("2021-04-01", "2021-07-31")$map(hlsMask) )$filter("CLOUD_COVERAGE < 30")$median() if (require("leaflet")) { leaflet() %>% addEEImage( image, bands = list(3, 2, 1), min_value = 0.001, max_value = 0.2 ) %>% setView(lng = -82.2345, lat = 29.6552, zoom = 10) } ## End(Not run)
This method handles adding an Earth Engine Image to a leaflet map.
## S4 method for signature 'leaflet,ee.image.Image' addEEImage( map, x, bands = NULL, min_value = 0, max_value = 1, palette = defaultPallete, ... )
## S4 method for signature 'leaflet,ee.image.Image' addEEImage( map, x, bands = NULL, min_value = 0, max_value = 1, palette = defaultPallete, ... )
map |
A |
x |
An Earth Engine Image object created with |
bands |
A vector defining the bands to be used for visualization. Default is NULL, which uses the available bands from the image. |
min_value |
The minimum value for visualization purposes. Default is 0. |
max_value |
The maximum value for visualization purposes. Default is 1. |
palette |
A character vector describing a list of colors in either hexadecimal or valid CSS color names. Default is a predefined palette. |
... |
Other parameters to be passed to the |
A leaflet::leaflet
/htmlwidget
object with the Earth Engine image added.
This class uses Approximate Neareast Neighbor Index for finding points that are within a specified range.
tree
The C++ pointer for the built tree
new()
Creates a new instance of the ANNIndex
class.
ANNIndex$new(x, y)
x
NumericVector of x/longitude
y
NumericVector of y/latitude
radius
the minimum radius between the points
searchFixedRadius()
Given a x, y point get the indexes that are within a specified radius.
ANNIndex$searchFixedRadius(x, y, radius)
x
NumericVector of x/longitude
y
NumericVector of y/latitude
radius
the minimum radius between the points
Mount, D. M.; Arya, S. ANN: A Library for Approximate Nearest Neighbor Searching, available in https://www.cs.umd.edu/~mount/ANN/
The local gradient is computed using the 4-connected neighbors of each pixel, so missing values will occur around the edges of an image.
aspect(x)
aspect(x)
x |
The |
An ee.Image
with a single band named "Aspect".
Calculates the angle formed by the 2D vector x, y.
atan2.ee.ee_number.Number(x)
atan2.ee.ee_number.Number(x)
x |
The number to calculate the |
The resulting ee.Number with the results from atan2
.
Computes a series of statistics from ATL03 and ATL08 labeled photons within a given segment length.
ATL03_ATL08_compute_seg_attributes_dt_segStat( atl03_atl08_seg_dt, list_expr, ph_class = c(0, 1, 2, 3), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), quality_ph = NULL, night_flag = NULL )
ATL03_ATL08_compute_seg_attributes_dt_segStat( atl03_atl08_seg_dt, list_expr, ph_class = c(0, 1, 2, 3), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), quality_ph = NULL, night_flag = NULL )
atl03_atl08_seg_dt |
An S4 object of class |
list_expr |
The function to be applied for computing the defined statistics |
ph_class |
Character vector indicating photons to process based on the classification (1=ground, 2=canopy, 3=top canopy), Default is c(2,3) |
beam |
Character vector indicating beams to process. Default is c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
quality_ph |
Indicates the quality of the associated photon. 0 = nominal, 1 = possible_afterpulse, 2 = possible_impulse_response_ effect, 3=possible_tep. Default is 0 |
night_flag |
Flag indicating the data were acquired in night conditions: 0=day, 1=night. Default is 1 |
Returns an S4 object of class icesat2.atl08_dt
Containing Statistics of ATL03 and ATL08 labeled photons
# 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)
# 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)
This function clips joined ATL03 and ATL08 photon attributes within a given Bounding Box
ATL03_ATL08_photons_attributes_dt_clipBox( atl03_atl08_dt, lower_left_lon, upper_right_lon, upper_right_lat, lower_left_lat )
ATL03_ATL08_photons_attributes_dt_clipBox( atl03_atl08_dt, lower_left_lon, upper_right_lon, upper_right_lat, lower_left_lat )
atl03_atl08_dt |
An S4 object of class |
lower_left_lon |
Numeric. West longitude (x) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lon |
Numeric. East longitude (x) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lat |
Numeric. North latitude (y) coordinate of bounding rectangle, in decimal degrees. |
lower_left_lat |
Numeric. South latitude (y) coordinate of bounding rectangle, in decimal degrees. |
Returns an S4 object of class icesat2.atl03atl08_dt
containing a subset of the ATL03 and ATL08 photon attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# Specifying the path to ATL03 and ATL08 file 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) # Joining ATL03 and ATL08 photons and heights atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5) head(atl03_atl08_dt) # Bounding rectangle coordinates lower_left_lon <- -103.7604 lower_left_lat <- 59.4672 upper_right_lon <- -103.7600 upper_right_lat <- 59.4680 # Clipping ATL08-derived canopy metrics by boundary box extent atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipBox( atl03_atl08_dt, lower_left_lon, upper_right_lon, upper_right_lat, lower_left_lat ) head(atl03_atl08_dt_clip) close(atl03_h5) close(atl08_h5)
# Specifying the path to ATL03 and ATL08 file 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) # Joining ATL03 and ATL08 photons and heights atl03_atl08_dt <- ATL03_ATL08_photons_attributes_dt_join(atl03_h5, atl08_h5) head(atl03_atl08_dt) # Bounding rectangle coordinates lower_left_lon <- -103.7604 lower_left_lat <- 59.4672 upper_right_lon <- -103.7600 upper_right_lat <- 59.4680 # Clipping ATL08-derived canopy metrics by boundary box extent atl03_atl08_dt_clip <- ATL03_ATL08_photons_attributes_dt_clipBox( atl03_atl08_dt, lower_left_lon, upper_right_lon, upper_right_lat, lower_left_lat ) head(atl03_atl08_dt_clip) close(atl03_h5) close(atl08_h5)
This function clips joined ATL03 and ATL08 photon attributes within a given geometry.
ATL03_ATL08_photons_attributes_dt_clipGeometry( atl03_atl08_dt, polygon, split_by = NULL )
ATL03_ATL08_photons_attributes_dt_clipGeometry( atl03_atl08_dt, polygon, split_by = NULL )
atl03_atl08_dt |
An S4 object of class |
polygon |
An object of class |
split_by |
Optional. Polygon ID. If defined, the data will be clipped by each polygon using the polygon ID from the attribute table. |
Returns an S4 object of class icesat2.atl03atl08_dt
containing the clipped ATL08 attributes.
# 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 polygon_filepath <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR") # Reading shapefile as a SpatVector 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" ) head(atl03_atl08_dt_clip) close(atl03_h5) close(atl08_h5)
# 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 polygon_filepath <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR") # Reading shapefile as a SpatVector 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" ) head(atl03_atl08_dt_clip) close(atl03_h5) close(atl08_h5)
This function computes a series of user defined descriptive statistics within each given grid cell for ATL03 and ATL08 photon attributes
ATL03_ATL08_photons_attributes_dt_gridStat( atl03_atl08_dt, func, res = 0.5, ph_class = c(2, 3), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), quality_ph = 0, night_flag = 1 )
ATL03_ATL08_photons_attributes_dt_gridStat( atl03_atl08_dt, func, res = 0.5, ph_class = c(2, 3), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), quality_ph = 0, night_flag = 1 )
atl03_atl08_dt |
An S4 object of class |
func |
The function to be applied for computing the defined statistics |
res |
Spatial resolution in decimal degrees for the output SpatRast raster layer. Default is 0.5. |
ph_class |
Character vector indicating photons to process based on the classification (1=ground, 2=canopy, 3=top canopy), Default is c(2,3) |
beam |
Character vector indicating beams to process. Default is c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
quality_ph |
Indicates the quality of the associated photon. 0=nominal, 1=possible_afterpulse, 2=possible_impulse_response_effect, 3=possible_tep. Default is 0 |
night_flag |
Flag indicating the data were acquired in night conditions: 0=day, 1=night. Default is 1 |
Return a SpatRast raster layer(s) of selected ATL03 and ATL08 photon attribute(s)
# 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)
# 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)
This function joins ATL03 and ATL08 computed photons attributes
ATL03_ATL08_photons_attributes_dt_join( atl03_h5, atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") )
ATL03_ATL08_photons_attributes_dt_join( atl03_h5, atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") )
atl03_h5 |
A ICESat-2 ATL03 object (output of |
atl08_h5 |
A ICESat-2 ATL08 object (output of |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
These are the photons attributes extracted by default:
ph_segment_id
: Georeferenced segment id (20-m) associated with each photon.
lon_ph
: Longitude of each received photon. Computed from the ECEF Cartesian coordinates
of the bounce point.
lat_ph
: Latitude of each received photon. Computed from the ECEF Cartesian coordinates
of the bounce point.
h_ph
: Height of each received photon, relative to the WGS-84 ellipsoid including the
geophysical corrections noted in section 6.0. Please note that neither the geoid,
ocean tide nor the dynamic atmospheric corrections (DAC) are applied to the
ellipsoidal heights.
quality_ph
: Indicates the quality of the associated photon. 0=nominal,
1=possible_afterpulse, 2=possible_impulse_response_effect, 3=possible_tep.
Use this flag in conjunction with signal_conf_ph
to identify those photons
that are likely noise or likely signal.
solar_elevation
: Elevation of the sun above the horizon at the photon bounce point.
dist_ph_along
: Along-track distance of the photon from the beginning of the segment.
dist_ph_across
: Across-track distance of the photon from the center of the segment.
night_flag
: Flag indicating the data were acquired in night conditions: 0=day, 1=night.
Night flag is set when solar elevation is below 0.0 degrees.
classed_pc_indx
: Indices of photons tracking back to ATL03 that surface finding software
identified and used within the creation of the data products.
classed_pc_flag
: The L2B algorithm is run if this flag is set to 1 indicating data have
sufficient waveform fidelity for L2B to run.
ph_h
: Height of photon above interpolated ground surface.
d_flag
: Flag indicating whether DRAGANN labeled the photon as noise or signal.
delta_time
: Mid-segment GPS time in seconds past an epoch. The epoch is provided in
the metadata at the file level.
orbit_number
: Orbit number identifier to identify data from different orbits.
beam
: Beam identifier.
strong_beam
: Logical indicating if the beam is a strong beam.
Returns an S4 object of class icesat2.atl03atl08_dt
containing the ATL08 computed photons attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# 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)
# 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)
Converts ATL03/ATL08 classified photon cloud to LAS
ATL03_ATL08_photons_attributes_dt_LAS( atl03_atl08_dt, output, normalized = TRUE )
ATL03_ATL08_photons_attributes_dt_LAS( atl03_atl08_dt, output, normalized = TRUE )
atl03_atl08_dt |
An S4 object of class |
output |
character. The output path of for the LAS(Z) file(s). The function will create one LAS file per UTM Zone in WGS84 datum. |
normalized |
logical, default TRUE. Whether the output should be normalized LAS or raw altitude. |
Nothing, it just saves outputs as LAS file in disk
outdir <- tempdir() # 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) if (require("lidR")) { ATL03_ATL08_photons_attributes_dt_LAS( atl03_atl08_dt, output = file.path(outdir, "output.laz"), normalized = TRUE ) } close(atl03_h5) close(atl08_h5)
outdir <- tempdir() # 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) if (require("lidR")) { ATL03_ATL08_photons_attributes_dt_LAS( atl03_atl08_dt, output = file.path(outdir, "output.laz"), normalized = TRUE ) } close(atl03_h5) close(atl08_h5)
Computes a series of statistics ATL03 and ATL08 joined photons attributes within area defined by a polygon
ATL03_ATL08_photons_attributes_dt_polyStat( atl03_atl08_dt, func, poly_id = NULL )
ATL03_ATL08_photons_attributes_dt_polyStat( atl03_atl08_dt, func, poly_id = NULL )
atl03_atl08_dt |
An S4 object of class |
func |
The function to be applied for computing the defined statistics |
poly_id |
Polygon id. If defined, statistics will be computed for each polygon |
Returns an S4 object of class icesat2.atl08_dt
Containing Statistics of ATL08 classified canopy photons
# 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)
# 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)
Function to estimate ground elevation using smoothing and interpolation functions
ATL03_ATL08_photons_dt_height_normalize( atl03_atl08_seg_dt, smoothing_window = NA, smoothing_func = median, interpolation_func = NA, xout_parameter_name = "xout", ... )
ATL03_ATL08_photons_dt_height_normalize( atl03_atl08_seg_dt, smoothing_window = NA, smoothing_func = median, interpolation_func = NA, xout_parameter_name = "xout", ... )
atl03_atl08_seg_dt |
An S4 object of class |
smoothing_window |
numeric. The smoothing window size in meters for smoothing the photon cloud. Default is NA, see details for more information. |
smoothing_func |
function. The smoothing function to be applied on the smoothing window. |
interpolation_func |
function. The interpolation function to estimate the ground elevation.
Default |
xout_parameter_name |
character. The parameter name used for the |
... |
parameters to be passed forward to |
The function for calculating the ground will first pass a smoothing
window with smoothing_window
size,
applying the smoothing_func
to aggregate the ground photons.
Then it will use an interpolation function between those aggregated photons to calculate a smooth surface.
The smoothing_func
signature will depend on the function used.
It is assumed that the first two arguments are vectors of x
(independent
variable) and y
(the prediction to be interpolated). The remaining
arguments are passed through ...
.
The interpolation functions need a third parameter which is the
x
vector to be interpolated. Functions from stats
base package
stats::approx()
and stats::spline()
name this argument as xout
,
so you can use:
ATL03_ATL08_photons_fitground_seg_dt( dt, interpolation_func = approx, xout = 1:30 )
For example, to interpolate the values for the 1:30 vector. But other functions
may name the parameter differently, such as signal::pchip()
, which name
the parameter as xi
instead of xout
. signal::pchip()
is the
algorithm used by ATL08 ATBD.
The smoothing_window
can be left NA, which will use the ATBD algoritm
for calculating the window size:
, where length
is the number of photons within segment.
This is not the same algorithm as used in ATL08 but is an adapted version that uses the ATL08 pre-classification
Function to estimate ground elevation using smoothing and interpolation functions
ATL03_ATL08_photons_seg_dt_fitground( atl03_atl08_seg_dt, smoothing_window = NA, smoothing_func = median, interpolation_func = NA, xout_parameter_name = "xout", ... )
ATL03_ATL08_photons_seg_dt_fitground( atl03_atl08_seg_dt, smoothing_window = NA, smoothing_func = median, interpolation_func = NA, xout_parameter_name = "xout", ... )
atl03_atl08_seg_dt |
An S4 object of class |
smoothing_window |
numeric. The smoothing window size in meters for smoothing the photon cloud. Default is NA, see details for more information. |
smoothing_func |
function. The smoothing function to be applied on the smoothing window. |
interpolation_func |
function. The interpolation function to estimate the ground elevation. |
xout_parameter_name |
character. Optional, can be used to inform the parameter name that the interpolation_func uses for passing the prediction vector and already use the photons for prediction. Default NA will use the ... |
... |
Optional parameters to pass to the interpolation_func, see details for more information. |
The function for calculating the ground will first pass a smoothing
window with smoothing_window
size,
applying the smoothing_func
to aggregate the ground photons.
Then it will use an interpolation function between those aggregated photons to calculate a smooth surface.
The smoothing_func
signature will depend on the function used.
It is assumed that the first two arguments are vectors of x
(independent
variable) and y
(the prediction to be interpolated). The remaining
arguments are passed through ...
.
The interpolation functions need a third parameter which is the
x
vector to be interpolated. Functions from stats
base package
stats::approx()
and stats::spline()
name this argument as xout
,
so you can use:
ATL03_ATL08_photons_fitground_seg_dt( dt, interpolation_func = approx, xout = 1:30 )
For example, to interpolate the values for the 1:30 vector. But other functions
may name the parameter differently, such as signal::pchip()
, which name
the parameter as xi
instead of xout
. signal::pchip()
is the
algorithm used by ATL08 ATBD.
The smoothing_window
can be left NA, which will use the ATBD algoritm
for calculating the window size:
, where length
is the number of photons within segment.
This is not the same algorithm as used in ATL08 but is an adapted version that uses the ATL08 pre-classification
This function reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) as h5 file.
ATL03_ATL08_seg_cover_dt_compute(atl03_atl08_dt, reflectance_ratio = 1)
ATL03_ATL08_seg_cover_dt_compute(atl03_atl08_dt, reflectance_ratio = 1)
atl03_atl08_dt |
|
reflectance_ratio |
Numeric. The reflectance ratio to use to compute the coverage metric.
|
Coverage is calculated with the formula
Returns an S4 object of class data.table::data.table
containing ICESat-2 ATL08 data.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This function reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) as h5 file.
ATL03_ATL08_segment_create( atl03_atl08_dt, segment_length, centroid = "mean", output = NA, overwrite = FALSE )
ATL03_ATL08_segment_create( atl03_atl08_dt, segment_length, centroid = "mean", output = NA, overwrite = FALSE )
atl03_atl08_dt |
|
segment_length |
|
centroid |
character. Method used to calculate the segment centroid, either "mean" or "midpoint", see details. Default 'mean'. |
output |
Character vector. The output vector file. The GDAL vector format
will be inferred by the file extension using |
overwrite |
logical input to control if the output vector file should be overwritten. Default FALSE. |
The centroid will be computed using either the photons centroid or the approximate segment centroid.
"mean": calculated using the average coordinates from all photons within the segment. This approach will better represent the mean statistics location.
"mid-point": the minimum and maximum coordinates will be averaged to calculate a midpoint within the segment. This will give a better representation of the segment true mid-point
Returns an S4 object of class icesat2.atl03atl08_dt
containing ICESat-2 ATL08 data.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# 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)
# 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)
This function clips ATL03 HDF5 file within beam groups, but keeps metada and ancillary data the same.
ATL03_h5_clipBox( atl03, output, bbox, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
ATL03_h5_clipBox( atl03, output, bbox, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
atl03 |
|
output |
character. Path to the output h5 file. |
bbox |
|
beam |
|
additional_groups |
|
Returns the clipped S4 object of class icesat2.atl03_h5
# 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) # Bounding rectangle coordinates xmin <- -106.5723 xmax <- -106.5693 ymin <- 41.533 ymax <- 41.537 # Clipping ATL03 photons by boundary box extent output <- tempfile(fileext = ".h5") atl03_photons_dt_clip <- ATL03_h5_clipBox(atl03_h5, output, c(ymax, xmin, ymin, xmax)) close(atl03_h5)
# 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) # Bounding rectangle coordinates xmin <- -106.5723 xmax <- -106.5693 ymin <- 41.533 ymax <- 41.537 # Clipping ATL03 photons by boundary box extent output <- tempfile(fileext = ".h5") atl03_photons_dt_clip <- ATL03_h5_clipBox(atl03_h5, output, c(ymax, xmin, ymin, xmax)) close(atl03_h5)
This function clips ATL03 HDF5 file within beam groups, but keeps metada and ancillary data the same.
ATL03_h5_clipGeometry( atl03, output, vect, polygon_id = NULL, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
ATL03_h5_clipGeometry( atl03, output, vect, polygon_id = NULL, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
atl03 |
|
output |
character. Path to the output h5 file, the attribute for polygons will be appended to the file name. |
vect |
|
polygon_id |
|
beam |
|
additional_groups |
|
Returns a list of clipped S4 object of class icesat2.atl03_h5
# 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) output <- tempfile(fileext = ".h5") vect_path <- system.file("extdata", "polygons.shp", package = "ICESat2VegR" ) vect <- terra::vect() # Clipping ATL03 photons by boundary box extent atl03_photons_dt_clip <- ATL03_h5_clipGeometry( atl03_h5, output, vect, polygon_id = "id" ) close(atl03_h5)
# 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) output <- tempfile(fileext = ".h5") vect_path <- system.file("extdata", "polygons.shp", package = "ICESat2VegR" ) vect <- terra::vect() # Clipping ATL03 photons by boundary box extent atl03_photons_dt_clip <- ATL03_h5_clipGeometry( atl03_h5, output, vect, polygon_id = "id" ) close(atl03_h5)
This function extracts photons attributes from ICESat-2 ATL03 data
ATL03_photons_attributes_dt( atl03_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") )
ATL03_photons_attributes_dt( atl03_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") )
atl03_h5 |
A ICESat-2 ATL03 object (output of |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
These are the photons attributes extracted:
lon_ph Longitude of each received photon. Computed from the ECEF Cartesian coordinates of the bounce point.
lat_ph Latitude of each received photon. Computed from the ECEF Cartesian coordinates of the bounce point.
lat_ph Latitude of each received photon. Computed from the ECEF Cartesian coordinates of the bounce point. Height of each received photon, relative to the WGS-84 ellipsoid including the geophysical corrections noted in section 6.0. Please note that neither the geoid, ocean tide nor the dynamic atmospheric corrections (DAC) are applied to the ellipsoidal heights.
quality_ph Indicates the quality of the associated photon. 0=nominal, 1=possible_afterpulse, 2=possible_impulse_response_ effect, 3=possible_tep. Use this flag in conjunction with signal_conf_ph to identify those photons that are likely noise or likely signal
night_flag Flag indicating the data were acquired in night conditions: 0=day, 1=night. Night flag is set when solar elevation is below 0.0 degrees.
Returns an S4 object of class data.table::data.table
containing the ATL03 photons attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# 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 photons attributes atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5) head(atl03_photons_dt) close(atl03_h5)
# 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 photons attributes atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5) head(atl03_photons_dt) close(atl03_h5)
This function clips ATL03 photons attributes within a given bounding coordinates
ATL03_photons_attributes_dt_clipBox( atl03_photons_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat )
ATL03_photons_attributes_dt_clipBox( atl03_photons_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat )
atl03_photons_dt |
A atl03_photons_dt object (output of |
lower_left_lon |
Numeric. West longitude (x) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lon |
Numeric. East longitude (x) coordinate of bounding rectangle, in decimal degrees. |
lower_left_lat |
Numeric. South latitude (y) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lat |
Numeric. North latitude (y) coordinate of bounding rectangle, in decimal degrees. |
Returns an S4 object of class icesat2.atl03_dt
containing the ATL03 photons attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# 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 photons attributes atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5) # Bounding rectangle coordinates lower_left_lon <- -106.57 lower_left_lat <- 41.53 upper_right_lon <- -106.5698 upper_right_lat <- 41.54 # Clipping ATL08-derived canopy metrics by boundary box extent atl03_photons_dt_clip <- ATL03_photons_attributes_dt_clipBox( atl03_photons_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat ) head(atl03_photons_dt_clip) close(atl03_h5)
# 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 photons attributes atl03_photons_dt <- ATL03_photons_attributes_dt(atl03_h5 = atl03_h5) # Bounding rectangle coordinates lower_left_lon <- -106.57 lower_left_lat <- 41.53 upper_right_lon <- -106.5698 upper_right_lat <- 41.54 # Clipping ATL08-derived canopy metrics by boundary box extent atl03_photons_dt_clip <- ATL03_photons_attributes_dt_clipBox( atl03_photons_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat ) head(atl03_photons_dt_clip) close(atl03_h5)
This function clips ATL03 photon attributes within given bounding coordinates.
ATL03_photons_attributes_dt_clipGeometry( atl03_photons_dt, sppoly, split_by = "id" )
ATL03_photons_attributes_dt_clipGeometry( atl03_photons_dt, sppoly, split_by = "id" )
atl03_photons_dt |
An ATL03 photon data table. An S4 object of class |
sppoly |
Spatial Polygon. An object of class |
split_by |
Polygon id. If defined, GEDI data will be clipped by each polygon using the polygon id from the attribute table defined by the user. |
Returns an S4 object of class icesat2.atl03_dt
containing the ATL03 photon attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# 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 polygon_filepath <- system.file( "extdata", "clip_geom.shp", package = "ICESat2VegR" ) # Reading shapefile as sf object sppoly <- terra::vect(polygon_filepath) # Clipping ATL03 photon attributes by Geometry atl03_photons_dt_clip <- ATL03_photons_attributes_dt_clipGeometry(atl03_photons_dt, sppoly, split_by = "id") head(atl03_photons_dt_clip) close(atl03_h5)
# 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 polygon_filepath <- system.file( "extdata", "clip_geom.shp", package = "ICESat2VegR" ) # Reading shapefile as sf object sppoly <- terra::vect(polygon_filepath) # Clipping ATL03 photon attributes by Geometry atl03_photons_dt_clip <- ATL03_photons_attributes_dt_clipGeometry(atl03_photons_dt, sppoly, split_by = "id") head(atl03_photons_dt_clip) close(atl03_h5)
Converts ATL03 photon cloud to LAS
ATL03_photons_attributes_dt_LAS(atl03_dt, output)
ATL03_photons_attributes_dt_LAS(atl03_dt, output)
atl03_dt |
An S4 object of class |
output |
character. The output path of for the LAS(Z) file(s) The function will create one LAS file per UTM Zone in WGS84 datum. |
As the las format expects a metric coordinate reference system (CRS) we use helper functions to define UTM zones to which the original ICESat-2 data will be converted.
The function credits go to Chuck Gantz- [email protected].
Nothing, it just saves outputs as LAS file in disk
https://oceancolor.gsfc.nasa.gov/docs/ocssw/LatLong-UTMconversion_8cpp_source.html
# 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 and ATL08 photons and heights atl03_dt <- ATL03_photons_attributes_dt(atl03_h5, beam = "gt1r") outdir <- tempdir() ATL03_photons_attributes_dt_LAS( atl03_dt, file.path(outdir, "output.laz") ) close(atl03_h5)
# 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 and ATL08 photons and heights atl03_dt <- ATL03_photons_attributes_dt(atl03_h5, beam = "gt1r") outdir <- tempdir() ATL03_photons_attributes_dt_LAS( atl03_dt, file.path(outdir, "output.laz") ) close(atl03_h5)
This function reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) as h5 file.
ATL03_photons_plot(atl08_path)
ATL03_photons_plot(atl08_path)
atl08_path |
File path pointing to ICESat-2 ATL08 data. Data in HDF5 Hierarchical Data Format (.h5). |
Returns an S4 object of class icesat2.atl08_dt
containing ICESat-2 ATL08 data.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This function reads the ICESat-2 Global Geolocated Photons (ATL03) Product (ATL03) as h5 file.
ATL03_read(atl03_path) ## S4 method for signature 'ANY' ATL03_read(atl03_path) ## S4 method for signature 'icesat2.granule_cloud' ATL03_read(atl03_path)
ATL03_read(atl03_path) ## S4 method for signature 'ANY' ATL03_read(atl03_path) ## S4 method for signature 'icesat2.granule_cloud' ATL03_read(atl03_path)
atl03_path |
An object of class |
Returns an S4 object of class icesat2.atl03_dt
containing ICESat-2 ATL03 data.
An S4 object of class icesat2.atl03_h5
containing ICESat-2 ATL03 data.
An S4 object of class icesat2.atl03_h5
containing ICESat-2 ATL03 data.
ATL03_read(ANY)
: Method for reading ICESat-2 ATL03 data from a local h5 file.
ATL03_read(icesat2.granule_cloud)
: Method for reading ICESat-2 ATL03 data from a cloud granule.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# Specifying the path to ATL03 file atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL03 data (h5 file) ATL03 <- ATL03_read(atl03_path = atl03_path) close(ATL03)
# Specifying the path to ATL03 file atl03_path <- system.file("extdata", "atl03_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL03 data (h5 file) ATL03 <- ATL03_read(atl03_path = atl03_path) close(ATL03)
This function extracts segment attributes from ICESat-2 ATL03 data
ATL03_seg_attributes_dt( atl03_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), attributes = c("h_ph", "altitude_sc", "bounce_time_offset", "delta_time", "full_sat_fract", "near_sat_fract", "neutat_delay_derivative", "neutat_delay_total", "neutat_ht", "ph_index_beg", "pitch", "podppd_flag", "range_bias_corr", "ref_azimuth", "ref_elev", "reference_photon_index", "roll", "segment_dist_x", "segment_id", "segment_length", "segment_ph_cnt", "sigma_across", "sigma_along", "sigma_h", "sigma_lat", "sigma_lon", "solar_azimuth", "solar_elevation", "surf_type", "tx_pulse_energy", "tx_pulse_skew_est", "tx_pulse_width_lower", "tx_pulse_width_upper", "yaw") )
ATL03_seg_attributes_dt( atl03_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), attributes = c("h_ph", "altitude_sc", "bounce_time_offset", "delta_time", "full_sat_fract", "near_sat_fract", "neutat_delay_derivative", "neutat_delay_total", "neutat_ht", "ph_index_beg", "pitch", "podppd_flag", "range_bias_corr", "ref_azimuth", "ref_elev", "reference_photon_index", "roll", "segment_dist_x", "segment_id", "segment_length", "segment_ph_cnt", "sigma_across", "sigma_along", "sigma_h", "sigma_lat", "sigma_lon", "solar_azimuth", "solar_elevation", "surf_type", "tx_pulse_energy", "tx_pulse_skew_est", "tx_pulse_width_lower", "tx_pulse_width_upper", "yaw") )
atl03_h5 |
A ICESat-2 ATL03 object (output of |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
attributes |
Character vector indicating the attrivutes |
These are the available variables for extraction:
h_ph
: Height of the reference photon above the WGS84 ellipsoid.
altitude_sc
: Height of the spacecraft above the WGS84 ellipsoid.
bounce_time_offset
: The difference between the transmit time and the ground bounce time of the reference photons.
delta_time
: Transmit time of the reference photon, measured in seconds from the atlas_sdp_gps_epoch.
full_sat_fract
: The fraction of pulses within the segment determined to be fully saturated.
near_sat_fract
: The fraction of pulses within the segment determined to be nearly saturated.
neutat_delay_derivative
: Change in neutral atmospheric delay per height change.
neutat_delay_total
: Total neutral atmosphere delay correction (wet+dry).
neutat_ht
: Reference height of the neutral atmosphere range correction.
ph_index_beg
: Index (1-based) within the photon-rate data of the first photon within this segment.
pitch
: Spacecraft pitch, computed using a 3, 2, 1 Euler angle sequence, with units in degrees.
podppd_flag
: A composite flag indicating the quality of input geolocation products for the specific ATL03 segment.
range_bias_corr
: The estimated range bias from geolocation analysis.
ref_azimuth
: Azimuth of the unit pointing vector for the reference photon in the local ENU frame, in radians.
ref_elev
: Elevation of the unit pointing vector for the reference photon in the local ENU frame, in radians.
reference_photon_index
: Index of the reference photon within the set of photons grouped within a segment.
reference_photon_lat
: Latitude of each reference photon.
reference_photon_lon
: Longitude of each reference photon.
roll
: Spacecraft roll, computed using a 3, 2, 1 Euler angle sequence, with units in degrees.
segment_dist_x
: Along-track distance from the equator crossing to the start of the 20 meter geolocation segment.
segment_id
: A 7-digit number identifying the along-track geolocation segment number.
segment_length
: The along-track length of the along-track segment, typically 20 meters.
segment_ph_cnt
: Number of photons in a given along-track segment.
sigma_across
: Estimated Cartesian across-track uncertainty (1-sigma) for the reference photon.
sigma_along
: Estimated cartesian along-track uncertainty (1-sigma) for the reference photon.
sigma_h
: Estimated height uncertainty (1-sigma) for the reference photon bounce point.
sigma_lat
: Estimated geodetic Latitude uncertainty (1-sigma) for the reference photon bounce point.
sigma_lon
: Estimated geodetic Longitude uncertainty (1-sigma) for the reference photon bounce point.
solar_azimuth
: Azimuth of the sun position vector from the reference photon bounce point position in
the local ENU frame, in degrees east.
solar_elevation
: Elevation of the sun position vector from the reference photon bounce point
position in the local ENU frame, in degrees.
surf_type
: Flags describing which surface types an interval is associated with (e.g., land,
ocean, sea ice, land ice, inland water).
tx_pulse_energy
: Average transmit pulse energy, measured by the internal laser energy monitor,
split into per-beam measurements.
tx_pulse_skew_est
: Difference between the averages of the lower and upper threshold crossing times,
estimating the transmit pulse skew.
tx_pulse_width_lower
: Average distance between the lower threshold crossing times measured by the
Start Pulse Detector.
tx_pulse_width_upper
: Average distance between the upper threshold crossing times measured by the
Start Pulse Detector.
velocity_sc
: Spacecraft velocity components (east component, north component, up component)
an observer on the ground would measure.
yaw
: Spacecraft yaw, computed using a 3, 2, 1 Euler angle sequence, with units in degrees.
Returns an S4 object of class data.table::data.table containing the ATL03 segment attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# 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 segment attributes atl03_segment_dt <- ATL03_seg_attributes_dt(atl03_h5 = atl03_h5) head(atl03_segment_dt) close(atl03_h5)
# 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 segment attributes atl03_segment_dt <- ATL03_seg_attributes_dt(atl03_h5 = atl03_h5) head(atl03_segment_dt) close(atl03_h5)
This function reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) as h5 file.
ATL08_attributes_dt_LAS(atl08_path)
ATL08_attributes_dt_LAS(atl08_path)
atl08_path |
File path pointing to ICESat-2 ATL08 data. Data in HDF5 Hierarchical Data Format (.h5). |
Returns an S4 object of class icesat2.atl08_dt
containing ICESat-2 ATL08 data.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# ATL08 file path atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This function clips the ATl08 HDF5 file. This function will only clip the beam groups within hdf5, it won't change metadata or ancillary data.
ATL08_h5_clipBox( atl08, output, bbox, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
ATL08_h5_clipBox( atl08, output, bbox, beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
atl08 |
|
output |
character. Path to the output h5 file. |
bbox |
|
beam |
|
additional_groups |
|
Returns the clipped S4 object of class icesat2.atl08_h5
# 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) # Bounding rectangle coordinates ul_lon <- -106.5723 lr_lon <- -106.5693 lr_lat <- 41.533 ul_lat <- 41.537 # Clipping ATL08 terrain and canopy attributes by boundary box atl08_seg_att_dt_clip <- ATL08_h5_clipBox( atl08_h5, output = tempfile(fileext = ".h5"), c(ul_lat, ul_lon, lr_lat, lr_lon) ) close(atl08_h5) close(atl08_seg_att_dt_clip)
# 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) # Bounding rectangle coordinates ul_lon <- -106.5723 lr_lon <- -106.5693 lr_lat <- 41.533 ul_lat <- 41.537 # Clipping ATL08 terrain and canopy attributes by boundary box atl08_seg_att_dt_clip <- ATL08_h5_clipBox( atl08_h5, output = tempfile(fileext = ".h5"), c(ul_lat, ul_lon, lr_lat, lr_lon) ) close(atl08_h5) close(atl08_seg_att_dt_clip)
This function clips ATL08 HDF5 file within beam groups, but keeps metada and ancillary data the same.
ATL08_h5_clipGeometry( atl08, output, vect, polygon_id = "id", beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
ATL08_h5_clipGeometry( atl08, output, vect, polygon_id = "id", beam = c("gt1r", "gt2r", "gt3r", "gt1l", "gt2l", "gt3l"), additional_groups = c("orbit_info") )
atl08 |
|
output |
character. Path to the output h5 file. |
vect |
|
polygon_id |
|
beam |
|
additional_groups |
|
Returns a list of clipped S4 object of class icesat2.atl08_h5
# 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" ) vect <- terra::vect(vect_path) # Clipping ATL08 photons by boundary box extent atl08_photons_dt_clip <- ATL08_h5_clipGeometry( atl08_h5, output, vect, polygon_id = "id" ) close(atl08_h5)
# 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" ) vect <- terra::vect(vect_path) # Clipping ATL08 photons by boundary box extent atl08_photons_dt_clip <- ATL08_h5_clipGeometry( atl08_h5, output, vect, polygon_id = "id" ) close(atl08_h5)
This function extracts computed photons attributes from ICESat-2 ATL08 data
ATL08_photons_attributes_dt( atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), photon_attributes = c("ph_segment_id", "classed_pc_indx", "classed_pc_flag", "ph_h", "d_flag", "delta_time") )
ATL08_photons_attributes_dt( atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), photon_attributes = c("ph_segment_id", "classed_pc_indx", "classed_pc_flag", "ph_h", "d_flag", "delta_time") )
atl08_h5 |
A ICESat-2 ATL08 object (output of |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
photon_attributes |
character vector indicating the attributes to extract from the ATL08 photons.
Default all |
These are the photons attributes extracted by default:
ph_segment_id: Georeferenced bin number (20-m) associated with each photon
classed_pc_indx: Indices of photons tracking back to ATL03 that surface finding software identified and used within the creation of the data products.
classed_pc_flag: The L2B algorithm is run if this flag is set to 1 indicating data have sufficient waveform fidelity for L2B to run
ph_h: Height of photon above interpolated ground surface
d_flag: Flag indicating whether DRAGANN labeled the photon as noise or signal
delta_time: Mid-segment GPS time in seconds past an epoch. The epoch is provided in the metadata at the file level
Returns an S4 object of class data.table::data.table containing the ATL08 computed photons attributes.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# 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)
# 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)
This function reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) as h5 file.
ATL08_read(atl08_path)
ATL08_read(atl08_path)
atl08_path |
File path pointing to ICESat-2 ATL08 data. Data in HDF5 Hierarchical Data Format (.h5). |
Returns an S4 object of class icesat2.atl08_h5
containing ICESat-2 ATL08 data.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This method reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) from a local HDF5 file.
## S4 method for signature 'character' ATL08_read(atl08_path)
## S4 method for signature 'character' ATL08_read(atl08_path)
atl08_path |
Character. File path pointing to ICESat-2 ATL08 data in HDF5 format (.h5). |
Returns an S4 object of class icesat2.atl08_h5
containing ICESat-2 ATL08 data.
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This method reads the ICESat-2 Land and Vegetation Along-Track Products (ATL08) from a single granule in the cloud.
## S4 method for signature 'icesat2.granule_cloud' ATL08_read(atl08_path)
## S4 method for signature 'icesat2.granule_cloud' ATL08_read(atl08_path)
atl08_path |
Object of class |
Returns an S4 object of class icesat2.atl08_h5
containing ICESat-2 ATL08 data.
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This method stops the process when multiple granules are provided.
## S4 method for signature 'icesat2.granules_cloud' ATL08_read(atl08_path)
## S4 method for signature 'icesat2.granules_cloud' ATL08_read(atl08_path)
atl08_path |
Object of class |
This method stops execution with an error message indicating that the package works with only one granule at a time.
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
# Specifying the path to ATL08 file atl08_path <- system.file("extdata", "atl08_clip.h5", package = "ICESat2VegR" ) # Reading ICESat-2 ATL08 data (h5 file) atl08 <- ATL08_read(atl08_path = atl08_path) close(atl08)
This function extracts terrain and canopy attributes by segments from ICESat-2 ATL08 data
ATL08_seg_attributes_dt( atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), attributes = c("delta_time", "h_canopy", "canopy_openness", "h_te_mean", "terrain_slope") )
ATL08_seg_attributes_dt( atl08_h5, beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), attributes = c("delta_time", "h_canopy", "canopy_openness", "h_te_mean", "terrain_slope") )
atl08_h5 |
A ICESat-2 ATL08 object (output of |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
attributes |
A character vector containing the list of terrain and canopy attributes to be extracted. Default is attribute = c("h_canopy","canopy_h_metrics","canopy_openness","h_te_mean","h_te_median","terrain_slope") |
ATL08 canopy attributes:
"h_canopy"
"canopy_rh_conf"
"h_median_canopy_abs"
"h_min_canopy"
"h_mean_canopy_abs"
"h_median_canopy"
"h_canopy_abs"
"toc_roughness"
"h_min_canopy_abs"
"h_dif_canopy"
"h_canopy_quad"
"h_canopy_20m"
"n_ca_photons"
"photon_rate_can"
"centroid_height"
"canopy_h_metrics_abs"
"h_mean_canopy"
"subset_can_flag"
"canopy_h_metrics"
"n_toc_photons"
"h_max_canopy_abs"
"h_canopy_uncertainty"
"canopy_openness"
"h_max_canopy"
"segment_cover"
ATL08 terrain attributes:
"h_te_best_fit"
"h_te_best_fit_20m"
"h_te_interp"
"h_te_max"
"h_te_mean"
"h_te_median"
"h_te_mode"
"h_te_rh25"
"h_te_skew"
"h_te_std"
"h_te_uncertainty"
"n_te_photons"
"photon_rate_te"
"subset_te_flag"
"terrain_slope"
Returns an S4 object of class icesat2.atl08_dt
containing the ATL08-derived terrain and canopy attributes by segments.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
# 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)
# 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)
This function clips ATL08 Terrain and Canopy Attributes within a given bounding box coordinates
ATL08_seg_attributes_dt_clipBox( atl08_seg_att_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat )
ATL08_seg_attributes_dt_clipBox( atl08_seg_att_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat )
atl08_seg_att_dt |
A atl08_seg_att_dt object (output of
|
lower_left_lon |
Numeric. West longitude (x) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lon |
Numeric. East longitude (x) coordinate of bounding rectangle, in decimal degrees. |
lower_left_lat |
Numeric. South latitude (y) coordinate of bounding rectangle, in decimal degrees. |
upper_right_lat |
Numeric. North latitude (y) coordinate of bounding rectangle, in decimal degrees. |
Returns an S4 object of class icesat2.atl08_dt
containing the clipped ATL08 terrain and canopy attributes.
# 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-derived Canopy Metrics atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5) # Bounding rectangle coordinates lower_left_lon <- -103.7604 lower_left_lat <- 59.4672 upper_right_lon <- -103.7600 upper_right_lat <- 59.4680 # Clipping ATL08 terrain and canopy attributes by boundary box atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipBox( atl08_seg_att_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat ) close(atl08_h5)
# 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-derived Canopy Metrics atl08_seg_att_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5) # Bounding rectangle coordinates lower_left_lon <- -103.7604 lower_left_lat <- 59.4672 upper_right_lon <- -103.7600 upper_right_lat <- 59.4680 # Clipping ATL08 terrain and canopy attributes by boundary box atl08_seg_att_dt_clip <- ATL08_seg_attributes_dt_clipBox( atl08_seg_att_dt, lower_left_lon, upper_right_lon, lower_left_lat, upper_right_lat ) close(atl08_h5)
This function clips ATL08 Terrain and Canopy Attributes within a given geometry
ATL08_seg_attributes_dt_clipGeometry( atl08_seg_att_dt, polygon, split_by = NULL )
ATL08_seg_attributes_dt_clipGeometry( atl08_seg_att_dt, polygon, split_by = NULL )
atl08_seg_att_dt |
A atl08_seg_att_dt object (output of
|
polygon |
Polygon. An object of class |
split_by |
Polygon id. If defined, ATL08 data will be clipped by each polygon using the polygon id from table of attribute defined by the user |
Returns an S4 object of class icesat2.atl08_dt
containing the clipped ATL08 Terrain and Canopy Attributes.
# 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) polygon_path <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR" ) if (require(terra)) { polygon <- terra::vect(polygon_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)
# 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) polygon_path <- system.file("extdata", "clip_geom.shp", package = "ICESat2VegR" ) if (require(terra)) { polygon <- terra::vect(polygon_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)
This function computes a series of user defined descriptive statistics within each grid cell for ATL08 Terrain and Canopy Attributes
ATL08_seg_attributes_dt_gridStat(atl08_seg_att_dt, func, res = 0.5)
ATL08_seg_attributes_dt_gridStat(atl08_seg_att_dt, func, res = 0.5)
atl08_seg_att_dt |
An S4 object of class
|
func |
The function to be applied for computing the defined statistics |
res |
Spatial resolution in decimal degrees for the output SpatRast raster layer. Default is 0.5. |
Return a SpatRast raster layer(s) of selected ATL08 terrain and canopy attribute(s)
# 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 the top h_canopy at 0.05 degree grid cell res <- 0.0001 mean_h_canopy <- ATL08_seg_attributes_dt_gridStat( atl08_seg_att_dt, func = mean(h_canopy), res = res ) plot(mean_h_canopy) # Define your own function mySetOfMetrics <- function(x) { metrics <- list( min = min(x, na.rm = TRUE), # Min of x max = max(x, na.rm = TRUE), # Max of x mean = mean(x, na.rm = TRUE), # Mean of x sd = sd(x, na.rm = TRUE) # Sd of x ) return(metrics) } res <- 0.05 # Computing h_canopy statistics at 0.05 degree grid cell from user-defined function h_canopy_metrics <- ATL08_seg_attributes_dt_gridStat( atl08_seg_att_dt, func = mySetOfMetrics(h_canopy), res = res ) plot(h_canopy_metrics) close(atl08_h5)
# 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 the top h_canopy at 0.05 degree grid cell res <- 0.0001 mean_h_canopy <- ATL08_seg_attributes_dt_gridStat( atl08_seg_att_dt, func = mean(h_canopy), res = res ) plot(mean_h_canopy) # Define your own function mySetOfMetrics <- function(x) { metrics <- list( min = min(x, na.rm = TRUE), # Min of x max = max(x, na.rm = TRUE), # Max of x mean = mean(x, na.rm = TRUE), # Mean of x sd = sd(x, na.rm = TRUE) # Sd of x ) return(metrics) } res <- 0.05 # Computing h_canopy statistics at 0.05 degree grid cell from user-defined function h_canopy_metrics <- ATL08_seg_attributes_dt_gridStat( atl08_seg_att_dt, func = mySetOfMetrics(h_canopy), res = res ) plot(h_canopy_metrics) close(atl08_h5)
Converts ATL08 segments to LAS
ATL08_seg_attributes_dt_LAS(atl08_dt, output)
ATL08_seg_attributes_dt_LAS(atl08_dt, output)
atl08_dt |
An S4 object of class |
output |
character. The output path of for the LAS(Z) file(s) The function will create one LAS file per UTM Zone in WGS84 datum. |
As the las format expects a metric coordinate reference system (CRS) we use helper functions to define UTM zones to which the original ICESat-2 data will be converted.
The function credits go to Chuck Gantz- [email protected].
Nothing, it just saves outputs as LAS file in disk
https://oceancolor.gsfc.nasa.gov/docs/ocssw/LatLong-UTMconversion_8cpp_source.html
# 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 ATL03 and ATL08 photons and heights atl08_dt <- ATL08_seg_attributes_dt(atl08_h5) outputLaz <- tempfile(fileext = ".laz") ATL08_seg_attributes_dt_LAS( atl08_dt, outputLaz ) close(atl08_h5)
# 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 ATL03 and ATL08 photons and heights atl08_dt <- ATL08_seg_attributes_dt(atl08_h5) outputLaz <- tempfile(fileext = ".laz") ATL08_seg_attributes_dt_LAS( atl08_dt, outputLaz ) close(atl08_h5)
Computes a series of statistics of ATL08 terrain and canopy attributes within area defined by a polygon
ATL08_seg_attributes_dt_polyStat(atl08_seg_att_dt, func, poly_id = NULL)
ATL08_seg_attributes_dt_polyStat(atl08_seg_att_dt, func, poly_id = NULL)
atl08_seg_att_dt |
An S4 object of class
|
func |
The function to be applied for computing the defined statistics |
poly_id |
Polygon id. If defined, statistics will be computed for each polygon |
Returns an S4 object of class icesat2.atl08_dt
Containing Statistics of ATL08 terrain and canopy attributes
# 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)
# 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)
This function will read multiple ATL08 H5 files and create a stack of raster layers: count, and 1st, 2nd, 3rd and 4th moments (count, m1, m2, m3 and m4) for each metric selected, from which we can calculate statistics such as Mean, SD, Skewness and Kurtosis.
ATL08_seg_attributes_h5_gridStat( atl08_dir, metrics = c("h_canopy", "canopy_rh_conf", "h_median_canopy_abs", "h_min_canopy", "h_mean_canopy_abs", "h_median_canopy", "h_canopy_abs", "toc_roughness", "h_min_canopy_abs", "h_dif_canopy", "h_canopy_quad", "h_canopy_20m", "n_ca_photons", "photon_rate_can", "centroid_height", "canopy_h_metrics_abs", "h_mean_canopy", "subset_can_flag", "canopy_h_metrics", "n_toc_photons", "h_max_canopy_abs", "h_canopy_uncertainty", "canopy_openness", "h_max_canopy", "segment_cover"), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), out_root, ul_lat, ul_lon, lr_lat, lr_lon, res, creation_options = def_co, agg_function = default_agg_function, agg_join = default_agg_join, finalizer = default_finalizer )
ATL08_seg_attributes_h5_gridStat( atl08_dir, metrics = c("h_canopy", "canopy_rh_conf", "h_median_canopy_abs", "h_min_canopy", "h_mean_canopy_abs", "h_median_canopy", "h_canopy_abs", "toc_roughness", "h_min_canopy_abs", "h_dif_canopy", "h_canopy_quad", "h_canopy_20m", "n_ca_photons", "photon_rate_can", "centroid_height", "canopy_h_metrics_abs", "h_mean_canopy", "subset_can_flag", "canopy_h_metrics", "n_toc_photons", "h_max_canopy_abs", "h_canopy_uncertainty", "canopy_openness", "h_max_canopy", "segment_cover"), beam = c("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"), out_root, ul_lat, ul_lon, lr_lat, lr_lon, res, creation_options = def_co, agg_function = default_agg_function, agg_join = default_agg_join, finalizer = default_finalizer )
atl08_dir |
CharacterVector. The directory paths where the ATL08 H5 files are stored; |
metrics |
CharacterVector. A vector of canopy attributes available from ATL08 product (e.g. "h_canopy") |
beam |
Character vector indicating beams to process (e.g. "gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r") |
out_root |
Character. The root name for the raster output files, the pattern is {out_root}{metric}{count/m1/m2}.tif. This should include the full path for the file. |
ul_lat |
Numeric. Upper left latitude for the bounding box |
ul_lon |
Numeric. Upper left longitude for the bounding box |
lr_lat |
Numeric. Lower right latitude for the bounding box |
lr_lon |
Numeric. Lower right longitude for the bounding box |
res |
NumericVector. Resolution lon lat for the output raster in coordinates decimal degrees |
creation_options |
CharacterVector. The GDAL creation options for the tif file. Default c("COMPRESS=PACKBITS", "BIGTIFF=IF_SAFER", "TILED=YES", "BLOCKXSIZE=512", "BLOCKYSIZE=512") will create BIGTIFF if needed, with DEFLATE compression and tiled by 512x512 pixels. |
agg_function |
Formula function-like. An aggregate function which should return a data.table with the aggregate statistics |
agg_join |
Function. A function to merge two different agg objects. |
finalizer |
List<name, formula>. A list with the final raster names and the formula which uses the base statistics. |
This function will create five different aggregate statistics (n, mean, variance, min, max). One can calculate mean and standard deviation with the following formulas according to Terriberry (2007) and Joanes and Gill (1998):
The agg_function
is a formula which return a data.table with the
aggregate function to perform over the data.
The default is:
~data.table( n = length(x), mean = mean(x,na.rm = TRUE), var = var(x) * (length(x) - 1), min = min(x, na.rm=T), max = max(x, na.rm=T) )
The agg_join
is a function to merge two data.table aggregates
from the agg_function
. Since the h5 files will be aggregated
one by one, the statistics from the different h5 files should
have a function to merge them. The default function is:
function(x1, x2) { combined = data.table() x1$n[is.na(x1$n)] = 0 x1$mean[is.na(x1$mean)] = 0 x1$variance[is.na(x1$variance)] = 0 x1$max[is.na(x1$max)] = -Inf x1$min[is.na(x1$min)] = Inf combined$n = x1$n + x2$n delta = x2$mean - x1$mean delta2 = delta * delta combined$mean = (x1$n * x1$mean + x2$n * x2$mean) / combined$n combined$variance = x1$variance + x2$variance + delta2 * x1$n * x2$n / combined$n combined$min = pmin(x1$min, x2$min, na.rm=F) combined$max = pmax(x1$max, x2$max, na.rm=F) return(combined) }
The finalizer
is a list of formulas to generate the final
rasters based on the intermediate statistics from the previous
functions. The default finalizer
will calculate the sd
,
skewness
and kurtosis
based on the variance
, M3
, M4
and n
values. It is defined as:
list( sd = ~sqrt(variance/(n - 1)), )
Nothing. It outputs multiple raster tif files to the out_root specified path.
Joanes DN, Gill CA (1998). “Comparing measures of sample skewness and kurtosis.” Journal of the Royal Statistical Society: Series D (The Statistician), 47(1), 183–189. doi:10.1111/1467-9884.00122.
Terriberry, Timothy B. (2007), Computing Higher-Order Moments Online, archived from the original on 23 April 2014, retrieved 5 May 2008
# Specifying the path to GEDI leveatl08_canopy_dt data (zip file) library(ICESat2VegR) library(data.table) # 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) # Bounding rectangle coordinates ul_lat <- 41.5386848449707031 ul_lon <- -106.5708541870117188 lr_lat <- 41.5314979553222656 lr_lon <- -106.5699081420898438 res <- 100 # meters lat_to_met_factor <- 1 / 110540 lon_to_met_factor <- 1 / 111320 xres <- lon_to_met_factor * res yres <- lat_to_met_factor * res agg_function <- ~ data.table( min = min(x), max = max(x), sum = sum(x), n = length(x) ) agg_join <- function(agg1, agg2) { agg1[is.na(agg1)] <- 0 data.table( min = pmin(agg1$min, agg2$min), max = pmax(agg1$max, agg2$max), sum = agg1$sum + agg2$sum, n = agg1$n + agg2$n ) } finalizer <- list( mean = "sum/n", range = "max-min" ) outdir <- tempdir() gc() file.remove(list.files(outdir, "*.tif")) close(atl08_h5)
# Specifying the path to GEDI leveatl08_canopy_dt data (zip file) library(ICESat2VegR) library(data.table) # 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) # Bounding rectangle coordinates ul_lat <- 41.5386848449707031 ul_lon <- -106.5708541870117188 lr_lat <- 41.5314979553222656 lr_lon <- -106.5699081420898438 res <- 100 # meters lat_to_met_factor <- 1 / 110540 lon_to_met_factor <- 1 / 111320 xres <- lon_to_met_factor * res yres <- lat_to_met_factor * res agg_function <- ~ data.table( min = min(x), max = max(x), sum = sum(x), n = length(x) ) agg_join <- function(agg1, agg2) { agg1[is.na(agg1)] <- 0 data.table( min = pmin(agg1$min, agg2$min), max = pmax(agg1$max, agg2$max), sum = agg1$sum + agg2$sum, n = agg1$n + agg2$n ) } finalizer <- list( mean = "sum/n", range = "max-min" ) outdir <- tempdir() gc() file.remove(list.files(outdir, "*.tif")) close(atl08_h5)
Download ICESat-2 ATL03 and ALT08 data from LP DAAC Data Pool. Users will need to enter their Earth Explore login Information for downloading the data.
ATLAS_dataDownload( url, outdir = NULL, overwrite = FALSE, buffer_size = 512, timeout = 10 )
ATLAS_dataDownload( url, outdir = NULL, overwrite = FALSE, buffer_size = 512, timeout = 10 )
url |
character vector object; url to ATL03 or ALT08 data, or both (output of |
outdir |
Vector object, output directory for downloading GEDI data, default |
overwrite |
logical; overwrite file if they already exists in destination, default FALSE |
buffer_size |
integer; the size of download chunk in KB to hold in memory before writing to file, default 512. |
timeout |
integer; connection timeout in seconds. |
No return value on success, on failure it will stop()
Credits to Cole Krehbiel. Code adapted from https://git.earthdata.nasa.gov/projects/LPDUR/repos/daac_data_download_r/browse/DAACDataDownload.R
## Not run: # Set path to ICESat-2 data # herein we will only download xml metedata base_path <- "https://data.nsidc.earthdatacloud.nasa.gov/nsidc-cumulus-prod-protected" url <- c( paste0(base_path, "/ATLAS/ATL08/006/2019/07/13/ATL08_20190713210015_02410406_006_02.h5"), paste0(base_path, "/ATLAS/ATL08/006/2019/07/15/ATL08_20190715084425_02640402_006_02.h5") ) # Set dir to download files to outdir <- tempdir() # Create .netrc file netrc <- file.path(outdir, ".netrc") netrc_conn <- file(netrc) # Assuming login data is saved in the # environmental variables EARTHDATA_USERNAME and EARTHDATA_PASSWORD writeLines(c( "machine urs.earthdata.nasa.gov", sprintf("login %s", Sys.getenv("EARTHDATA_USERNAME")), sprintf("password %s", Sys.getenv("EARTHDATA_PASSWORD")) ), netrc_conn) close(netrc_conn) #' Downloading ICEsat-2 data ATLAS_dataDownload(url, outdir) ## End(Not run)
## Not run: # Set path to ICESat-2 data # herein we will only download xml metedata base_path <- "https://data.nsidc.earthdatacloud.nasa.gov/nsidc-cumulus-prod-protected" url <- c( paste0(base_path, "/ATLAS/ATL08/006/2019/07/13/ATL08_20190713210015_02410406_006_02.h5"), paste0(base_path, "/ATLAS/ATL08/006/2019/07/15/ATL08_20190715084425_02640402_006_02.h5") ) # Set dir to download files to outdir <- tempdir() # Create .netrc file netrc <- file.path(outdir, ".netrc") netrc_conn <- file(netrc) # Assuming login data is saved in the # environmental variables EARTHDATA_USERNAME and EARTHDATA_PASSWORD writeLines(c( "machine urs.earthdata.nasa.gov", sprintf("login %s", Sys.getenv("EARTHDATA_USERNAME")), sprintf("password %s", Sys.getenv("EARTHDATA_PASSWORD")) ), netrc_conn) close(netrc_conn) #' Downloading ICEsat-2 data ATLAS_dataDownload(url, outdir) ## End(Not run)
This function finds the exact granule(s) that contain ICESat-2 ATLAS data for a given region of interest and date range
ATLAS_dataFinder( short_name, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, version = "006", daterange = NULL, persist = TRUE, cloud_hosted = TRUE, cloud_computing = FALSE )
ATLAS_dataFinder( short_name, lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, version = "006", daterange = NULL, persist = TRUE, cloud_hosted = TRUE, cloud_computing = FALSE )
short_name |
ICESat-2 ATLAS data level short_name; Options: "ATL03", "ATL08", |
lower_left_lon |
Numeric. Minimum longitude in (decimal degrees) for the bounding box of the area of interest. |
lower_left_lat |
Numeric. Minimum latitude in (decimal degrees) for the bounding box of the area of interest. |
upper_right_lon |
Numeric. Maximum longitude in lon (decimal degrees) for the bounding box of the area of interest. |
upper_right_lat |
Numeric. Maximum latitude in (decimal degrees) for the bounding box of the area of interest. |
version |
Character. The version of the ICESat-2 ATLAS product files to be returned (only V005 or V006). Default "006". |
daterange |
Vector. Date range. Specify your start and end dates using ISO 8601 [YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]Z. Ex.: c("2019-07-01T00:00:00Z","2020-05-22T23:59:59Z"). If NULL (default), the date range filter will be not applied. |
persist |
Logical. If TRUE, it will create the .netrc |
cloud_hosted |
Logical. Flag to indicate use of cloud hosted collections.To be used when the cloud computing parameter is FALSE. |
cloud_computing |
Logical. If TRUE, it will return granules for cloud computing directly, otherwise it will return links to be passed in the function ATLAS_dataDownload for data download. |
Return either a vector object pointing out the path to ICESat-2 ATLAS data found within the boundary box coordinates provided for data download or a vector object containing the granules hosted on the cloud for cloud computing directly.
bbox: Defined by the upper left and lower right corner coordinates, in lat,lon ordering, for the bounding box of the area of interest (e.g. lower_left_lon,lower_left_lat,upper_right_lon,upper_right_lat)
This function relies on the existing CMR tool: https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html
# 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 ATLAS02b_list <- ATLAS_dataFinder( short_name = "ATL08", lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, version = "006", daterange = daterange )
# 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 ATLAS02b_list <- ATLAS_dataFinder( short_name = "ATL08", lower_left_lon, lower_left_lat, upper_right_lon, upper_right_lat, version = "006", daterange = daterange )
randomForest::randomForest()
model, transform to a Google Earth Engine randomForest modelGiven an R randomForest::randomForest()
model, transform to a Google Earth Engine randomForest model
build_ee_forest(rf)
build_ee_forest(rf)
rf |
the |
The Google Earth Engine classifier
This function clips ATL03 and ATL08 HDF5 file within beam groups, but keeps metada and ancillary data the same.
clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl03_h5,character,SpatExtent' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl03_h5,character,SpatVector' clip(x, output, clip_obj, polygon_id = "id", ...) ## S4 method for signature 'icesat2.atl03_h5,character,numeric' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,SpatExtent' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,numeric' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,SpatVector' clip(x, output, clip_obj, polygon_id, ...)
clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl03_h5,character,SpatExtent' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl03_h5,character,SpatVector' clip(x, output, clip_obj, polygon_id = "id", ...) ## S4 method for signature 'icesat2.atl03_h5,character,numeric' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,SpatExtent' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,numeric' clip(x, output, clip_obj, ...) ## S4 method for signature 'icesat2.atl08_h5,character,SpatVector' clip(x, output, clip_obj, polygon_id, ...)
x |
An |
output |
A character string specifying the path to the output H5 file. |
clip_obj |
A |
... |
Additional arguments passed to specific method implementation. |
polygon_id |
A character string specifying the ID of the polygon for clipping. |
Generic function for clipping ICESat-2 ATL03 and ATL08 H5 data.
Returns the clipped S4 object of the same class as the input file
Returns the clipped icesat2.atl03_h5
object.
Returns the clipped icesat2.atl03_h5
object.
Returns the clipped icesat2.atl08_h5
object.
Returns the clipped icesat2.atl08_h5
object.
Returns the clipped icesat2.atl08_h5
object.
clip(x = icesat2.atl03_h5, output = character, clip_obj = SpatExtent)
: Clips ATL03 data using a SpatExtent
.
clip(x = icesat2.atl03_h5, output = character, clip_obj = SpatVector)
: Clips ATL03 data using a SpatVector
.
This method clips ATL03 HDF5 data within beam groups using a terra::SpatVector
object,
but keeps metadata and ancillary data the same.
clip(x = icesat2.atl03_h5, output = character, clip_obj = numeric)
: Clips ATL03 data using numeric coordinates.
This method clips ATL03 HDF5 data within beam groups using numeric coordinates, but keeps metadata and ancillary data the same.
clip(x = icesat2.atl08_h5, output = character, clip_obj = SpatExtent)
: Clips ATL08 data using a SpatExtent
.
This method clips ATL08 HDF5 data within beam groups using a terra::SpatExtent
object,
but keeps metadata and ancillary data the same.
clip(x = icesat2.atl08_h5, output = character, clip_obj = numeric)
: Clips ATL08 data using numeric coordinates.
This method clips ATL08 HDF5 data within beam groups using numeric coordinates, but keeps metadata and ancillary data the same.
clip(x = icesat2.atl08_h5, output = character, clip_obj = SpatVector)
: Clips ATL08 data using a SpatVector
.
This method clips ATL08 HDF5 data within beam groups using a terra::SpatVector
object,
but keeps metadata and ancillary data the same.
ATL03_h5_clipBox()
, ATL03_h5_clipGeometry()
,
ATL08_h5_clipBox()
, ATL08_h5_clipGeometry()
# 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" ) vect <- terra::vect(vect_path) ext <- terra::ext(vect) # Clipping ATL08 photons by boundary box extent atl08_clip <- clip( atl08_h5, output, ext ) close(atl08_clip) # Clipping ATL08 photons by geometry atl08_clip_geom <- clip( atl08_h5, output, vect, polygon_id = "id" ) close(atl08_clip_geom, close)
# 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" ) vect <- terra::vect(vect_path) ext <- terra::ext(vect) # Clipping ATL08 photons by boundary box extent atl08_clip <- clip( atl08_h5, output, ext ) close(atl08_clip) # Clipping ATL08 photons by geometry atl08_clip_geom <- clip( atl08_h5, output, vect, polygon_id = "id" ) close(atl08_clip_geom, close)
Default clip method
## S4 method for signature 'ANY,ANY,ANY' clip(x, output, clip_obj, ...)
## S4 method for signature 'ANY,ANY,ANY' clip(x, output, clip_obj, ...)
x |
Maps to x1 from |
output |
Maps to x2 from |
clip_obj |
Maps to y1 from |
... |
Maps first element of list to y2 of |
clip(x = ANY, output = ANY, clip_obj = ANY)
: clip will dispatch to graphics::clip()
Closing files will avoid locking HDF5 ATL03 files.
## S4 method for signature 'icesat2.h5' close(con, ...)
## S4 method for signature 'icesat2.h5' close(con, ...)
con |
An object of class |
... |
Inherited from base |
Closing ensures the data is actually flushed (saved) to the dataset also it releases the lock from the file.
## S3 method for class 'GDALDataset' close(con, ...)
## S3 method for class 'GDALDataset' close(con, ...)
con |
GDALDataset to be closed. |
... |
not used, inherited from generic close function. |
Closes the HDF5 file pointer to release resources
## S3 method for class 'icesat2.predict_h5' close(con, ...)
## S3 method for class 'icesat2.predict_h5' close(con, ...)
con |
The HDF5 file pointer of class |
... |
Additional parameters inherited from generic |
Nothing, just closes the HDF5 file pointer
Create a new raster file based on specified data. It will output a *.tif file.
createDataset( raster_path, nbands, datatype, projstring, lr_lat, ul_lat, ul_lon, lr_lon, res, nodata, co = c("TILED=YES", "BLOCKXSIZE=512", "BLOCKYSIZE=512", "COMPRESSION=LZW") )
createDataset( raster_path, nbands, datatype, projstring, lr_lat, ul_lat, ul_lon, lr_lon, res, nodata, co = c("TILED=YES", "BLOCKXSIZE=512", "BLOCKYSIZE=512", "COMPRESSION=LZW") )
raster_path |
Character. The output path for the raster data |
nbands |
Integer. Number of bands. Default 1. |
datatype |
GDALDataType. The GDALDataType to use for the raster, use (GDALDataType$) to find the options. Default GDALDataType$GDT_Float64 |
projstring |
The projection string, either proj or WKT is accepted. |
lr_lat |
Numeric. The lower right latitude. |
ul_lat |
Numeric. The upper left latitude. |
ul_lon |
Numeric. The upper left longitude. |
lr_lon |
Numeric. The lower right longitude. |
res |
Numeric. The resolution of the output raster |
nodata |
Numeric. The no data value for the raster. Default 0. |
co |
CharacterVector. A CharacterVector of creation options for GDAL. Default NULL |
An object from GDALDataset R6 class.
# 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()
# 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()
earthaccess
python reticulate moduleThe pointer to the earthaccess
python reticulate module
earthaccess
earthaccess
An object of class python.builtin.module
(inherits from python.builtin.object
) of length 1.
Try logging in on earthaccess
earthaccess_login(persist = TRUE)
earthaccess_login(persist = TRUE)
persist |
Logical. If TRUE, it will persist the login credentials in .netrc file. |
Nothing, just try to login in earthaccess
# Try to login in NASA earthaccess # Shouldn't be tested because it relies on a web services requiring authentication. earthaccess_login()
# Try to login in NASA earthaccess # Shouldn't be tested because it relies on a web services requiring authentication. earthaccess_login()
earth-engine-api
python reticulate moduleThe pointer to the earth-engine-api
python reticulate module
ee
ee
An object of class python.builtin.module
(inherits from python.builtin.object
) of length 1.
https://developers.google.com/earth-engine/apidocs
Initializes the Google Earth Engine API
ee_initialize()
ee_initialize()
Nothing, it just initializes the Google Earth Engine API
Earth Engine
server numberCreates an Earth Engine
server number
ee_number(x)
ee_number(x)
x |
the number to convert to Earth Engine's number. |
The Earth Engine number
https://developers.google.com/earth-engine/apidocs/ee-number
Given a geometry with point samples and images from Earth Engine retrieve the point geometry with values for the images
extract(stack, geom, scale)
extract(stack, geom, scale)
stack |
A single image or a vector/list of images from Earth Engine. |
geom |
A geometry from |
scale |
The scale in meters for the extraction (image resolution). |
An ee.FeatureCollection with the properties extracted from the stack of images from ee.
Calculate raster values based on a formula
formulaCalculate(formula, data, updateBand)
formulaCalculate(formula, data, updateBand)
formula |
Formula. A formula to apply to the RasterBands from |
data |
List. A named list with the used variables in the textual formula |
updateBand |
GDALRasterBand. The GDALRasterBand which will be updated with the calculated values. |
Nothing, it just updates the band of interest.
# 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 ) ds$Close()
# 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 ) ds$Close()
Wrapping class for GDALDataset C++ API exporting GetRasterBand, GetRasterXSize, GetRasterYSize
new()
Create a new raster file based on specified data. It will output a *.tif file.
GDALDataset$new(ds)
ds
GDALDatasetR pointer. Should not be used
datatype
GDALDataType. The GDALDataType to use for the raster, use (GDALDataType$) to find the options. Default GDALDataType$GDT_Float64
An object from GDALDataset R6 class.
GetRasterBand()
Function to retrieve the GDALRasterBand R6 Object.
GDALDataset$GetRasterBand(x)
x
Integer. The band index, starting from 1 to number of bands.
An object of GDALRasterBand R6 class.
GetRasterXSize()
Get the width for the raster
GDALDataset$GetRasterXSize()
An integer indicating the raster width
GetRasterYSize()
Get the height for the raster
GDALDataset$GetRasterYSize()
An integer indicating the raster height
Close()
Closes the GDALDataset
GDALDataset$Close()
An integer indicating the raster width
clone()
The objects of this class are cloneable with this method.
GDALDataset$clone(deep = FALSE)
deep
Whether to make a deep clone.
List of datatypes supported by the GDALDataset R6 class
GDALDataType
GDALDataType
An object of class list
of length 7.
Function to open GDAL Dataset
GDALOpen(filename, readonly = TRUE)
GDALOpen(filename, readonly = TRUE)
filename |
Character. The path to a GDAL dataset. |
readonly |
Logical. Flag to open a read only GDALDataset with GA_ReadOnly or GA_Update. Default TRUE. |
An R6 object of GDALDataset class.
ds_path <- system.file("extdata", "example.tif", package = "ICESat2VegR") ds <- GDALOpen(ds_path) ds$Close()
ds_path <- system.file("extdata", "example.tif", package = "ICESat2VegR") ds <- GDALOpen(ds_path) ds$Close()
Wrapping class for GDALRasterBand C++ API exporting GetBlockXSize, GetBlockYSize, ReadBlock, WriteBlock for better IO speed.
new()
Creates a new GDALRasterBand
GDALRasterBand$new(band)
band
The C++ pointer to the GDALRasterBandR object.
datatype
The GDALDataType for this band
An object of GDALRasterBand R6 class
ReadBlock()
Efficiently reads a raster block
GDALRasterBand$ReadBlock(iXBlock, iYBlock)
iXBlock
Integer. The i-th column block to access. The iXBlock
will be offset
from the origin.
iYBlock
Integer. The i-th row block to access. The iYBlock
will be offset
from the origin.
The returned Vector will be single dimensional with the length
. If you use matrix(, ncol=BLOCKXSIZE)
the matrix returned will actually be transposed. You should either transpose it or you can
calculate the indices using
RawVector for GDALDataType$GDT_Byte, IntegerVector for int types and NumericVector for floating point types.
WriteBlock()
Efficiently writes a raster block
GDALRasterBand$WriteBlock(iXBlock, iYBlock, buffer)
iXBlock
Integer. The i-th column block to write. The iXBlock
will be
offset from the origin.
iYBlock
Integer. The i-th row block to write. The iYBlock
will be offset
from the origin.
buffer
RawVector/IntegerVector/NumericVector depending on the GDALDataType.
This should be a 1D vector with size equal to raster
.
The returned Vector will be single dimensional with the length
.
If you use matrix(, ncol=BLOCKXSIZE) the matrix returned will actually be transposed.
You should either transpose it or you can calculate the indices using
.
Nothing
GetBlockXSize()
Get the block width
GDALRasterBand$GetBlockXSize()
An integer indicating block width
GetBlockYSize()
Get the block height
GDALRasterBand$GetBlockYSize()
An integer indicating block height
GetXSize()
Get the band width
GDALRasterBand$GetXSize()
An integer indicating band width
CalculateStatistics()
Calculate statistics for the GDALRasterBand
GDALRasterBand$CalculateStatistics()
nothing
GetYSize()
Get the band height
GDALRasterBand$GetYSize()
An integer indicating band height
GetNoDataValue()
Get band no data value
GDALRasterBand$GetNoDataValue()
Numeric indicating no data value
GetRasterDataType()
Get band datatype
GDALRasterBand$GetRasterDataType()
Numeric indicating the datatype
clone()
The objects of this class are cloneable with this method.
GDALRasterBand$clone(deep = FALSE)
deep
Whether to make a deep clone.
This constructor must not be called at all, this is automatically called from GDALDataset$GetRasterBand function.
Get observations given a minimum radius distance between samples
geomSampling(size, geom, split_id = NULL, chainSampling = NULL)
geomSampling(size, geom, split_id = NULL, chainSampling = NULL)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
geom |
a |
split_id |
character. The variable name of the geometry to use as split factor for sampling |
chainSampling |
chains different methods of sampling by providing the result
of another samplingMethod |
A icesat2_sampling_method
for defining the method used in sample()
Retrieve the Google Earth Engine image catalog id
get_catalog_id(id)
get_catalog_id(id)
id |
character. The id retrieved from the data.table resulting from |
The catalog id to open within Google Earth Engine.
Retrieve Google Earth Engine's tile url for an Image or ImageCollection
getTileUrl(img)
getTileUrl(img)
img |
The |
The url for the tile service.
ee.Image.glcmTexture
Computes texture metrics from the Gray Level Co-occurrence Matrix around each pixel of every band. The GLCM is a tabulation of how often different combinations of pixel brightness values (grey levels) occur in an image. It counts the number of times a pixel of value X lies next to a pixel of value Y, in a particular direction and distance. and then derives statistics from this tabulation.
glcmTexture(x, size = 1, kernel = NULL, average = TRUE)
glcmTexture(x, size = 1, kernel = NULL, average = TRUE)
x |
The input image to calculate the texture on. |
size |
integer, default 1. The size of the neighborhood to include in each GLCM. |
kernel |
default NULL. A kernel specifying the x and y offsets over which to compute the GLCMs. A GLCM is computed for each pixel in the kernel that is non-zero, except the center pixel and as long as a GLCM hasn't already been computed for the same direction and distance. For example, if either or both of the east and west pixels are set, only 1 (horizontal) GLCM is computed. Kernels are scanned from left to right and top to bottom. The default is a 3x3 square, resulting in 4 GLCMs with the offsets (-1, -1), (0, -1), (1, -1) and (-1, 0). |
average |
logical, default TRUE. If true, the directional bands for each metric are averaged. |
This implementation computes the 14 GLCM metrics proposed by Haralick, and 4 additional metrics from Conners. Inputs are required to be integer valued.
The output consists of 18 bands per input band if directional averaging is on and 18 bands per directional pair in the kernel, if not:
ASM: f1, Angular Second Moment; measures the number of repeated pairs
CONTRAST: f2, Contrast; measures the local contrast of an image
CORR: f3, Correlation; measures the correlation between pairs of pixels
VAR: f4, Variance; measures how spread out the distribution of gray-levels is
IDM: f5, Inverse Difference Moment; measures the homogeneity
SAVG: f6, Sum Average
SVAR: f7, Sum Variance
SENT: f8, Sum Entropy
ENT: f9, Entropy. Measures the randomness of a gray-level distribution
DVAR: f10, Difference variance
DENT: f11, Difference entropy
IMCORR1: f12, Information Measure of Corr. 1
IMCORR2: f13, Information Measure of Corr. 2
MAXCORR: f14, Max Corr. Coefficient. (not computed)
DISS: Dissimilarity
INERTIA: Inertia
SHADE: Cluster Shade
PROM: Cluster prominence
Another Earth Engine image with bands described on details section.
More information can be found in the two papers: Haralick et. al, 'Textural Features for Image Classification', http://doi.org/10.1109/TSMC.1973.4309314 and Conners, et al, Segmentation of a high-resolution urban scene using texture operators', http://doi.org/10.1016/0734-189X(84)90197-X.
https://developers.google.com/earth-engine/apidocs/ee-image-glcmtexture
Get samples stratified by grid cells of specified size
gridSampling(size, grid_size, chainSampling = NULL)
gridSampling(size, grid_size, chainSampling = NULL)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
grid_size |
generic params. The |
chainSampling |
chains different methods of sampling by providing the result
of another samplingMethod |
A icesat2_sampling_method
for defining the method used in sample()
Class for sampling methods to be passed on for the sample function
Class that represent custom segments created from ATL03 and ATL08 joined data
This class is actually just a wrap around the data.table
, but it indicates
the output from ATL03_ATL08_segment_create()
, which means the dataset will contain
the needed structure for computing value for the computing the stats with
ATL03_ATL08_compute_seg_attributes_dt_segStat()
Class for ATL03 attributes
data.table
in the data.table
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
Class for ICESat-2 ATL03
h5
Object of class H5File
from hdf5r
package containing the
ICESat-2 Global Geolocated Photon Data (ATL03)
H5File
in the hdf5r
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
Class for ATL03 segment attributes
data.table
in the data.table
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
Class for joined ATL03 and ATL08 attributes
data.table
in the data.table
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
Class for ATL08 attributes
data.table
in the data.table
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
Class for ICESat-2 ATL08
h5
Object of class H5File
from hdf5r
package containing the
ICESat-2 Land and Vegetation Along-Track Products (ATL08)
H5File
in the hdf5r
package and
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL08_ATBD_r006.pdf
The class representing the h5 file opened from the cloud for cloud computing.
The class representing the h5 file opened from the cloud for cloud computing.
Besides representing h5 files, it is also used to represent groups
opened with [[]]
.
The variants _cloud
and _local
allows all the other functions
to use generic calls using the same interface, with each class
implementation is provided accordingly.
The regular usage does not require the user to work with those classes as most other provided functions will actually give access to the most common necessities for working with ICESat-2 data.
new()
Direct initialization should not be used, it is handled by ATL0X_read()
ICESat2.h5_cloud$new(h5)
h5
the result of the ATLAS_dataFinder()
with cloud_computing = TRUE
The class object
ls()
Lists the groups and datasets that are within current group
ICESat2.h5_cloud$ls()
List the groups and datasets within the current path
ls_groups()
Lists all grouops recursively
ICESat2.h5_cloud$ls_groups(recursive = FALSE)
recursive
logical
, default FALSE. If TRUE it will list
groups recursively and return the full path.
The character
representing
ls_attrs()
Lists the available attributes
ICESat2.h5_cloud$ls_attrs()
character
vector of attributes available
dt_datasets()
Get datasets as data.table with columns (name, dataset.dims, rank)
ICESat2.h5_cloud$dt_datasets(recursive = FALSE)
recursive
logical
, default FALSE. If TRUE recursively searches
and returns the full path.
A data.table::data.table
with the columns (name, dataset.dims, rank)
exists()
Checks if a supplied group/dataset exist within the H5
ICESat2.h5_cloud$exists(path)
path
character
with the path to test
logical
TRUE or FALSE if it exists or not
attr()
Read an attribute from h5
ICESat2.h5_cloud$attr(attribute)
attribute
character
the address of the attribute to open
close_all()
Safely closes the h5 file pointer
ICESat2.h5_cloud$close_all()
Nothing, just closes the file
print()
Prints the data in a friendly manner
ICESat2.h5_cloud$print(...)
...
Added for compatibility purposes with generic signature
Outputs information about object
clone()
The objects of this class are cloneable with this method.
ICESat2.h5_cloud$clone(deep = FALSE)
deep
Whether to make a deep clone.
The class representing the h5 file opened from local files.
The class representing the h5 file opened from local files.
The variants _cloud
and _local
allows all the other functions
to use generic calls using the same interface, with each class
implementation is provided accordingly.
The regular usage does not require the user to work with those classes as most other provided functions will actually give access to the most common necessities for working with ICESat-2 data.
h5
A pointer to hdf5r::H5File
in case
the user wants to access features not implemented yet
beams
The character
vector of beams available for the granule.
strong_beams
The character
vector of strong beams calculated using orbit_info
weak_beams
The character
vector of weak beams calculated using orbit_info
isOpen
A flag to indicate if the file pointer has already been closed
new()
Direct initialization should not be used, it is handled by ATL0X_read()
ICESat2.h5_local$new(h5)
h5
the result of the ATLAS_dataFinder()
The class object
ls()
Lists the groups and datasets that are within current group
ICESat2.h5_local$ls()
List the groups and datasets within the current path
ls_groups()
Lists all grouops recursively
ICESat2.h5_local$ls_groups(recursive = FALSE)
recursive
logical
, default FALSE. If TRUE it will list
groups recursively and return the full path.
The character
representing
ls_attrs()
Lists the available attributes
ICESat2.h5_local$ls_attrs()
character
vector of attributes available
dt_datasets()
Get datasets as data.table with columns (name, dataset.dims, rank)
ICESat2.h5_local$dt_datasets(recursive = FALSE)
recursive
logical
, default FALSE. If TRUE recursively searches
and returns the full path.
A data.table::data.table
with the columns (name, dataset.dims, rank)
exists()
Checks if a supplied group/dataset exist within the H5
ICESat2.h5_local$exists(path)
path
character
with the path to test
logical
TRUE or FALSE if it exists or not
attr()
Read an attribute from h5
ICESat2.h5_local$attr(attribute)
attribute
character
the address of the attribute to open
close_all()
Safely closes the h5 file pointer
ICESat2.h5_local$close_all(silent = TRUE)
silent
logical
, default TRUE. Will cast warning messages if silent = FALSE.
Nothing, just closes the file
print()
Prints the data in a friendly manner
ICESat2.h5_local$print(...)
...
Added for compatibility purposes with generic signature
Outputs information about object
clone()
The objects of this class are cloneable with this method.
ICESat2.h5_local$clone(deep = FALSE)
deep
Whether to make a deep clone.
Base class for all ICESat2VegR package's H5 files for generic functions that can be run on any H5
Class representing dataset opened from the cloud using h5py
Class representing dataset opened from the cloud using h5py
This class should not be instanced by the user, instead it is
automatically handled when the user opens a dataset using [[]]
operator from a h5 file.
ds
Dataset pointer
dims
Dimensions of the dataset
chunk_dims
Chunk dimensions for the dataset
new()
Constructor using a dataset pointer
ICESat2.h5ds_cloud$new(ds)
ds
Dataset pointer
get_type()
Get the type of data for this dataset
ICESat2.h5ds_cloud$get_type()
get_fill_value()
Get the fill_value used by the dataset
ICESat2.h5ds_cloud$get_fill_value()
get_creation_property_list()
Get creation property list for the dataset (plist)
ICESat2.h5ds_cloud$get_creation_property_list()
clone()
The objects of this class are cloneable with this method.
ICESat2.h5ds_cloud$clone(deep = FALSE)
deep
Whether to make a deep clone.
Class representing dataset opened from locally using hdf5r
Class representing dataset opened from locally using hdf5r
This class should not be instanced by the user, instead it is
automatically handled when the user opens a dataset using [[]]
operator from a h5 file.
ds
Dataset pointer
dims
Dimensions of the dataset
chunk_dims
Chunk dimensions for the dataset
new()
Constructor using a dataset pointer
ICESat2.h5ds_local$new(ds)
ds
Dataset pointer
get_type()
Get the type of data for this dataset
ICESat2.h5ds_local$get_type()
get_fill_value()
Get the fill_value used by the dataset
ICESat2.h5ds_local$get_fill_value()
get_creation_property_list()
Get creation property list for the dataset (plist)
ICESat2.h5ds_local$get_creation_property_list()
clone()
The objects of this class are cloneable with this method.
ICESat2.h5ds_local$clone(deep = FALSE)
deep
Whether to make a deep clone.
This is a generic prediction class for HDF5 files to make type checking and method matching with S4 methods.
Configure environment for using Google Earth Engine functions and accessing earthaccess cloud data
ICESat2VegR_configure()
ICESat2VegR_configure()
This function will configure the python environment as required by this package for:
Accessing the h5 files directly from the cloud for cloud computing
Using earth engine functions wrappers that are made available within this package.
TRUE if everything works as expected, it is just an interactive installer
Returns the number of images in an ImageCollection
## S4 method for signature 'ee.imagecollection.ImageCollection' length(x)
## S4 method for signature 'ee.imagecollection.ImageCollection' length(x)
x |
The |
The number of images in the ImageCollection
Applies the fitted model as randomForest::randomForest
object to
the input raster stack (as ee.Image) to produce a wall-to-wall maps.
map_create(model, stack)
map_create(model, stack)
model |
|
stack |
A vector/list of ee.Image created using the ee API. |
An ee.Image
resulting from applying the fitted model.
Fit different models based on x and y inputs
model_fit(x, y, method = "lm", LOOCV = FALSE, ..., size = 40, linout = TRUE)
model_fit(x, y, method = "lm", LOOCV = FALSE, ..., size = 40, linout = TRUE)
x |
input data.frame of predictors (independ variables) the data from |
y |
input vector of observed data |
method |
the model to use the data from. The options are "lm" for linear
regression, "rf" for random forest, "nnt" for neural network, "svm" for support
vector machine and knn.* for k-nearest neighbors (see |
LOOCV |
|
... |
Other parameters to pass to the model |
size |
|
linout |
|
A list containing the method, model and cross validation data
if LOOCV = TRUE
.
This function plots photons along track
This function plots photons along track
This function plots photons along track
This function plots photons along track
## S4 method for signature 'icesat2.atl03atl08_dt,character' plot( x, y = "h_ph", beam = NULL, colors = c("gray", "goldenrod", "forestgreen", "green"), legend = "topleft", ... ) ## S4 method for signature 'icesat2.atl03atl08_dt,missing' plot(x, y, ...) ## S4 method for signature 'icesat2.atl08_dt,character' plot(x, y, beam = "gt1l", col = "gray", xlim = NULL, ylim = NULL, ...) ## S4 method for signature 'icesat2.atl03_dt,character' plot(x, y, col = "gray", ...)
## S4 method for signature 'icesat2.atl03atl08_dt,character' plot( x, y = "h_ph", beam = NULL, colors = c("gray", "goldenrod", "forestgreen", "green"), legend = "topleft", ... ) ## S4 method for signature 'icesat2.atl03atl08_dt,missing' plot(x, y, ...) ## S4 method for signature 'icesat2.atl08_dt,character' plot(x, y, beam = "gt1l", col = "gray", xlim = NULL, ylim = NULL, ...) ## S4 method for signature 'icesat2.atl03_dt,character' plot(x, y, col = "gray", ...)
x |
An object of class |
y |
The attribute name for y axis |
beam |
Character vector indicating only one beam to process ("gt1l", "gt1r", "gt2l", "gt2r", "gt3l", "gt3r"). Default is "gt1r" |
colors |
A vector containing colors for plotting noise, terrain, vegetation and top canopy photons (e.g. c("gray", "#bd8421", "forestgreen", "green") |
legend |
the position of the legend. 'bottomleft', 'bottomright', 'topleft', 'topright' or FALSE to omit |
... |
will be passed to the main plot |
col |
Color for plotting the photons. Default is "gray" |
xlim |
The x limits to use for the plot |
ylim |
the y limits to use for the plot |
No return value
No return value
No return value
No return value
# 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", colors = c("gray", "#bd8421", "forestgreen", "green"), pch = 16, cex = 0.5 ) close(atl03_h5) close(atl08_h5) # 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, colors = c("gray", "#bd8421", "forestgreen", "green"), pch = 16, cex = 0.5 ) close(atl03_h5) close(atl08_h5) 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 and ATL08 photons and heights atl08_seg_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5) plot( atl08_seg_dt, "h_canopy", beam = "gt1r", col = "gray" ) close(atl08_h5) # 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_attributes_dt( atl03_h5 = atl03_h5, attributes = c("reference_photon_lon", "reference_photon_lat", "segment_dist_x", "h_ph") ) plot( atl03_photons_dt, "h_ph", col = "gray", pch = 16, cex = 0.5 ) close(atl03_h5)
# 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", colors = c("gray", "#bd8421", "forestgreen", "green"), pch = 16, cex = 0.5 ) close(atl03_h5) close(atl08_h5) # 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, colors = c("gray", "#bd8421", "forestgreen", "green"), pch = 16, cex = 0.5 ) close(atl03_h5) close(atl08_h5) 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 and ATL08 photons and heights atl08_seg_dt <- ATL08_seg_attributes_dt(atl08_h5 = atl08_h5) plot( atl08_seg_dt, "h_canopy", beam = "gt1r", col = "gray" ) close(atl08_h5) # 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_attributes_dt( atl03_h5 = atl03_h5, attributes = c("reference_photon_lon", "reference_photon_lat", "segment_dist_x", "h_ph") ) plot( atl03_photons_dt, "h_ph", col = "gray", pch = 16, cex = 0.5 ) close(atl03_h5)
Model prediction over a data.table from ATL03 or ATL08 data containing geolocation data. It can both append results to an existing HDF5 file or create a new file, allowing to incrementally add predictions to the file to avoid memory issues.
predict_h5(model, dt, output)
predict_h5(model, dt, output)
model |
The trained model object |
dt |
The input data.table to run the model |
output |
The output HDF5 file path |
An icesat2.predict_h5
, which is an
h5 file with latitude, longitude and prediction datasets.
atl03_path <- system.file( "extdata", "atl03_clip.h5", package = "ICESat2VegR" ) atl03_h5 <- ATL03_read(atl03_path = atl03_path) atl03_seg_dt <- ATL03_seg_attributes_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)
atl03_path <- system.file( "extdata", "atl03_clip.h5", package = "ICESat2VegR" ) atl03_h5 <- ATL03_read(atl03_path = atl03_path) atl03_seg_dt <- ATL03_seg_attributes_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)
This method is used to predict using a trained model and save the results in HDF5 file.
## S4 method for signature 'ANY,icesat2.atl03_seg_dt,character' predict_h5(model, dt, output)
## S4 method for signature 'ANY,icesat2.atl03_seg_dt,character' predict_h5(model, dt, output)
model |
The trained model object |
dt |
The input data.table to run the model |
output |
The output file path |
An icesat2.predict_h5
, which is an
h5 file with latitude, longitude and prediction
atl03_path <- system.file( "extdata", "atl03_clip.h5", package = "ICESat2VegR" ) atl03_h5 <- ATL03_read(atl03_path = atl03_path) atl03_seg_dt <- ATL03_seg_attributes_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)
atl03_path <- system.file( "extdata", "atl03_clip.h5", package = "ICESat2VegR" ) atl03_h5 <- ATL03_read(atl03_path = atl03_path) atl03_seg_dt <- ATL03_seg_attributes_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)
This method is used to predict using a trained model and save the results in HDF5 file.
## S4 method for signature 'ANY,icesat2.atl08_dt,character' predict_h5(model, dt, output)
## S4 method for signature 'ANY,icesat2.atl08_dt,character' predict_h5(model, dt, output)
model |
The trained model object |
dt |
The input data.table to run the model |
output |
The output file path |
This method is used to predict using a trained model and save the results in an HDF5 file.
An icesat2.predict_h5
, which is an
h5 file with latitude, longitude and prediction datasets.
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)
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)
predict
method for generating predictions for the ee.Classifier.predict
method for generating predictions for the ee.Classifier.
## S3 method for class 'ee.Classifier' predict(object, data, ...)
## S3 method for class 'ee.Classifier' predict(object, data, ...)
object |
The ee.Classifier generated either by using the regular
|
data |
|
... |
Unused parameter, just to match the generic signature. |
A numeric
with the predicted values
Prediction method wrapper for yai
## S3 method for class 'yai' predict(object, ...)
## S3 method for class 'yai' predict(object, ...)
object |
the model of class |
... |
the first parameter only will be used as the x parameter. If not supplied will be forwarded to defaul yaImpute predict function. |
either a numeric or data.frame with the predicted/imputed variables.
Prepend a class to an object's list of classes
prepend_class(obj, className)
prepend_class(obj, className)
obj |
The object to which prepend the class. |
className |
|
Nothing, it replaces the class attribute in place
Pure random sampling method
randomSampling(size)
randomSampling(size)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
A icesat2_sampling_method
for defining the method used in sample()
This is used after running the prediction using predict_h5()
function to rasterize and aggregate the prediction within raster cells.
By default it will calculate (n, mean, variance * (n - 1), min, max, sd)
in a single raster file with those 6 bands in that order.
You can modify this behavior by changing the agg_function
, agg_join
and finalizer
parameters, see details section.
rasterize_h5(h5_input, output, bbox, res, ...)
rasterize_h5(h5_input, output, bbox, res, ...)
h5_input |
The input HDF5 file path |
output |
The output raster file path |
bbox |
The bounding box of the raster |
res |
The resolution of the raster |
... |
Additional parameters (see details section) |
This function will create five different aggregate statistics (n, mean, variance, min, max).
Within ...
additional parameters we can use:
agg_function
: is a formula which return a data.table with the
aggregate function to perform over the data.
The default is:
~data.table( n = length(x), mean = mean(x,na.rm = TRUE), variance = var(x) * (length(x) - 1), min = min(x, na.rm=T), max = max(x, na.rm=T) )
agg_join
: is a function to merge two data.table aggregates
from the agg_function
. Since the h5 files will be aggregated
in chunks to avoid memory overflow, the statistics from the
different chunks should have a function to merge them.
The default function is:
function(x1, x2) { combined = data.table() x1$n[is.na(x1$n)] = 0 x1$mean[is.na(x1$mean)] = 0 x1$variance[is.na(x1$variance)] = 0 x1$max[is.na(x1$max)] = -Inf x1$min[is.na(x1$min)] = Inf combined$n = x1$n + x2$n delta = x2$mean - x1$mean delta2 = delta * delta combined$mean = (x1$n * x1$mean + x2$n * x2$mean) / combined$n combined$variance = x1$variance + x2$variance + delta2 * x1$n * x2$n / combined$n combined$min = pmin(x1$min, x2$min, na.rm=F) combined$max = pmax(x1$max, x2$max, na.rm=F) return(combined) }
finalizer
: is a list of formulas to generate the final
rasters based on the intermediate statistics from the previous
functions. The default finalizer
will calculate the sd
,
based on the variance
and n
values. It is defined as:
list( sd = ~sqrt(variance/(n - 1)), )
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) xmin <- min(atl08_dt$longitude) xmax <- max(atl08_dt$longitude) ymin <- min(atl08_dt$latitude) ymax <- max(atl08_dt$latitude) 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) output_raster <- tempfile(fileext = ".tif") rasterize_h5( predicted_h5, output = output_raster, bbox = terra::ext(xmin, xmax, ymin, ymax), res = 0.003 )
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) xmin <- min(atl08_dt$longitude) xmax <- max(atl08_dt$longitude) ymin <- min(atl08_dt$latitude) ymax <- max(atl08_dt$latitude) 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) output_raster <- tempfile(fileext = ".tif") rasterize_h5( predicted_h5, output = output_raster, bbox = terra::ext(xmin, xmax, ymin, ymax), res = 0.003 )
Rasterizes the model prediction saved in the HDF5 file
## S4 method for signature 'icesat2.predict_h5,character,SpatExtent,numeric' rasterize_h5( h5_input, output, bbox, res, chunk_size = 512 * 512, agg_function = agg_function_default, agg_join = agg_join_default, finalizer = finalizer_default )
## S4 method for signature 'icesat2.predict_h5,character,SpatExtent,numeric' rasterize_h5( h5_input, output, bbox, res, chunk_size = 512 * 512, agg_function = agg_function_default, agg_join = agg_join_default, finalizer = finalizer_default )
h5_input |
The input HDF5 file path |
output |
The output raster file path |
bbox |
The bounding box of the raster |
res |
The resolution of the raster |
chunk_size |
The chunk size to read the HDF5 file |
agg_function |
The function to aggregate the data |
agg_join |
The function to join the aggregated data |
finalizer |
The function to finalize the raster |
Get observations given a minimum radius distance between samples
rasterSampling(size, raster, chainSampling = NULL)
rasterSampling(size, raster, chainSampling = NULL)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
raster |
a |
chainSampling |
chains different methods of sampling by providing the result
of another samplingMethod |
A icesat2_sampling_method
for defining the method used in sample()
data.table::rbindlist()
functionWraps around data.table::rbindlist()
function
rbindlist2(l, ...)
rbindlist2(l, ...)
l |
A list containing data.table, data.frame or list objects. ... is the same but you pass the objects by name separately. |
... |
pass directly to |
The data.table with the same class as the input
This function extracts reference ground track from ICESat-2 ATL03 data and writes it as a GDAL vector format.
rgt_extract(h5)
rgt_extract(h5)
h5 |
A ICESat-2 ATL03 object (output of |
This function will use the reference photons from the segments as reference for deriving the ground tracks. The begining and end of the lines are interpolated from the information regarding the position of the reference photon within the segment and the segment length.
Returns the ground track boundaries as terra::SpatVector
extracted from "orbit_info",
along with other orbit information.
https://icesat-2.gsfc.nasa.gov/sites/default/files/page_files/ICESat2_ATL03_ATBD_r006.pdf
# Specifying the path to ATL03 H5 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 photons attributes rgt <- rgt_extract(h5 = atl03_h5) head(rgt) terra::plet(rgt) close(atl03_h5)
# Specifying the path to ATL03 H5 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 photons attributes rgt <- rgt_extract(h5 = atl03_h5) head(rgt) terra::plet(rgt) close(atl03_h5)
Sample method for applying multiple sampling methods
sample(x, ..., method)
sample(x, ..., method)
x |
the generic input data to be sampled |
... |
generic params to pass ahead to the specific sampling function |
method |
the sampling method to use. |
It is expected that the user pass a method
parameter within ...
randomSampling()
, spacedSampling()
, gridSampling()
,
stratifiedSampling()
, geomSampling()
, rasterSampling()
Search for Google Earth Engine datasets
search_datasets( ..., title = TRUE, description = TRUE, operator = "and", refresh_cache = FALSE )
search_datasets( ..., title = TRUE, description = TRUE, operator = "and", refresh_cache = FALSE )
... |
character arguments to search for within title and/or description |
title |
logical. Whether should search within the title, default TRUE. |
description |
logical. Whether should search within the description of the dataset, default TRUE. |
operator |
character. Should be either "OR" or "AND" to tell if the search needs to include all the queries "AND" or any of the queries "OR". Default "AND". |
refresh_cache |
flag indicating if the results cache should be refreshed, default FALSE. |
A data.table
containing the id, title and description of the datasets that matched
the supplied query ordered by relevance.
Given a stack image raster from GEE retrieve the point geometry with values for the images
seg_gee_ancillary_dt_extract(stack, geom, scale = 30, chunk_size = 1000)
seg_gee_ancillary_dt_extract(stack, geom, scale = 30, chunk_size = 1000)
stack |
A single image or a vector/list of images from Earth Engine. |
geom |
A geometry from |
scale |
The scale in meters for the extraction (image resolution). |
chunk_size |
If the number of observations is greater than 1000, it is recommended to chunk the results for not running out of memory within GEE server, default is chunk by 1000. |
A data.table::data.table with the properties extracted from the ee images.
The local gradient is computed using the 4-connected neighbors of each pixel, so missing values will occur around the edges of an image.
slope(x)
slope(x)
x |
The |
An ee.Image
with a single band named "Slope".
Get observations given a minimum radius distance between samples
spacedSampling(size, radius, spatialIndex = NULL, chainSampling = NULL)
spacedSampling(size, radius, spatialIndex = NULL, chainSampling = NULL)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
radius |
the minimum radius between samples. |
spatialIndex |
optional parameter. You can create a spatial index for accelerating
the search space with |
chainSampling |
chains different methods of sampling by providing the result
of another samplingMethod |
A icesat2_sampling_method
for defining the method used in sample()
Computes absolute and relative root-mean-square error (RMSE) and bias, and adjusted coefficient of determination from a linear relationship between predicted and observed data
stats_model( observed, predicted, plotstat = TRUE, legend = "topleft", unit = " m", ... )
stats_model( observed, predicted, plotstat = TRUE, legend = "topleft", unit = " m", ... )
observed |
A vector containing observed data |
predicted |
A vector containing predicted data |
plotstat |
if TRUE, a plot showing the 1:1 figure will be displayed. Default is TRUE |
legend |
Character for legend position. Default is "topleft" |
unit |
Character indicating the unit for the observed and predicted data (e.g."Mg/ha") |
... |
Other params to be redirected to the plot. |
Returns an data.frame object containing the list of stats
# Observed and predicted aboveground biomass observed <- c(178, 33, 60, 80, 104, 204, 146) predicted <- c(184, 28.5, 55, 85, 105, 210, 155) stats_model(observed, predicted, plotstat = TRUE, legend = "topleft", unit = "Mg/ha", xlab = "Obserbed AGBD (Mg/ha)", ylab = "Predicted AGBD (Mg/ha)", pch = 16 )
# Observed and predicted aboveground biomass observed <- c(178, 33, 60, 80, 104, 204, 146) predicted <- c(184, 28.5, 55, 85, 105, 210, 155) stats_model(observed, predicted, plotstat = TRUE, legend = "topleft", unit = "Mg/ha", xlab = "Obserbed AGBD (Mg/ha)", ylab = "Predicted AGBD (Mg/ha)", pch = 16 )
Get samples stratified by a variable binning histogram
stratifiedSampling(size, variable, chainSampling = NULL, ...)
stratifiedSampling(size, variable, chainSampling = NULL, ...)
size |
the sample size. Either an integer of absolute number of samples or if it is between (0, 1) it will sample a percentage relative to the number of available observations within the group. |
variable |
Variable name used for the stratification |
chainSampling |
chains different methods of sampling by providing the result
of another samplingMethod |
... |
forward to the |
A icesat2_sampling_method
for defining the method used in sample()
terra::SpatVector
Generic function to export icesat2 classes to terra::SpatVector
to_vect(x, ...)
to_vect(x, ...)
x |
The icesat2 object to convert to |
... |
other potential parameters needed. |
The icesat2 object as the appropriate terra::SpatVector
# Get path to ATL03 h5 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 segment attributes atl03_segment_dt <- ATL03_seg_attributes_dt(atl03_h5 = atl03_h5) # Extract vector atl03_segment_vect <- to_vect(atl03_segment_dt) # Terra plot terra::plot(atl03_segment_vect, col = atl03_segment_vect$segment_ph_cnt) # Export as temp gpkg temp_vect <- tempfile(fileext = ".gpkg") terra::writeVector(atl03_segment_vect, temp_vect) head(atl03_segment_dt) close(atl03_h5)
# Get path to ATL03 h5 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 segment attributes atl03_segment_dt <- ATL03_seg_attributes_dt(atl03_h5 = atl03_h5) # Extract vector atl03_segment_vect <- to_vect(atl03_segment_dt) # Terra plot terra::plot(atl03_segment_vect, col = atl03_segment_vect$segment_ph_cnt) # Export as temp gpkg temp_vect <- tempfile(fileext = ".gpkg") terra::writeVector(atl03_segment_vect, temp_vect) head(atl03_segment_dt) close(atl03_h5)
This method converts data from various ICESat-2 data types to a terra::SpatVector-class
object,
facilitating geographic operations and visualizations within the terra package.
## S4 method for signature 'icesat2.atl03_atl08_seg_dt' to_vect(x, ...)
## S4 method for signature 'icesat2.atl03_atl08_seg_dt' to_vect(x, ...)
x |
ICESat-2 data object to be converted. |
... |
Additional parameters for the method. |
terra::SpatVector
object representing the input data.
This method converts data from various ICESat-2 data types to a terra::SpatVector-class
object,
facilitating geographic operations and visualizations within the terra package.
## S4 method for signature 'icesat2.atl03_dt' to_vect(x, ...)
## S4 method for signature 'icesat2.atl03_dt' to_vect(x, ...)
x |
ICESat-2 data object to be converted. |
... |
Additional parameters for the method. |
terra::SpatVector
object representing the input data.
This method converts data from various ICESat-2 data types to a terra::SpatVector-class
object,
facilitating geographic operations and visualizations within the terra package.
## S4 method for signature 'icesat2.atl03_seg_dt' to_vect(x, ...)
## S4 method for signature 'icesat2.atl03_seg_dt' to_vect(x, ...)
x |
ICESat-2 data object to be converted. |
... |
Additional parameters for the method. |
terra::SpatVector
object representing the input data.
This method converts data from various ICESat-2 data types to a terra::SpatVector-class
object,
facilitating geographic operations and visualizations within the terra package.
## S4 method for signature 'icesat2.atl03atl08_dt' to_vect(x, ...)
## S4 method for signature 'icesat2.atl03atl08_dt' to_vect(x, ...)
x |
ICESat-2 data object to be converted. |
... |
Additional parameters for the method. |
terra::SpatVector
object representing the input data.
This method converts data from various ICESat-2 data types to a terra::SpatVector-class
object,
facilitating geographic operations and visualizations within the terra package.
## S4 method for signature 'icesat2.atl08_dt' to_vect(x, ...)
## S4 method for signature 'icesat2.atl08_dt' to_vect(x, ...)
x |
ICESat-2 data object to be converted. |
... |
Additional parameters for the method. |
terra::SpatVector
object representing the input data.