Build Status cran version Documentation Status Downloads + Downloads (old package name)

R interface to the Data Retriever.

The Data Retriever automates the tasks of finding, downloading, and cleaning up publicly available data, and loads them or stores them in variety of databases or flat file formats. This lets data analysts spend less time cleaning up and managing data, and more time analyzing it.

This package lets you work with the Data Retriever (written in Python) using R, so that the Retriever’s data handling can easily be integrated into R workflows.


The rdataretriever is an R wrapper for the Python package, Data Retriever. This means that Python and the retriever Python package need to be installed first.

Basic Installation

If you just want to use the Data Retriever from within R follow these instuctions run the following commands in R. This will create a local Python installation that will only be used by R and install the needed Python package for you.

After running these commands restart R.

Advanced Installation for Python Users

If you are using Python for other tasks you can use rdataretriever with your existing Python installation (though the basic installation above will also work in this case by creating a separate miniconda install and Python environment).

Install the retriever Python package

Install the retriever Python package into your prefered Python environment using either conda (64-bit conda is required):

or pip:

Select the Python environment to use in R

rdataretriever will try to find Python environments with retriever (see the reticulate documentation on order of discovery for more details) installed. Alternatively you can select a Python environment to use when working with rdataretriever (and other packages using reticulate).

The most robust way to do this is to set the RETICULATE_PYTHON environment variable to point to the preferred Python executable:

This command can be run interactively or placed in .Renviron in your home directory.

Alternatively you can do select the Python environment through the reticulate package for either conda:

or virtualenv:

You can check to see which Python environment is being used with:

Installing Spatial Datasets

Set-up and Requirements


  • PostgreSQL with PostGis, psql(client), raster2pgsql, shp2pgsql, gdal,

The rdataretriever supports installation of spatial data into Postgres DBMS.

  1. Install PostgreSQL and PostGis

    To install PostgreSQL with PostGis for use with spatial data please refer to the OSGeo Postgres installation instructions.

    We recommend storing your PostgreSQL login information in a .pgpass file to avoid supplying the password every time. See the .pgpass documentation for more details.

    After installation, Make sure you have the paths to these tools added to your system’s PATHS. Please consult an operating system expert for help on how to change or add the PATH variables.

    For example, this could be a sample of paths exported on Mac:

    #~/.bash_profile file, Postgres PATHS and tools.
    export PATH="/Applications/${PATH}"
    export PATH="$PATH:/Applications/"
  2. Enable PostGIS extensions

    If you have Postgres set up, enable PostGIS extensions. This is done by using either Postgres CLI or GUI(PgAdmin) and run

    For psql CLI shell psql -d yourdatabase -c "CREATE EXTENSION postgis;" psql -d yourdatabase -c "CREATE EXTENSION postgis_topology;"

    For GUI(PgAdmin)

    For more details refer to the PostGIS docs.

Sample commands

rdataretriever::install_postgres('harvard-forest') # Vector data
rdataretriever::install_postgres('bioclim') # Raster data

# Install only the data of USGS elevation in the given extent
rdataretriever::install_postgres('usgs-elevation', list(-94.98704597353938, 39.027001800158615, -94.3599408119917, 40.69577051867074))


rdataretriever allows users to save a dataset in its current state which can be used later.

Note: You can save your datasets in provenance directory by setting the environment variable PROVENANCE_DIR

Commit a dataset

To commit directly to provenance directory:

Log of committed dataset in provenance directory

Install a committed dataset

Datasets stored in provenance directory can be installed directly using hash value

Using Docker Containers

To run the image interactively

docker-compose run --service-ports rdata /bin/bash

To run tests

docker-compose run rdata Rscript load_and_test.R


Make sure you have tests passing on R-oldrelease, current R-release and R-devel

To check the package

R CMD Build #build the package
R CMD check  --as-cran --no-manual rdataretriever_[version]tar.gz

To Test

setwd("./rdataretriever") # Set working directory
# install all deps
# install.packages("reticulate")
install.packages(".", repos = NULL, type="source")

To get citation information for the rdataretriever in R use citation(package = 'rdataretriever')


A big thanks to Ben Morris for helping to develop the Data Retriever. Thanks to the rOpenSci team with special thanks to Gavin Simpson, Scott Chamberlain, and Karthik Ram who gave helpful advice and fostered the development of this R package. Development of this software was funded by the National Science Foundation as part of a CAREER award to Ethan White.