library(labrador.client)

get_cafri_data(
  product = "agb_3_county",
  region = "3_county"
) |> 
  raster::raster() |> 
  raster::plot()

CAFRI maintains a massive amount of spatial data in the cloud which is useful across multiple projects. Sharing this amount of data over things like Dropbox or Google Drive is impractical, and managing user access to individual files in order to only share smaller pieces sounds like a lot of work. So we built a bespoke data-sharing platform for use within our lab, because that sounded easier.

That platform is named Labrador (because it helps you retrieve your data). In order to download data from Labrador, we also wrote a “client” package which handles all the communication with the service. That’s this package, labrador.client.

In order to download data, you’ll need to first install the package and get a token. This file walks through that process and how to download data once you’re done.

Installation

1. .Rprofile setup

General information on the “.Rprofile” file can be found here or here.

The easiest way to edit your .Rprofile file, whether you already have one or not, is to open Rstudio (or any other R session) and run:

usethis::edit_r_profile()

Next you need to add the following line to your file, save, and restart your current R session:

options(
    repos = c(
      "https://cloud.r-project.org",
      "https://cafri-labs.github.io/drat/"
    )
)

2. Install the package

Run the following in your R session:

install.packages("labrador.client")

3. Request an access token

To access the data in labrador you need need a token. You can request a token from Mike Mahoney or Lucas Johnson in slack, via email, or in person…

You will then receive an email from , with the subject “Labrador API Access Token”. The email will contain a link, and a passphrase to decrypt the secret link. Once you have decrypted the secret link, copy the contents and paste them into an R session. This will write the token to a safe location on your machine, and will be used for all future requests to labrador.

Usage

As part of our documentation-centralization initiatives, instructions on how to use labrador.client now live in the lab manual. The pkgdown site provides a function-level reference.