Skip to content

Repository files navigation

PRIOGRID

Note

PRIOGRID v.3.0.2 is a Beta version. Please report any issues and we will aim to fix them as soon as possible.

An R-package for collecting and standardizing open spatial data into a common grid format.

Resources:

What's New in PRIOGRID v.3.x

  • Better metadata handling — Stores information about data licenses, citations, and download URLs. Automatically downloads data and handles local data with user-specified options.
  • R, not SQL — More researchers know R, and the package leverages excellent spatial-data infrastructure with sf, terra, and exactextractr.
  • Flexible spatio-temporal configuration — Change resolution, extent, and projection to test the modifiable areal unit problem or create tailored datasets (e.g., area-equal projections for polar regions).
  • PRIOGRID is a research tool, not just a dataset.
  • Efficient, self-describing outputs — Variables are distributed as Cloud-Optimized GeoTIFFs. The tabular tables (a static wide table and Hive-partitioned Parquet for time-varying data) are built locally from those GeoTIFFs on first read, after which read_pg_timevarying() pushes year/date/cell/variable filters down to Arrow before loading.

Installation

Install PRIOGRID from GitHub using remotes or renv:

install.packages("renv")
renv::install("prio-data/priogrid")

Optional R Packages

terra, sf, and exactextractr are listed in Suggests and are not installed automatically. They are only required for spatial functionality (working with rasters, extent-based subsetting, and building the tabular tables from the downloaded GeoTIFFs on first read) and will be requested the first time you use a function that needs them.

Troubleshooting Installation

terra, sf, and exactextractr depend on system-level geo-libraries. If installation of these packages fails, refer to their installation guides:

If you continue to experience issues after following these guides, please file an issue.

SSL Certificate Issues

If you encounter SSL certificate errors when downloading data, try:

  1. Install system certificates:

Mac (Homebrew users):

brew update
brew install ca-certificates

Linux (Ubuntu/Debian):

sudo apt-get update
sudo apt-get install ca-certificates
  1. Install CURL R-package from source:
install.packages("curl", type = "source")

Getting Started

Set a local folder for PRIOGRID to store downloaded and processed data (this persists across R sessions):

library(priogrid)

pg_set_rawfolder("/path/to/your/data/folder")

Browse available variables:

pgvariables

Plot a variable (this will automatically download the required data to the folder you have set).

plot_pgvariable("cru_tmp", "2010-12-31", extent = "Asia", add_borders = T)

Read in raw-data:

df <- read_cshapes()

Download the official release and read it into R in tabular format:

pg_static      <- read_pg_static()
pg_timevarying <- read_pg_timevarying()

The first read_pg_*() call builds the tabular tables from the downloaded GeoTIFFs (requires terra) and caches them; later reads use the cache and need only arrow.

The full pg_timevarying table takes ~8.5GB RAM to load, so users might experience errors when loading the full table. You can load only the rows and columns you need, however. Filters push down to Arrow before anything is collected:

pg_sub <- read_pg_timevarying(
  years     = 2010:2015,
  extent    = c(xmin = -20, xmax = 55, ymin = -35, ymax = 40),
  variables = "cru_tmp"
)

Documentation

Full documentation is available in the package vignettes:

Vignette Description
Getting Started Setup, downloading, and reading tabular data
Accessing as Rasters Working with individual variables using terra
Citations and Bibliography Citing data providers in publications
Custom Configurations Custom resolution, extent, projection, and time periods
Understanding Metadata Exploring pgsources, pgvariables, and pgsearch()
Contributing Adding new data sources and variables

Contributing

We welcome contributions. Report issues or suggest new data sources or variable ideas using our Issue Tracker.

Please see our contribution guidelines for details on how you can contribute with code.

Funding

PRIOGRID 3 has been developed through the Peace Science Infrastructure project funded by the Research Council of Norway (grant number 322425).

About

Replication scripts that were used to generate the PRIO-GRID v3.0 dataset using R. For version 2.0 replication see legacy branch.

Resources

Contributing

Stars

40 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages