l4_clip: Clip GEDI level 4A data to an extent or Shapefile boundary

l4_clipR Documentation

Clip GEDI level 4A data to an extent or Shapefile boundary

Description

Useful to get GEDI data for a specific study area, by clipping the data to a vector boundary or extent. Remember that, by default GEDI coordinates are in lon/lat format (EPSG 4326).

Usage

l4_clip(gediL4, clip, usegeometry = NULL, tct = NULL)

Arguments

gediL4

data.table obtained with the function l4_getmulti.

clip

An object from which an extent can be obtained (xmin, xmax, ymin, ymax). Currently could be a path to a shp or tif file, an object of class sf, a Raster* object, a SpatRaster, SpatVector, or a numeric vector of coordinates.

usegeometry

Logical: should the points be clipped on the boundary of a vector geometry (or path from which a geometry can be created). NULL and FALSE will be interpreted as the same, in that case the extent of clip will be used. Default to NULL.

tct

Numeric: tree cover threshold to filter GEDI data.

Details

GEDI coordinates are by default in lon/lat format (EPSG 4326). The function will try to convert the extent of clip to lon/lat coordinate system to ensure compatibility during the clip. The only exeption is when clip is a numeric vector or an extent object. In these cases the user must check that the extent is in lon/lat projection.

Value

A data.table object if usegeometry=NULL or FALSE, a SpatVector otherwise. It return NULL if gediL4 is NULL.

Examples


outdir = tempdir()
l4_zip <- system.file("extdata",
                     "GEDI04_A_2020036151358_O06515_02_T00198_02_002_01_V002.zip",
                     package="GEDI4R")
l4 <- unzip(l4_zip,exdir = outdir)
#get GEDI data
l4_data <- l4_getmulti(l4)
#clip using vector of coordinates
b_box <- c(-50,35,52,37)
clipped <- l4_clip(l4_data,clip=b_box)
#using Shapefile to clip
bound <- system.file("extdata","bound4326.shp",package="GEDI4R")
#with  extension
clipped <- l4_clip(l4_data,clip=bound,usegeometry = F)
#with  polygon boundaries
clipped2 <- l4_clip(l4_data,clip=bound,usegeometry = T)

VangiElia/GEDI4R documentation built on April 8, 2023, 6:13 p.m.