Learn R Programming

rGEDI (version 0.6.0)

clip: Clip GEDI data with a common interface

Description

clip() provides one clipping interface for open GEDI HDF5 products, extracted footprint tables, and GEDI Level 3 or Level 4B rasters. It follows the workflow used by ICESat2VegR while retaining rGEDI's coordinate order.

Usage

clip(x, clip_obj, ...)

# S4 method for gedi.level1b,numeric clip(x, clip_obj, ...)

# S4 method for gedi.level1b,SpatExtent clip(x, clip_obj, ...)

# S4 method for gedi.level1b,ANY clip(x, clip_obj, ...)

# S4 method for gedi.level2a,numeric clip(x, clip_obj, ...)

# S4 method for gedi.level2a,SpatExtent clip(x, clip_obj, ...)

# S4 method for gedi.level2a,ANY clip(x, clip_obj, ...)

# S4 method for gedi.level2b,numeric clip(x, clip_obj, ...)

# S4 method for gedi.level2b,SpatExtent clip(x, clip_obj, ...)

# S4 method for gedi.level2b,ANY clip(x, clip_obj, ...)

# S4 method for gedi.level4a,numeric clip(x, clip_obj, ...)

# S4 method for gedi.level4a,SpatExtent clip(x, clip_obj, ...)

# S4 method for gedi.level4a,ANY clip(x, clip_obj, ...)

# S4 method for data.frame,numeric clip(x, clip_obj, ...)

# S4 method for data.frame,SpatExtent clip(x, clip_obj, ...)

# S4 method for data.frame,ANY clip(x, clip_obj, ...)

# S4 method for SpatRaster,ANY clip(x, clip_obj, ...)

Value

The return type follows x. Open Level 1B, 2A, 2B, and 4A HDF5 inputs return clipped open GEDI objects; footprint tables return a data.table::data.table; and Level 3/4B rasters return a terra::SpatRaster. Geometry clipping with split_by returns a named list of HDF5-backed GEDI objects, one per polygon ID.

Arguments

x

A gedi.level1b, gedi.level2a, gedi.level2b, or gedi.level4a object; a footprint data.frame/data.table; or a terra::SpatRaster.

clip_obj

A numeric extent in the order c(xmin, xmax, ymin, ymax), a terra::SpatExtent, or an sf, sfc, or terra::SpatVector polygon object.

...

Arguments used by the selected method. HDF5 methods accept output and geometry methods also accept split_by. Table geometry methods accept split_by. Raster methods accept filename and overwrite.

Details

Extracted tables are recognized from standard GEDI coordinates: longitude_bin0/latitude_bin0, lon_lowestmode/lat_lowestmode, or longitude/latitude. When the corresponding longitude_lastbin and latitude_lastbin fields exist, both waveform endpoints must fall inside a numeric extent.

This function masks graphics::clip(). Use graphics::clip() explicitly when changing a base graphics clipping region.

Examples

Run this code
footprints <- data.frame(
  shot_number = 1:3,
  lon_lowestmode = c(-44.13, -44.12, -44.10),
  lat_lowestmode = c(-13.74, -13.73, -13.70)
)
clip(footprints, c(-44.14, -44.11, -13.75, -13.72))

Run the code above in your browser using DataLab