| Type: | Package |
| Title: | NASA POWER API Client |
| Version: | 4.3.0 |
| Description: | An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resources) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web-based data viewer and web access, please see https://power.larc.nasa.gov/. |
| License: | MIT + file LICENSE |
| URL: | https://codeberg.org/ropensci/nasapower, https://docs.ropensci.org/nasapower/ |
| BugReports: | https://codeberg.org/ropensci/nasapower/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | cli, crul, lubridate, readr, rlang, tibble (≥ 3.0.2), yyjsonr |
| Suggests: | knitr, purrr, rmarkdown, spelling, testthat (≥ 3.0.0), vcr (≥ 0.6.0), webmockr, withr |
| VignetteBuilder: | knitr |
| Config/Needs/build: | moodymudskipper/devtag |
| Config/Needs/documentation: | roxylint |
| Config/roxygen2/version: | 8.0.0 |
| Config/roxylint: | list(linters = roxylint::tidy) |
| Config/testthat/edition: | 3 |
| Config/testthat/parallel: | true |
| Encoding: | UTF-8 |
| Language: | en-US |
| NeedsCompilation: | no |
| Repository: | CRAN |
| X-schema.org-applicationCategory: | Tools |
| X-schema.org-isPartOf: | https://ropensci.org |
| X-schema.org-keywords: | NASA, meteorological-data, weather, global, weather, weather-data, meteorology, NASA-POWER, agroclimatology, earth-science, data-access, climate-data |
| Packaged: | 2026-06-02 06:27:12 UTC; 283204f |
| Author: | Adam H. Sparks |
| Maintainer: | Adam H. Sparks <adamhsparks@gmail.com> |
| Date/Publication: | 2026-06-02 07:50:30 UTC |
nasapower: NASA POWER API Client
Description
An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resources) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web-based data viewer and web access, please see https://power.larc.nasa.gov/.
Author(s)
Maintainer: Adam H. Sparks adamhsparks@gmail.com (ORCID)
Authors:
Adam H. Sparks adamhsparks@gmail.com (ORCID)
Other contributors:
Scott Chamberlain myrmecocystus@gmail.com (ORCID) (Scott Chamberlain reviewed nasapower for rOpenSci, see <https://github.com/ropensci/software-review/issues/155>.) [reviewer]
Hazel Kavili (Hazel Kavili reviewed nasapower for rOpenSci, see <https://github.com/ropensci/software-review/issues/155>.) [reviewer]
Alison Boyer (Alison Boyer reviewed nasapower for rOpenSci, see <https://github.com/ropensci/software-review/issues/155>.) [reviewer]
Fernando Miguez femiguez@iastate.edu (ORCID) (Fernando Miguez provided assistance in identifying improper missing value handling in the POWER data, see <https://github.com/femiguez/apsimx/pull/26>.) [contributor]
Maëlle Salmon (ORCID) (Maëlle Salmon contributed a patch to fix issues with using the R package, 'vcr', for testing the API queries, see <https://github.com/ropensci/nasapower/pull/64>.) [contributor]
Phillip D. Alderman phillip.alderman@okstate.edu (ORCID) (Phillip Alderman contributed a patch to fix an issue with, 'The 'file' argument of 'vroom()' must use 'I()' for literal data as of vroom 1.5.0.', see <https://github.com/ropensci/nasapower/pull/67>.) [contributor]
Aleksandar Blagotić alex@rapporter.net (Author of the CRAN package 'rapportools', from which the '.is_boolean()' was derived.) [contributor, copyright holder]
Gergely Daróczi daroczig@rapporter.net (Author of the CRAN package 'rapportools', from which the '.is_boolean()' was derived.) [contributor, copyright holder]
Curtin University (ROR) (http://www.curtin.edu.au/) [copyright holder]
See Also
Useful links:
Report bugs at https://codeberg.org/ropensci/nasapower/issues
Get NASA POWER data from the POWER API
Description
Get POWER global meteorology and surface solar energy climatology data and return a tidy data frame tibble object. All options offered by the official POWER API are supported. Requests are formed to submit one request per point. There is no need to make synchronous requests for multiple parameters for a single point or regional request. See section on “Rate Limiting” for more.
Usage
get_power(
community,
pars,
lonlat,
temporal_api = "daily",
dates = NULL,
site_elevation = NULL,
wind_elevation = NULL,
wind_surface = NULL,
time_standard = "LST"
)
Arguments
community |
A case-insensitive character vector providing community name: “AG”, “RE” or “SB”. See argument details for more. |
pars |
case-insensitive character vector of solar, meteorological or
climatology parameters to download. When requesting a single point of x,
y coordinates, a maximum of twenty (20) |
lonlat |
A numeric vector of geographic coordinates for a cell or region entered as x, y (longitude, latitude) coordinates. See argument details for more. |
temporal_api |
A case-insensitive character vector providing the temporal API end-point for data being queried, supported values are “hourly”, “daily”, “monthly” or “climatology”. Defaults to “daily”. See argument details for more. |
dates |
A character vector of start and end dates in that order, |
site_elevation |
A user-supplied value for elevation at a single point
in metres. If provided this will return a corrected atmospheric pressure
value adjusted to the elevation provided. Only used with |
wind_elevation |
A user-supplied value for elevation at a single point
in metres. Wind elevation values are required to be between 10 and 300
metres. Only used with |
wind_surface |
A user-supplied wind surface for which the corrected
wind-speed is to be supplied. See |
time_standard |
POWER provides two different time standards.
|
Value
A data frame as a POWER.Info class, an extension of the
tibble, object of POWER data including location, dates
(not including “climatology”) and requested parameters; a decorative
header of metadata is included in this object.
Argument details for “community”
There are three valid values, one must be supplied. This will affect the units of the parameter and the temporal display of time series data.
- ag
Provides access to the Agroclimatology Archive, which contains industry-friendly parameters formatted for input to crop models.
- sb
Provides access to the Sustainable Buildings Archive, which contains industry-friendly parameters for the buildings community to include parameters in multi-year monthly averages.
- re
Provides access to the Renewable Energy Archive, which contains parameters specifically tailored to assist in the design of solar and wind powered renewable energy systems.
Argument details for temporal_api
There are four valid values.
- hourly
The hourly average of
parsby hour, day, month and year, the time zone is LST by default.- daily
The daily average of
parsby day, month and year.- monthly
The monthly average of
parsby month and year.- climatology
Provide parameters as 22-year climatologies (solar) and 30-year climatologies (meteorology); the period climatology and monthly average, maximum, and/or minimum values.
Argument details for lonlat
- For a single point
To get a specific cell, 1/2 x 1/2 degree, supply a length-two numeric vector giving the decimal degree longitude and latitude in that order for data to download,
e.g.,lonlat = c(-179.5, -89.5).- For regional coverage
To get a region, supply a length-four numeric vector as lower left (lon, lat) and upper right (lon, lat) coordinates, e.g.,
lonlat = c(xmin, ymin, xmax, ymax)in that order for a given region, e.g., a bounding box for the south western corner of Australia:lonlat = c(112.5, -55.5, 115.5, -50.5). *Maximum area processed is 4.5 x 4.5 degrees (100 points).- For global coverage
To get global coverage for “climatology”, supply “global” while also specifying “climatology” for the
temporal_api.
Argument details for dates
if one date only is provided, it
will be treated as both the start date and the end date and only a single
day's values will be returned, e.g., dates = "1983-01-01". When
temporal_api is set to “MONTHLY”, use only two year values (YYYY),
e.g. dates = c(1983, 2010). This argument should not be used when
temporal_api is set to “climatology” and will be ignored if set.
wind_surface
There are 17 surfaces that may be used for corrected wind-speed values using the following equation:
WSC_hgt = WS_10 m\times(\frac{hgt}{WS_50m})^\alpha
Valid surface types are described here.
- vegtype_1
35-m broadleaf-evergreen trees (70% coverage)
- vegtype_2
20-m broadleaf-deciduous trees (75% coverage)
- vegtype_3
20-m broadleaf and needleleaf trees (75% coverage)
- vegtype_4
17-m needleleaf-evergreen trees (75% coverage)
- vegtype_5
14-m needleleaf-deciduous trees (50% coverage)
- vegtype_6
Savanna:18-m broadleaf trees (30%) & groundcover
- vegtype_7
0.6-m perennial groundcover (100%)
- vegtype_8
0.5-m broadleaf shrubs (variable %) & groundcover
- vegtype_9
0.5-m broadleaf shrubs (10%) with bare soil
- vegtype_10
Tundra: 0.6-m trees/shrubs (variable %) & groundcover
- vegtype_11
Rough bare soil
- vegtype_12
Crop: 20-m broadleaf-deciduous trees (10%) & wheat
- vegtype_20
Rough glacial snow/ice
- seaice
Smooth sea ice
- openwater
Open water
- airportice
Airport: flat ice/snow
- airportgrass
Airport: flat rough grass
Rate limiting
The POWER API endpoints limit
queries to prevent server overloads due to repetitive and rapid requests.
If you find that the API is throttling your queries, I suggest
that you investigate the use of limit_rate() from ratelimitr to
create self-limiting functions that will respect the rate limits that the
API has in place. It is considered best practice to check the
POWER website for the
latest rate limits as they differ between temporal APIs and may
change over time as the project matures.
Note
The associated metadata shown in the decorative header are not saved if the data are exported to a file format other than a native R data format, e.g., .Rdata, .rda or .rds.
Author(s)
Adam H. Sparks adamhsparks@gmail.com
References
https://power.larc.nasa.gov/docs/methodology/ https://power.larc.nasa.gov
Examples
# Fetch daily "AG" community temperature, relative humidity and
# precipitation for January 1 1985 at Kingsthorpe, Queensland, Australia
ag_d <- get_power(
community = "AG",
lonlat = c(151.81, -27.48),
pars = c("RH2M", "T2M", "PRECTOTCORR"),
dates = "1985-01-01",
temporal_api = "daily"
)
ag_d
# Fetch single point climatology for air temperature
ag_c_point <- get_power(
community = "AG",
pars = "T2M",
c(151.81, -27.48),
temporal_api = "climatology"
)
ag_c_point
# Fetch interannual solar cooking parameters for a given region
interannual_clrsky <- get_power(
community = "re",
lonlat = c(150.5, -28.5, 153.5, -25.5),
dates = c("1984", "1985"),
temporal_api = "monthly",
pars = "CLRSKY_SFC_SW_DWN"
)
interannual_allsky <- get_power(
community = "re",
lonlat = c(150.5, -28.5, 153.5, -25.5),
dates = c("1984", "1985"),
temporal_api = "monthly",
pars = "ALLSKY_SFC_SW_DWN"
)
interannual_list <- list(interannual_clrsky, interannual_allsky)
interannual_re <- do.call("rbind", interannual_list)
interannual_re
nasapower Options
Description
The behaviour of certain nasapower functions can be controlled through
package-level options. These are set via base::options() and retrieved
internally using base::getOption(). All options have sensible defaults and
do not need to be set for normal use.
Options can be set for a single session:
options(nasapower.timeout = 60L)
Or persistently across sessions by adding them to your .Rprofile:
# ~/.Rprofile options( nasapower.timeout = 60L, nasapower.timeout.connect = 10L, nasapower.max_tries = 3L )
Options
nasapower.timeout-
Maximum time in seconds to wait for data to be transferred from the POWER API before the request is aborted. This controls the overall transfer timeout, not the time to establish a connection (see
nasapower.timeout.connect).Should be a single positive number. Non-integer values are coerced to integer. If an invalid value is supplied a warning is issued and the default is used. Default: `10L`. Increase this if you are retrieving large regional datasets or are on a slow connection.
nasapower.timeout.connect-
Maximum time in seconds to wait for a connection to the POWER API to be established before the request is aborted. A connection that takes longer than this is unlikely to succeed, so this is intentionally kept shorter than
nasapower.timeout.Should be a single positive number. Non-integer values are coerced to integer. If an invalid value is supplied a warning is issued and the default is used. Default: `5L`.
nasapower.max_tries-
Maximum number of times a failed request will be retried before an error is thrown. Retries are handled automatically by the underlying HTTP client and apply to transient failures (e.g., network timeouts, HTTP 429 or 503 responses).
Should be a single positive integer >= 1. A value of `1L` disables retries. If an invalid value is supplied a warning is issued and the default is used. Default: `6L`. Consider reducing this in automated pipelines where you would prefer to fail fast and handle retries externally.
Cumulative wait time
The worst-case time before an error is surfaced to the user is approximately:
nasapower.max_tries * nasapower.timeout
With defaults (6L * 10L) this is roughly 60 seconds. If you increase
either value, be aware of the combined effect on how long your code may
block.
Query the POWER API for Detailed Information on Available Parameter Groupings
Description
Queries the POWER API returning detailed information on available parameter
groupings. Results are grouped by community followed by temporal API, or if
global = TRUE, grouped by climatology then by available parameter types.
Usage
query_groupings(global = FALSE)
Arguments
global |
Boolean; should the query return global parameter groupings and
attribute information? Defaults to |
Value
A list object of information on parameter groupings in the POWER API.
Author(s)
Adam H. Sparks, adamhsparks@gmail.com
Examples
# Fetch groupings for parameters
query_groupings()
# Fetch groupings for global parameters
query_groupings(global = TRUE)
Query the POWER API for Detailed Information on Available Parameters
Description
Queries the POWER API returning detailed information on available parameters.
For a list of all available parameters, see parameters.
Usage
query_parameters(
community = NULL,
pars = NULL,
temporal_api = NULL,
metadata = FALSE
)
Arguments
community |
An optional character vector providing community name: "ag", "sb", or "re". |
pars |
An optional character string of a single solar, meteorological, or climatology parameter to query. If not provided, all parameters are returned. |
temporal_api |
An optional character vector indicating the temporal API endpoint for data being queried. Supported values are "hourly", "daily", "monthly", or "climatology". |
metadata |
Boolean; retrieve extra parameter metadata? This is only
applicable if you supply both |
Value
A list object of information for the requested parameter(s), community(ies), and temporal API(s).
Argument details for temporal_api
There are four valid values:
- hourly
The hourly average of parameters by hour, day, month, and year.
- daily
The daily average of parameters by day, month, and year.
- monthly
The monthly average of parameters by month and year.
- climatology
Parameters as 22-year climatologies (solar) and 30-year climatologies (meteorology); includes period climatology and monthly average, maximum, and/or minimum values.
Author(s)
Adam H. Sparks, adamhsparks@gmail.com
Examples
# Fetch complete attribute information for "T2M"
query_parameters(pars = "T2M")
# Fetch temporal and community-specific attribute information
# for "T2M" in the "ag" community for the "hourly" temporal API
query_parameters(
pars = "T2M",
community = "ag",
temporal_api = "hourly"
)
# Fetch all parameters in the "ag" community for "hourly" temporal API
query_parameters(
community = "ag",
temporal_api = "hourly"
)
Query the POWER API for Detailed Information on Wind Type Surfaces
Description
Queries the POWER API returning detailed information on all (or just one) wind elevation surface alias and attribute information.
Usage
query_surfaces(surface_alias = NULL)
Arguments
surface_alias |
An optional character vector providing a wind surface alias available from the POWER API. All values are returned if not provided. |
Value
A list object of information for the requested wind surface(s).
Author(s)
Adam H. Sparks, adamhsparks@gmail.com
Examples
# Fetch all wind surface information
query_surfaces()
# Fetch surface information for "airportgrass"
query_surfaces(surface_alias = "airportgrass")