how to resolve the HTTP 422 error with the NASAPOWER get_power function in R

391 views Asked by At

I am getting the Error: Unprocessable Entity (HTTP 422) with the get_power function (global meteorology and surface solar energy climatology data) of the NASAPOWER library in R

library(nasapower)
ag_d <- get_power(
  community = "AG",
  lonlat = c(151.81, -27.48),
  pars = c("RH2M", "T2M", "PRECTOT"),
  dates = "1985-01-01",
  temporal_average = "DAILY"
)

Any suggestions!

1

There are 1 answers

2
José Lucas Safanelli On BEST ANSWER

NASA Power API version 2 was released. The maintainer of nasapower R's package has been updating the codes. Take a look at the github repo. You can find, for example, that PRECTOT was changed to PRECTOTCORR. You can also find the progress here.

They recommend using the in-development version:

if (!require("remotes")) {
  install.packages("remotes")
}

remotes::install_github("ropensci/nasapower")

library("nasapower")

daily_ag <- get_power(community = "ag",
                      lonlat = c(151.81, -27.48),
                      pars = c("RH2M", "T2M", "PRECTOTCORR"),
                      dates = "1985-01-01",
                      temporal_api = "daily"
                      )
daily_ag

Best