gediDownload: Download GEDI data

View source: R/gediDownload.R

gediDownloadR Documentation

Download GEDI data

Description

Download GEDI data from LP DAAC Data Pool. Users will need to enter their Earth Explore login Information for downloading the data.

Usage

gediDownload(
  filepath,
  outdir = NULL,
  overwrite = FALSE,
  buffer_size = 512,
  timeout = 10
)

Arguments

filepath

Vector object; path to the GEDI data

outdir

Vector object, output directory for downloading GEDI data, default tempdir()

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.

Value

No return value on success, on failure it will stop()

References

Credits to Cole Krehbiel. Code adapted from https://git.earthdata.nasa.gov/projects/LPDUR/repos/daac_data_download_r/browse/DAACDataDownload.R

Examples

## Not run: 
# Set path to GEDI data
# herein we will only download xml metedata
filepath=c(paste0(
                 "https://e4ftl01.cr.usgs.gov/GEDI/GEDI02_B.001",
                 "/2019.04.18/GEDI02_B_2019108032534_O01961_T03911_02_001_01.h5.xml"
                 ),
          paste0("https://e4ftl01.cr.usgs.gov/GEDI/GEDI02_B.001",
                 "/2019.04.18/GEDI02_B_2019108045815_O01962_T01066_02_001_01.h5.xml"
                )
         )

# Set dir to download files to
outdir=tempdir()

# Create .netrc file
netrc = file.path(outdir, ".netrc")
netrc_conn <- file(netrc)

writeLines(c("machine urs.earthdata.nasa.gov",
            sprintf("login %s", Sys.getenv("NASA_USER")),
            sprintf("password %s", Sys.getenv("NASA_PASSWORD"))
), netrc_conn)

close(netrc_conn)

#' Downloading GEDI data
gediDownload(filepath,outdir)

## End(Not run)

carlos-alberto-silva/rGEDI documentation built on Oct. 18, 2024, 4:46 a.m.