l4_convert: Convert GEDI level 4A data to 'sf' object and export it

View source: R/l4_convert.R

l4_convertR Documentation

Convert GEDI level 4A data to sf object and export it

Description

Write GEDI level 4A data to disk as a vector file.

Usage

l4_convert(gediL4, epsg = NULL, filename, return_path = F, ...)

Arguments

gediL4

data.table obtained with the function l4_getmulti() or l4_clip, or a SpatVector object.

epsg

Numeric: destination EPSG code. Default to NULL.

filename

Character: path to data source name. Usually a file name with extension. See ?writeVector for more details.

return_path

Logical: if TRUE, the path of the saved file will be returned, otherwise the function will return NULL. Default to FALSE.

...

Others argument to pass to writeVector, such as filetype or overwrite

Details

If a file extension will cause conflict with the filetype, the extension will be guessed from the file name. Note that in converting data to ESRI Shapefile, columns names will be abbreviated.

Value

The function is called for its side effects. It return NULL unless return_path=TRUE.

See Also

writeVector

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)
#convert to shp file
converted <- l4_convert(l4_data,epsg = 4326,filename=paste0(outdir,"/example.shp"),return_path = T)
example <- terra::vect(converted)
file.remove(list.files(outdir,pattern = "example",full.names = T))

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