Easily Download and Visualise Climate Data from CliFlo

CliFlo is a web portal to the New Zealand National Climate Database and provides public access (via subscription) to around 6,500 various climate stations (see < https://cliflo.niwa.co.nz/> for more information). Collating and manipulating data from CliFlo (hence clifro) and importing into R for further analysis, exploration and visualisation is now straightforward and coherent. The user is required to have an internet connection, and a current CliFlo subscription (free) if data from stations, other than the public Reefton electronic weather station, is sought.

Build Status CRAN_Status_Badge codecov.io

New Zealand's National Climate Database, CliFlo holds data from about 6500 climate stations, with observations dating back to 1850. CliFlo returns raw data at ten minute, hourly, and daily frequencies. CliFlo also returns statistical summaries, inclusive of about eighty different types of monthly and annual statistics and six types of thirty−year normals.

The clifro package is designed to minimise the hassle in downloading data from CliFlo. It does this by providing functions for the user to log in, easily choose the appropriate datatypes and stations, and then query the database. Once the data have been downloaded, they are stored as specific objects in R with the primary aim to ensure data visualisation and exploration is done with minimal effort and maximum efficiency.

This package extends the functionality of CliFlo by returning stations resulting from simultaneous searches, the ability to visualise where these climate stations are by exporting to KML files, and elegant plotting of the climate data. The vignettes and help files are written with the intention that even inexperienced R users can use clifro easily. Exporting the climate data from R is fairly easy and for more experienced useRs, automated updating of spreadsheets or databases can be made much easier.

Free CliFlo Subscription

A current CliFlo subscription is recommended for clifro, otherwise data from only one station is available. The subscription is free and lasts for 2 years or 2,000,000 rows without renewal, which enables access to around 6,500 climate stations around New Zealand and the Pacific.

Note this package requires internet access for connecting to the National Climate Database web portal.

Installation in R

# Or the latest development version
# Then load the package

Getting Started

The following small example shows some of the core functionality in clifro.

Where are the climate stations?

We can search for climate stations anywhere in New Zealand and return the station information in the form of a KML file. For example, we can return all the climate stations (current and historic) in the greater Auckland region.

all.auckland.st = cf_find_station("Auckland", search = "region", status = "all")
cf_save_kml(all.auckland.st, "all_auckland_stations")

All Auckland Climate Stations

Note the open stations have green markers and the closed stations have red markers.

Download and visualise public climate data

The only station available for unlimited public access to climate data is the Reefton electronic weather station (EWS). We can download the 2014 wind and rain data and easily visualise the results very easily.

public.cfuser = cf_user()
# Choose the datatypes
daily.wind.rain.dt = cf_datatype(c(2, 3), c(1, 1), list(4, 1), c(1, NA))
# Choose the Reefton EWS station
reefton.st = cf_station()
# Send the query to CliFlo and retrieve the data
daily.datalist = cf_query(user = public.cfuser, 
                          datatype = daily.wind.rain.dt, 
                          station = reefton.st,
                          start_date = "2012-01-01 00",
                          end_date = "2013-01-01 00")
#> connecting to CliFlo...
#> reading data...
#> UserName is = public
#> Number of charged rows output = 0
#> Number of free rows output = 732
#> Total number of rows output = 732
#> Copyright NIWA 2018 Subject to NIWA's Terms and Conditions
#> See: http://clifloecd1.niwa.co.nz/pls/niwp/doc/terms.html
#> Comments to: [email protected]
# Have a look at what data is now available
#> List containing clifro data frames:
#>               data      type              start                end rows
#> df 1) Surface Wind  9am only (2012-01-01  9:00) (2012-12-31  9:00)  366
#> df 2)         Rain     Daily (2012-01-01  9:00) (2012-12-31  9:00)  366
# Plot the data using default plotting methods
plot(daily.datalist)     # For the first dataframe  (Surface Wind)

plot(daily.datalist, 2)  # For the second dataframe (Rain)

For more details and reproducible examples, see the technical report for how to use clifro, including choosing datatypes, stations, saving locations as KML files and easy, elegant plotting for various different climate and weather data.

# View the clifro demo
# Read the 'Introduction to clifro' vignette

Contributor Code of Conduct

The clifro package is released with a contributor code of conduct. By participating in this project you agree to abide by its terms.


To cite package ‘clifro’ in publications use:
Seers B and Shears N (2015). “New Zealand's Climate Data in R - An Introduction to clifro.” The University of Auckland, Auckland, New
Zealand. <URL: http://stattech.wordpress.fos.auckland.ac.nz/2015-02-new-zealands-climate-data-in-r-an-introduction-to-clifro/>.
A BibTeX entry for LaTeX users is
    title = {New Zealand's Climate Data in R --- An Introduction to clifro},
    author = {Blake Seers and Nick Shears},
    institution = {The University of Auckland},
    address = {Auckland, New Zealand},
    year = {2015},
    url = {http://stattech.wordpress.fos.auckland.ac.nz/2015-02-new-zealands-climate-data-in-r-an-introduction-to-clifro/},


clifro 3.2-0 (25-Jul-2018)

Bug Fixes

  • Fixed issue #14
  • Updated links in Rd files to ensure no warnings when building package.
  • clifro no longer tests whether or not you have Google Earth installed.

Minor Improvements

  • clifro has had troubles with installation on certain operating systems due to the XML package (issue #19). The XML and selectr dependencies have now been replaced with xml2 and magrittr.
  • Updated vignettes.

clifro 3.1-5 (04-Oct-2017)

Bug Fixes

  • Fixed issue #14

clifro 3.1-4 (21-April-2017)

Bug Fixes

  • Fixed issue #13

clifro 3.1-3 (16-March-2017)


  • Reorganise package structure to include README figures to be shipped with the package so that the upcoming version of R can compile them locally.

clifro 3.1-2 (09-January-2017)

Bug Fixes

  • Fixed issue #7

clifro 3.1-0 (14-December-2016)

Minor Improvements

  • Curl options can now be passed to all curl handles that are initiated by clifro. This means the curl options are not overwritten every time a new clifro function is called. Curl options are passed to clifro using the cf_curl_opts function, which is passed directly to the RCurl::curlOptions() function.

Bug Fixes

  • Requesting combined datatypes now works (issue #4). Note there is no default plot method for this datatype as they are essentially combinations of other datatypes.
  • Fix bug that hung R if a datatype without any rows was requested -- Fixed issue #6

clifro 3.0-0 (10-August-2016)

Minor Improvements

  • Allow expressions in legend title for windrose

Major Bug Fixes

  • HTTPS required due to a recent change in NIWA's proxy server -- Fixed Issue #3. As a result older versions of clifro don't seem to work on Windows due to an SSL certificate problem.

Minor Bug Fixes

  • cf_find_station correctly gives distances instead of longitudes

clifro 2.4-1 (15-January-2016)

Minor Improvements

  • Update citation information

clifro 2.4-0 (05-March-2015)

Bug Fixes

  • Bug fixed for subsetting cfStation using [

clifro 2.2.3 (04-March-2015)

  • Start using NEWS to document changes to clifro

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.