Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jsta/glwdr

R client for the Global Lakes and Wetlands Database
https://github.com/jsta/glwdr

limnology rstats

Last synced: about 1 month ago
JSON representation

R client for the Global Lakes and Wetlands Database

Awesome Lists containing this project

README

        

---
output: github_document
---

# Global Lakes and Wetlands Database (GLWD) R client

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "vignettes/"
)
```

[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![cran version](http://www.r-pkg.org/badges/version/glwdr)](https://cran.r-project.org/package=glwdr)

## Installation

```{r eval = FALSE}
devtools::install_github("jsta/glwdr")
```

### Load Package
```{r }
library(glwdr)
```

## Usage

```{r eval = FALSE, echo=FALSE}
library(maps)
library(sp)
library(ggplot2)
library(raster)

# glwd_get(level = 1)
level_1 <- glwd_load(level = 1)

map("world")
plot(level_1, add = TRUE, col = "blue")

# glwd_get(level = 2)
level_2 <- glwd_load(level = 2)
level_2_key <- data.frame(TYPE = c("Lake", "Reservoir", "River"),
col = c("blue", "red", "lightblue"), stringsAsFactors = FALSE)
level_2 <- merge(level_2, level_2_key, all.x = TRUE, all.y = FALSE)
plot(level_2, add = TRUE, col = level_2@data$col, border = NA)

# glwd_get(level = 3)
level_3 <- glwd_load(level = 3)
# need to define color ramp more closely matching pub
plot(dt, breaks = 1:12, col = viridis::viridis(12), add = TRUE)
```

### Level 1
```{r eval=FALSE}
glwd_get(level = 1)

dt <- glwd_load(level = 1)
```

```{r echo=FALSE,message=FALSE,results='hide'}
library(glwdr)

dt <- suppressMessages(glwd_load(level = 1))
```

```{r level-1}
library(maps)
library(sp)

dt <- dt[dt$COUNTRY == "United States" &
dt$LAT_DEG < 56 &
dt$AREA_SKM < 30000,]

map("state")
plot(dt, add = TRUE, col = "blue")
axis(1); axis(2)
```

```{r echo=FALSE, eval=FALSE}
dt@data[1:5,]
```

### Level 2

```{r eval=FALSE}
glwd_get(level = 2)

dt <- glwd_load(level = 2)
```

```{r echo=FALSE,message=FALSE,results='hide'}
library(glwdr)

dt <- suppressMessages(glwd_load(level = 2))
```

```{r level-2}
library(ggplot2)
library(raster)

states <- map_data("state")
states <- glwdr:::map_data_to_spdf(states)
projection(dt) <- projection(states)

map("state")
plot(dt[states,], add = TRUE, border = "blue")
axis(1); axis(2)
```

### Level 3

```{r eval=FALSE}
glwd_get(level = 3)

dt <- glwd_load(level = 3)
```

```{r echo=FALSE,message=FALSE,results='hide'}
library(glwdr)

dt <- suppressMessages(glwd_load(level = 3))
```

```{r level-3}
map("world")
plot(dt, breaks = 1:12, col = viridis::viridis(12), add = TRUE)
axis(1); axis(2)
```

## References

Lehner, B., Döll, P.: Development and validation of a global
database of lakes, reservoirs and wetlands, Journal of Hydrology, Volume
296, Issues 1–4, 20 August 2004, Pages 1-22,
http://dx.doi.org/10.1016/j.jhydrol.2004.03.028.