Import data from New Zealand's National Climate Database via CliFlo into R for exploring, analysis, plotting, exporting to KML, CSV, or other software.


The clifro package is intended to simplify the process of data extraction, formatting and visualisation from the CliFlo web portal. It requires the user to build a query consisting of 3 main components; the user, the datatype(s) and the station(s). These are then combined using the cf_query function that sends the query to the CliFlo database and returns the results that can easily be plotted using generic plotting functions.

This package requires the user to already have a current subscription to the National Climate Database unless a public user is sought, where data is limited to Reefton Ews. Subscription is free and can obtained from

See also

cf_user, cf_datatype, and cf_station for choosing the clifro user, datatypes and stations, respectively.


if (FALSE) { # Create a public user ---------------------------------------------------- public.user = cf_user() # Defaults to "public" public.user # Select datatypes -------------------------------------------------------- # 9am Surface wind (m/s) wind.dt = cf_datatype(2, 1, 4, 1) # Daily Rain rain.dt = cf_datatype(3, 1, 1) # Daily temperature extremes temp.dt = cf_datatype(4, 2, 2) # Combine them together all.dts = wind.dt + rain.dt + temp.dt all.dts # Select the Reefton Ews station ------------------------------------------ = cf_station() # Submit the query -------------------------------------------------------- # Retrieve all data from ~ six months ago at 9am = cf_query(public.user, all.dts,, paste(as.Date(Sys.time()) - 182, "9")) # Plot the data ----------------------------------------------------------- # Plot the 9am surface wind data (first dataframe in the list) ---[1] # all identical - although passed to different methods plot( #plot,cfDataList,missing-method plot(, 1) #plot,cfDataList,numeric-method plot([1]) #plot,cfData,missing-method --> plot,cfWind,missing-method speed_plot( direction_plot( # Plot the daily rain data (second dataframe in the list) ---[2] # With runoff and soil deficit plot(, 2) # Just plot amount of rain (mm) plot(, 2, include_runoff = FALSE) # Plot the hourly temperature data (third dataframe in the list) --- plot(, 3) # Pass an argument to ggplot2::theme library(ggplot2) # for element_text() plot(, 3, text = element_text(size = 18)) }