Skip to content

Commit

Permalink
merged with Caio
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-alberto-silva committed Mar 9, 2020
1 parent dd00d48 commit 6e99b20
Show file tree
Hide file tree
Showing 49 changed files with 263 additions and 256 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
# Generated by roxygen2: do not edit by hand

export(LPDAACDataPool)
export(clipLevel1B)
Expand Down
18 changes: 9 additions & 9 deletions R/C_processExtractMetrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
#'
#'# Unzipping ALS data
#'alsfile_Amazon_filepath <- unzip(alsfile_Amazon_zip,exdir = dirname(alsfile_Amazon_zip))
#'alsfile_Savanna_filepath <- unzip(alsfile_Smazon_zip,exdir = dirname(alsfile_Savanna_zip))
#'alsfile_Savanna_filepath <- unzip(alsfile_Savanna_zip,exdir = dirname(alsfile_Savanna_zip))
#'
#'# Reading and plot ALS file (las file)
#'als_Amazon<-readLAS(alsfile_Amazon_filepath)
Expand All @@ -135,14 +135,14 @@
#' coords = c(xcenter_Savanna, ycenter_Savanna))
#'
#'# Extracting GEDI feull-waveform derived metrics
#'wf_amazon_metrics<-gediWFMetrics(input=wf_amazon,outRoot=file.path(getwd(), "amazon"))
#'wf_cerrado_metrics<-gediWFMetrics(input=wf_cerrado,outRoot=file.path(getwd(), "cerrado"))
#'wf_amazon_metrics<-gediWFMetrics(input=wf_Amazon,outRoot=file.path(getwd(), "amazon"))
#'wf_savanna_metrics<-gediWFMetrics(input=wf_Savanna,outRoot=file.path(getwd(), "cerrado"))
#'
#'close(wf_amazon)
#'close(wf_cerrado)
#'close(wf_Amazon)
#'close(wf_Savanna)
#'
#'metrics<-rbind(wf_amazon_metrics,wf_cerrado_metrics)
#'rownames(metrics)<-c("Amazon","Cerrado")
#'metrics<-rbind(wf_amazon_metrics,wf_savanna_metrics)
#'rownames(metrics)<-c("Amazon","Savanna")
#'head(metrics)
#'}
#'
Expand Down Expand Up @@ -301,7 +301,7 @@ gediWFMetrics = function(
inputInList = list(NULL, NULL)
if (class(input)=="list") {
files = sapply(input, function(x) {
x@h5$close_all()
close(x)
return (x@h5$filename)
})
inList = tempfile(fileext=".txt")
Expand All @@ -310,7 +310,7 @@ gediWFMetrics = function(
close(fileHandle)
inputInList[[2]] = inList
} else {
input@h5$close_all()
close(input)
inputInList[[1]] = input@h5$filename
}

Expand Down
6 changes: 3 additions & 3 deletions R/C_simulateFullWaveform.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#'
#'# Unzipping ALS data
#'alsfile_Amazon_filepath <- unzip(alsfile_Amazon_zip,exdir = dirname(alsfile_Amazon_zip))
#'alsfile_Savanna_filepath <- unzip(alsfile_Smazon_zip,exdir = dirname(alsfile_Savanna_zip))
#'alsfile_Savanna_filepath <- unzip(alsfile_Savanna_zip,exdir = dirname(alsfile_Savanna_zip))
#'
#'# Reading and plot ALS file (las file)
#'als_Amazon<-readLAS(alsfile_Amazon_filepath)
Expand Down Expand Up @@ -132,9 +132,9 @@
#'plot(wf_Savanna, relative=TRUE, polygon=TRUE, type="l", lwd=2, col="green",
#' xlab="Waveform Amplitude (%)", ylab="Elevation (m)", ylim=c(815,835))
#'grid()
#'
#'close(wf_Amazon)
#'
#'close(wf_Amazon)
#'close(wf_Savanna)
#'}
#'
#' @import hdf5r
Expand Down
2 changes: 1 addition & 1 deletion R/clipLevel1B.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ clipLevel1B = function(level1b, xmin, xmax, ymin, ymax, output=""){
masks,
output)
output = newFile@h5$filename
newFile@h5$close_all()
close(newFile)
result = readLevel1B(output)

return (result)
Expand Down
10 changes: 5 additions & 5 deletions R/clipLevel1BGeo.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
#'ymax = -13.71244
#'
#'# clip by boundary box coordinates
#'level1bGeo_clip <- clipLevel1BGeo(level1BGeo,xmin, xmax, ymin, ymax)
#'level1BGeo_clip <- clipLevel1BGeo(level1BGeo,xmin, xmax, ymin, ymax)
#'
#'library(leaflet)
#'leaflet() %>%
#' addCircleMarkers(level1bGeo_clip$longitude_bin0,
#' level1bGeo_clip$latitude_bin0,
#' addCircleMarkers(level1BGeo_clip$longitude_bin0,
#' level1BGeo_clip$latitude_bin0,
#' radius = 1,
#' opacity = 1,
#' color = "red") %>%
Expand Down Expand Up @@ -106,9 +106,9 @@ clipLevel1BGeo = function(level1BGeo,xmin, xmax, ymin, ymax){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'level1bGeo_clip = clipLevel1BGeometry(level1bGeo, polygon_spdf, split_by="id")
#'level1BGeo_clip = clipLevel1BGeometry(level1BGeo, polygon_spdf, split_by="id")
#'
#'library(leaflet)
#'leaflet() %>%
Expand Down
4 changes: 2 additions & 2 deletions R/clipLevel2A.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ clipLevel2A = function(level2a, xmin, xmax, ymin, ymax, output=""){
masks,
output)
output = newFile@h5$filename
newFile@h5$close_all()
close(newFile)
result = readLevel2A(output)

return (result)
Expand Down Expand Up @@ -94,7 +94,7 @@ clipLevel2A = function(level2a, xmin, xmax, ymin, ymax, output=""){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# Spepecifing output file and path
#'output<-paste0(getwd(),"//GEDI02_A_2019108080338_O01964_T05337_02_001_01_clip")
Expand Down
2 changes: 1 addition & 1 deletion R/clipLevel2AM.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ clipLevel2AM = function(level2AM,xmin, xmax, ymin, ymax){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'level2AM_clip = clipLevel2AMGeometry(level2AM, polygon_spdf, split_by="id")
#'
Expand Down
4 changes: 2 additions & 2 deletions R/clipLevel2B.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ clipLevel2B = function(level2b, xmin, xmax, ymin, ymax, output=""){
masks,
output)
output = newFile@h5$filename
newFile@h5$close_all()
close(newFile)
result = readLevel2B(output)

return (result)
Expand Down Expand Up @@ -104,7 +104,7 @@ clipLevel2B = function(level2b, xmin, xmax, ymin, ymax, output=""){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# Spepecifing output file and path
#'output<-paste0(getwd(),"//GEDI02_B_2019108080338_O01964_T05337_02_001_01_clip")
Expand Down
2 changes: 1 addition & 1 deletion R/clipLevel2BPAIProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ clipLevel2BPAIProfile = function(level2BPAIProfile,xmin, xmax, ymin, ymax){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# clip level2BPAIProfile by geometry
#'level2b_clip_geometry <- clipLevel2BPAIProfileGeometry(
Expand Down
2 changes: 1 addition & 1 deletion R/clipLevel2BPAVDProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ clipLevel2BPAVDProfile = function(level2BPAVDProfile,xmin, xmax, ymin, ymax){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# clip level2BPAIProfile by geometry
#'level2BPAVDProfile_clip <- clipLevel2BPAVDProfileGeometry(
Expand Down
2 changes: 1 addition & 1 deletion R/clipLevel2BVPM.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ clipLevel2BVPM = function(level2BVPM,xmin, xmax, ymin, ymax){
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# clip level2BVPM by geometry
#'level2b_clip_geometry <- clipLevel2BVPMGeometry(level2BVPM,polygon_spdf,split_by="id")
Expand Down
4 changes: 2 additions & 2 deletions R/getLevel1bGeo.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
#'level1b<-readLevel1B(level1Bpath=level1Bpath)
#'
#'# Get GEDI level1B geolocations
#'level1bGeo<-getLevel1BGeo(level1b,select=c("elevation_bin0", "elevation_lastbin"))
#'head(level1bGeo)
#'level1BGeo<-getLevel1BGeo(level1b,select=c("elevation_bin0", "elevation_lastbin"))
#'head(level1BGeo)
#'
#'
#'@export
Expand Down
4 changes: 2 additions & 2 deletions R/getLevel2AM.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'@seealso https://lpdaac.usgs.gov/products/gedi02_av001/
#'
#'@examples
#'\dontrun{
#'
#'# specify the path to GEDI level2A data (zip file)
#'level2A_fp_zip <- system.file("extdata",
#' "GEDI02_A_2019108080338_O01964_T05337_02_001_01_sub.zip",
Expand All @@ -27,7 +27,7 @@
#'# Get GEDI Elevation and Height Metrics
#'level2AM<-getLevel2AM(level2a)
#'head(level2AM)
#'}
#'
#'@export
getLevel2AM<-function(level2a){
level2a<-level2a@h5
Expand Down
2 changes: 1 addition & 1 deletion R/gridStatsLevel2AM.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'@seealso https://lpdaac.usgs.gov/products/gedi02_av001/
#'
#'@examples
#'\dontrun{
#'\donttest{
#'# specify the path to GEDI level2A data (zip file)
#'level2A_fp_zip <- system.file("extdata",
#' "GEDI02_A_2019108080338_O01964_T05337_02_001_01_sub.zip",
Expand Down
2 changes: 1 addition & 1 deletion R/polyStatsLevel2AM.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# Get GEDI Eleveation and Relative Metrics (level2A)
#'level2AM<-getLevel2AM(level2a)
Expand Down
2 changes: 1 addition & 1 deletion R/polyStatsLevel2BVPM.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#'# Reading shapefile as SpatialPolygonsDataFrame object
#'library(raster)
#'polygon_spdf<-shapefile(polygons_filepath)
#'polygon_spdf<-shapefile(polygon_filepath)
#'
#'# Get GEDI Canopy Cover and Vertical Profile Metrics
#'level2BVPM<-getLevel2BVPM(level2b)
Expand Down
2 changes: 1 addition & 1 deletion R/readLevel2A.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'@seealso https://lpdaac.usgs.gov/products/gedi02_av001/
#'
#'@examples
#'\dontrun{
#'\donttest{
#'# specify the path to GEDI level2A data (zip file)
#'level2A_fp_zip <- system.file("extdata",
#' "GEDI02_A_2019108080338_O01964_T05337_02_001_01_sub.zip",
Expand Down
22 changes: 20 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,27 @@
classes = classes[classes %in% objs]
objNames = names(classes)
for (o in objNames) {
try(close(get(o)), silent=T)
try(close(get(o, envir = .GlobalEnv)), silent=T)
}
rm(list=as.vector(objNames))
library.dynam.unload("rGEDI", libpath)
invisible()
}

.onLoad <- function(libname, pkgname){
objs = c("gedi.level1a", "gedi.level1b", "gedi.level2a", "gedi.level1bSim")
classes = sapply(ls(.GlobalEnv), function(x) class(get(x)))
classes = classes[classes %in% objs]
objNames = names(classes)
for (i in 1:length(objNames)) {
if (length(classes) > 0) {
assign(
objNames[i],
new(
classes[i][[1]],
h5=hdf5r::h5file(get(objNames[i])@h5$filename)),
envir=.GlobalEnv)
}
}

invisible()
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified inst/extdata/Savanna.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion man/LPDAACDataPool.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/clipLevel1BGeo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/clipLevel1BGeoGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clipLevel2AGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clipLevel2AMGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clipLevel2BGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clipLevel2BPAIProfileGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/clipLevel2BPAVDProfileGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/clipLevel2BVPMGeometry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6e99b20

Please sign in to comment.