Authors: Noam Ross and Evan A. Eskew

citesdb is an R package to conveniently analyze the full CITES shipment-level wildlife trade database, available at https://trade.cites.org/. This data consists of over 40 years and 20 million records of reported shipments of wildlife and wildlife products subject to oversight under the Convention on International Trade in Endangered Species of Wild Fauna and Flora. The source data are maintained by the UN Environment World Conservation Monitoring Centre.

Installation

Install the citesdb package with this command:

devtools::install_github("ropensci/citesdb")

Note that since citesdb installs a source dependency from GitHub, you will need package build tools.

Usage

Getting the data

When you first load the package, you will see a message like this:

Not to worry, just do as it says and run cites_db_download(). This will fetch the most recent database from online, an approximately 158 MB download. It will expand to over 1 GB in the local database. During the download and database building, up to 3.5 GB of disk space may be used temporarily.

Using the database

Once you fetch the data, you can connect to the database with the cites_db() command. The cites_shipments() command loads a remote tibble that is backed by the database but is not loaded into R. You can use this command to analyze CITES data without ever loading it into memory, gathering your results with the dplyr function collect(). For example:

(Note that running collect() on all of cites_shipments() will load a >3 GB data frame into memory!)

The back-end database, MonetDB, is very fast and powerful, making analyses on such large data quite snappy using normal desktops and laptops. Here’s the timing of the above query, which processes over 20 million records:

If you are using a recent version of RStudio interactively, loading the CITES package also brings up a browsable pane in the “Connections” tab that lets you explore and preview the database, as well as interact with it directly via SQL commands.

If you don’t need any of the bells and whistles of this package, you can download the raw data as a single compressed TSV file from the releases page, or as a .zip file of many CSV files from the original source at https://trade.cites.org/.

Metadata

The package database also contains tables of field metadata, codes used, and CITES countries. This information comes from “A guide to using the CITES Trade Database”, on the CITES website. Convenience functions cites_metadata(), cites_codes(), and cites_parties() access this information:

More information on the release of shipment-level CITES data can be found in the ?guidance help file.

Citation

If you use citesdb in a publication, please cite both the package and source data:

Ross, Noam, Evan A. Eskew, and Nicolas Ray. 2019. citesdb: A high-performance database of shipment-level CITES trade data. R package v0.2.0. EcoHealth Alliance: New York, NY. https://github.com/ropensci/citesdb. doi:10.5281/zenodo.2630836

UNEP-WCMC (Comps.) 2019. Full CITES Trade Database Download. Version 2019.2. CITES Secretariat, Geneva, Switzerland. Compiled by UNEP-WCMC, Cambridge, UK. Available at: https://trade.cites.org.

Contributing

Have feedback or want to contribute? Great! Please take a look at the contributing guidelines before filing an issue or pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Created by EcoHealth Alliance