nasapower

Adam H Sparks

Introduction

nasapower aims to make it quick and easy to automate downloading NASA POWER global meteorology, surface solar energy amd climatology data data in your R session as a tidy data frame for analysis and use in modelling or other purposes using get_power(). POWER (Prediction Of Worldwide Energy Resource) data are freely available for download through a web interface at a resolution of 1/2 arc degree longitude by 1/2 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 International Consortium for Agricultural Systems Applications (ICASA) format text files for use in the Decision Support System for Agrotechnology Transfer (DSSAT) framework, create_met().

Using get_power to Fetch POWER Data

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

Global data are only available for the climatology temporal_average, setting this argument as such will fetch global data.

Fetch global “AG”" climatology for temperature and relative humidity.

Note the associated metadata in the data frame header 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

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.

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.

create_met(lonlat = c(151.81, -27.48),
           dates = c("1985-01-01", "1985-12-31"),
           dsn = tempdir(),
           file_out = "Kingsthorpe.met")

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.

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.

create_icasa(lonlat = c(151.81, -27.48),
             dates = c("1985-01-01", "1985-12-31"),
             dsn = tempdir(),
             file_out = "Kingsthorpe_ICASA.txt")

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 Regional Data to a raster Object

Using lapply and split it is easy to create stacks of raster objects from a regional query.

Plot all the items in the stack.

Converting Global Climatology to a raster Object

Converting global climatology to a raster objects is as simple as querying and then converting the resulting tibble to a raster object using raster::rasterFromXYZ()*. Illustrated here using the climatology_ag object previously created are two methods.

*: You may experience issues if you have <16GB RAM available converting the entire object to a raster::brick().

For low-memory systems

For low-memory systems (e.g. a recent Apple Mac computer with 8GB RAM), it is useful to have as much of your R global environment free from objects that take much memory and make sure other processes are not using system memory.

Using indexing pick the month or annual value and create a raster object.

For systems with more available memory

For systems with RAM of ~16GB or more, it is possible to create a raster::brick() of the resulting POWER query. To do so, subset the tibble() for the desired parameter and drop the PARAMETER column.

References

https://power.larc.nasa.gov

https://power.larc.nasa.gov/documents/POWER_Data_v8_methodology.pdf