carlos-alberto-silva / rGEDI

rGEDI: An R Package for NASA's Global Ecosystem Dynamics Investigation (GEDI) Data Visualization and Processing.
157 stars 67 forks source link

NA in coordinates error #13

Closed serbinsh closed 4 years ago

serbinsh commented 4 years ago

First, I am working to follow along with the vignette using my own data. However I am running into an error with the conversion of L1B data to a spatial data frame due to NA's in coordinates, which as far as I can tell is really only perhaps 1 "row" of the data

> gedilevel1b <- readLevel1B(level1Bpath = file.path(outdir, "GEDI01_B_2019210205202_O03556_T00995_02_003_01.h5"))
> head(gedilevel1b)
Error in x[seq_len(n)] : object of type 'S4' is not subsettable
> level1bGeo <- getLevel1BGeo(level1b=gedilevel1b,select=c("elevation_bin0"))
  |========================================================================================================================================================| 100%
> head(level1bGeo)
         shot_number latitude_bin0 latitude_lastbin longitude_bin0 longitude_lastbin elevation_bin0
1: 35560012100000001     -51.67903        -51.67903       159.5828          159.5828       2196.590
2: 35560012300000002     -51.67900        -51.67900       159.5836          159.5836       2196.404
3: 35560012500000003     -51.67897        -51.67897       159.5845          159.5845       2196.769
4: 35560012700000004     -51.67894        -51.67894       159.5853          159.5853       2196.472
5: 35560012900000005     -51.67892        -51.67891       159.5861          159.5861       2211.450
6: 35560013100000006     -51.67889        -51.67888       159.5869          159.5869       2209.526
> # Converting shot_number as "integer64" to "character"
> level1bGeo$shot_number <- paste0(level1bGeo$shot_number)
> library(sp)
> level1bGeo_spdf <- SpatialPointsDataFrame(cbind(level1bGeo$longitude_bin0, level1bGeo$latitude_bin0),
+                                         data=level1bGeo)
Error in .local(obj, ...) : NA values in coordinates

Also when viewiing this data table I realized I am not certain if the code is interpreting my Lat/Longs properly. The values for Lat and Long dont match when I have provided

ul_lat <- 34.506881
lr_lat <-  34.063161
ul_lon <- -87.589072
lr_lon <- -87.060702

It looks like long may be converted to degrees east? But Lat becomes negative? I assumed these were meant to be lat/long in decimal degrees?

serbinsh commented 4 years ago

FYI

> which(is.na(level1bGeo))
 [1]  6036930  9884836 11404134 15252040 16771338 20619244 22138542 25986448 27505746 31353652
> 
tomtom776 commented 4 years ago

@serbinsh I am also having a similar issue. I used the following command to get past it:

level1bGeo_omit <- na.omit(level1bGeo)

But then I noticed that there was missing data in the middle if the GEDI transect. I think the gedifinder function might be flawed.

caiohamamura commented 4 years ago

This is actually expected, the gedifinder (a service provided by NASA) will only return the transects that intersects with the bounding box provided. The files aren't clipped to your specified region, instead they probably cover a much larger region.