Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch data from a region #55

Closed
kauedesousa opened this issue Aug 23, 2021 · 5 comments
Closed

Fetch data from a region #55

kauedesousa opened this issue Aug 23, 2021 · 5 comments

Comments

@kauedesousa
Copy link
Member

Hi @adamhsparks

I am trying to download data from a region and a get this error. Here the code. Am I making the wrong call or is it something in the functions?

library("nasapower")

get_power(community = "ag",
          lonlat = c(112.5, -55.5, 115.5, -50.5),
          pars = c("T2M_MAX", "T2M_MIN"),
          dates = c("1985-01-01", "1985-02-01"),
          temporal_api = "daily")


 Error: New columns must be compatible with `.data`.
x New columns have 0 rows.
ℹ `.data` has 1920 rows.
Run `rlang::last_error()` to see where the error occurred.

This is a short information in my R session

─ Session info ────────────────────────────────────
 setting  value                       
 version  R version 4.1.0 (2021-05-18)
 os       macOS Big Sur 11.5.2        
 system   x86_64, darwin17.0          
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Oslo                 
 date     2021-08-23                  

@adamhsparks
Copy link
Member

adamhsparks commented Aug 23, 2021

Hi @kauedesousa, I'm not sure what the issue is?

> get_power(community = "ag",
+           lonlat = c(112.5, -55.5, 115.5, -50.5),
+           pars = c("T2M_MAX", "T2M_MIN"),
+           dates = c("1985-01-01", "1985-02-01"),
+           temporal_api = "daily")
NASA/POWER CERES/MERRA2 Native Resolution Daily Data                                                    
 Dates (month/day/year): 01/01/1985 through 02/01/1985  
 Location: Regional  
 Elevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = na meters 
 Value for missing model data cannot be computed or out of model availability range: NA  
 Parameter(s):  
 
 Parameters: 
 T2M_MAX     MERRA-2 Temperature at 2 Meters Maximum (C) ;
 T2M_MIN     MERRA-2 Temperature at 2 Meters Minimum (C)  
 
# A tibble: 1,920 × 9
     LAT   LON  YEAR    MM    DD   DOY YYYYMMDD   T2M_MAX T2M_MIN
   <dbl> <dbl> <dbl> <int> <int> <int> <date>       <dbl>   <dbl>
 1 -55.2  113.  1985     1     1     1 1985-01-01    4.09    2.85
 2 -55.2  113.  1985     1     1     1 1985-01-01    4.18    2.83
 3 -55.2  114.  1985     1     1     1 1985-01-01    4.12    2.76
 4 -55.2  114.  1985     1     1     1 1985-01-01    3.92    2.46
 5 -55.2  115.  1985     1     1     1 1985-01-01    3.68    2.06
 6 -55.2  115.  1985     1     1     1 1985-01-01    3.51    1.68
 7 -54.8  113.  1985     1     1     1 1985-01-01    4.36    3.12
 8 -54.8  113.  1985     1     1     1 1985-01-01    4.45    3.04
 9 -54.8  114.  1985     1     1     1 1985-01-01    4.4     2.98
10 -54.8  114.  1985     1     1     1 1985-01-01    4.25    2.8 
# … with 1,910 more rows

@kauedesousa
Copy link
Member Author

Hi @adamhsparks, it seems that I was using an old version of tibble. If I run the following code it goes fine

library("nasapower")

get_power(community = "ag",
          lonlat = c(112.5, -55.5, 115.5, -50.5),
          pars = c("T2M_MAX", "T2M_MIN"),
          dates = c("1985-01-01", "1985-02-01"),
          temporal_api = "daily")

The issue was here

<error/tibble_error_incompatible_new_cols>
New columns must be compatible with `.data`.
x New columns have 0 rows.
ℹ `.data` has 1920 rows.
Backtrace:
 1. nasapower::get_power(...)
 2. tibble::add_column(...)

Thanks a lot!

@kauedesousa
Copy link
Member Author

kauedesousa commented Aug 24, 2021

Now, a different type of error, if I change the coordinates to a different region

It goes fine for a single point

get_power(community = "ag",
          lonlat = c(11, 60),
          pars = c("PRECTOTCORR"),
          dates = c("2010-06-01", "2010-07-30"),
          temporal_api = "daily")

But returns no data if I call for a region

get_power(community = "ag",
          lonlat = c(11, 60, 12, 61),
          pars = c("PRECTOTCORR"),
          dates = c("2010-06-01", "2010-07-30"),
          temporal_api = "daily")

Error: Something went wrong with the query, no data were returned. Please see <https://power.larc.nasa.gov> for potential server issues.

Any idea on the origin of this issue?

@adamhsparks
Copy link
Member

adamhsparks commented Aug 24, 2021

Edge case that I didn't discover.

Check the URL that's generated, for the error message. It should be passing it along but it's not. Sorry about that. I'll work on this.

https://power.larc.nasa.gov/api/temporal/daily/regional?parameters=PRECTOTCORR&community=ag&start=20100601&end=20100730&latitude-min=60.5&latitude-max=61.5&longitude-min=11.5&longitude-max=12.5&format=csv&time_standard=utc&user&user=test

"Please provide at least a 2 degree range in latitude; otherwise use the point endpoint."

adamhsparks added a commit that referenced this issue Dec 5, 2021
@adamhsparks
Copy link
Member

closed with 7ac4cba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants