Introduction

nasapower aims to make it quick and easy to automate downloading NASA POWER global meteorology and surface solar energy climatology data data in your R session as a tidy data frame for analysis and use in modelling or other purposes, get_power(). POWER (Prediction Of Worldwide Energy Resource) data are freely available for download through a web interface at a resolution of 0.5 arc degree longitude by 0.5 arc degree latitude. Two other functions are provided to quickly and easily generate weather.met files from the POWER data for use in the Agricultural Production Systems sIMulator (APSIM), create_met() and ICASA format text files for use in Decision Support System for Agrotechnology Transfer (DSSAT) modelling, create_met().

Using get_power

The get_power() function has five arguments as seen in this example and returns a data frame with a metadata header in the current R session.

Example fetching daily data for a single point

Fetch daily “AG” community temperature, relative humidity and precipitation for January 1985 for Kingsthorpe, Queensland, Australia.

Example fetching daily data for an area

Fetch daily “AG” community relative humidity and temperature for south east Queensland region.

Example fetching interannual data for an area

Fetch interannual solar cooking parameters for south east Queensland region.

Example fetching climatology data

Fetch global AG climatology for temperature.

Note the associated metadata are not saved if the data are exported to a file format other than an R data format, e.g., .Rdata, .rda or .rds.

Description of parameters for get_power

  • community, a text string with valid values of: “AG” (Agroclimatology), “SSE” (Surface meteorology and Solar Energy) or “SB” (Sustainable Buildings). The selected user community will affect the units of the parameter and the temporal display of time series data (e.g. Agroclimatology will use MJ/m2/day for radiation units, while SSE and SB use kW/m2/day as units).

  • lonlat

    • For a single point To get a specific cell, 1/2 x 1/2 degree, supply a length-2 numeric vector giving the decimal degree longitude and latitude in that order for data to download, e.g., lonlat = c(-89.5, -179.5).

    • For regional coverage To get a region, supply a length-4 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). Max bounding box is 10 x 10 degrees of 1/2 x 1/2 degree data, i.e., 100 points maximum in total.

    • For global coverage To get global coverage for long term monthly averages for the entire globe use Global in place of lonlat values. temporal_average will automatically be set to CLIMATOLOGY if this option is set.

  • pars, A character vector of solar, meteorological or climatology parameters to download. See names(parameters) for a full list of valid values and definitions. Visit the POWER website for the Parameters Table. If downloading CLIMATOLOGY a maximum of 3 pars can be specified at one time for for DAILY and INTERANNUAL a maximum of 20 can be specified at one time.

  • dates, a vector of start and end dates for which to query the POWER API, e.g., dates = c("1983-01-01", "2017-12-31").

  • temporal_average, a character vector of the desired temporal average(s). Valid values are “DAILY”, “INTERANNUAL” and “CLIMATOLOGY”.

Using create_met

The create_met() function wraps get_power(), prepareMet() and writeMet() from the APSIM package to simplify creating .met files from POWER data for use in the APSIM modelling framework.

Four arguments are passed to this function, lonlat, dates, dsn and file_out.

  • lonlat

    • For a single point To get a specific cell, 1/2 x 1/2 degree, supply a length-2 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-4 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). Max bounding box is 10 x 10 degrees of 1/2 x 1/2 degree data, i.e., 100 points maximum in total.

  • dates, a vector of start and end dates for which to query the POWER API, e.g., dates = c("1983-01-01", "2017-12-31").

  • dsn, a file path to the directory for writing the resulting file, .e.g., “~/Documents”. If none is given, defaults to user’s home directory.

  • file_out, a file name for the resulting text file written to disk. If none is provided, defaults to “APSIM.met”

Get POWER values for a single point, Kingsthorpe, Queensland for 1985 and create an APSIM weather.met object suitable for use in APSIM for crop modelling and save it to local disk for use in APSIM modelling.

Using create_icasa

The create_icasa() simplifies a get_power() query to create an ICASA file for use in DSSAT modelling.

Four arguments are passed to this function, lonlat, dates, dsn and file_out.

  • lonlat

    • For a single point To get a specific cell, 1/2 x 1/2 degree, supply a length-2 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-4 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). Max bounding box is 10 x 10 degrees of 1/2 x 1/2 degree data, i.e., 100 points maximum in total.

  • dates, a vector of start and end dates for which to query the POWER API, e.g., dates = c("1983-01-01", "2017-12-31").

  • dsn, a file path to the directory for writing the resulting file, .e.g., “~/Documents”. If none is given, defaults to user’s home directory.

  • file_out, a file name for the resulting text file written to disk. If none is provided, defaults to “ICASA.txt”

Get POWER values for a single point, Kingsthorpe, Queensland for 1985 and create an ICASA text file suitable for use in DSSAT for crop modelling and save it to local disk.

Creating Spatial Objects from get_power

If you require spatial objects to work with, it is rather simple to convert the resulting tidy data frame from get_power() to a spatial object in R using raster::rasterFromXYZ().

Converting Global Climatology to a raster Object

Converting global climatology to a raster::brick is as simple as querying and then converting the resulting tibble to a raster object. Illustrated here using the climatology_ag object previously created.

# create RasterBricks for the individual parameters and drop the parameter field
RH2M <- rasterFromXYZ(subset(climatology_ag, PARAMETER == "RH2M")[, -3])

T2M <- rasterFromXYZ(subset(climatology_ag, PARAMETER == "T2M")[, -3])

PRECIP <- rasterFromXYZ(subset(climatology_ag, PARAMETER == "PRECTOT")[, -3])

Plot the annual values from the resulting RasterBrick() objects.

plot(RH2M$ANN)

plot(T2M$ANN)

plot(PRECIP$ANN)