Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
boshek committed Feb 14, 2019
1 parent 646abea commit de08408
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 117 deletions.
38 changes: 22 additions & 16 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ knitr::opts_chunk$set(

[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/bcmaps)](https://cran.r-project.org/package=bcmaps) [![CRAN Downloads](https://cranlogs.r-pkg.org/badges/bcmaps?color=brightgreen)](https://CRAN.R-project.org/package=bcmaps)



## Overview

An [R](http://r-project.org) package of spatial map layers for British Columbia.
Expand Down Expand Up @@ -65,8 +67,11 @@ install.packages('bcmapsdata', repos='https://bcgov.github.io/drat/')
```

To see the layers that are available, run the `available_layers()` function:
```{r, echo=FALSE}
library(bcmaps)
```

```{r}
```{r, eval=FALSE}
library(bcmaps)
available_layers()
```
Expand Down Expand Up @@ -113,27 +118,19 @@ kootenays <- rd[rd$ADMIN_AREA_NAME == "Regional District of Central Kootenay", ]
plot(st_geometry(kootenays), col = "lightseagreen", add = TRUE)
```

### Spatial (sp) objects

If you aren't using the `sf` package and prefer the old standard [`sp`](https://cran.r-project.org/package=sp)
way of doing things, set `class = "sp"` in either `get_layer` or the shortcut functions:

```{r watercourses, warning=FALSE}
library("sp")
# Load watercourse data and plot with boundaries of B.C.
plot(get_layer("bc_bound", class = "sp"))
plot(watercourses_15M(class = "sp"), add = TRUE)
```

### It's a beautiful day in the neighbourhood

A handy layer for creating maps for display is the `bc_neighbours` layer, accessible with the function by the same name:
A handy layer for creating maps for display is the `bc_neighbours` layer, accessible with the function by the same name. This example also illustrates using the popular [ggplot2](https://ggplot2.tidyverse.org/) package to plot maps in R using `geom_sf`:

```{r bc_neighbours}
library(ggplot2)
ggplot() +
geom_sf(data = bc_neighbours(), mapping = aes(fill = name)) +
geom_sf(data = bc_cities())
geom_sf(data = bc_cities()) +
coord_sf(datum = NA) +
scale_fill_discrete(name = "Jurisdiction") +
theme_minimal()
```


Expand All @@ -148,8 +145,6 @@ bec <- bec(force = TRUE, ask = FALSE)
```

```{r bec, message=FALSE}
# This example requires ggplot2 3.0.0 or greater, which has the
# `geom_sf()` function (see https://ggplot2.tidyverse.org/reference/ggsf.html):
bec <- bec()
library(ggplot2)
ggplot() +
Expand All @@ -160,6 +155,17 @@ ggplot() +
```

### Spatial (sp) objects

If you aren't using the `sf` package and prefer the old standard [`sp`](https://cran.r-project.org/package=sp)
way of doing things, set `class = "sp"` in either `get_layer` or the shortcut functions:

```{r watercourses, warning=FALSE}
library("sp")
# Load watercourse data and plot with boundaries of B.C.
plot(get_layer("bc_bound", class = "sp"))
plot(watercourses_15M(class = "sp"), add = TRUE)
```

### Vignettes

Expand Down
125 changes: 24 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,87 +68,7 @@ function:

``` r
library(bcmaps)
#> Loading required package: sf
#> Linking to GEOS 3.6.1, GDAL 2.1.3, PROJ 4.9.3
available_layers()
#> layer_name
#> 1 airzones
#> 2 bc_bound
#> 3 bc_bound_hres
#> 4 bc_cities
#> 5 bc_neighbours
#> 6 ecoprovinces
#> 7 ecoregions
#> 8 ecosections
#> 9 gw_aquifers
#> 10 hydrozones
#> 11 municipalities
#> 12 nr_areas
#> 13 nr_districts
#> 14 nr_regions
#> 15 regional_districts
#> 16 water_districts
#> 17 water_precincts
#> 18 watercourses_15M
#> 19 watercourses_5M
#> 20 wsc_drainages
#> 21 bec
#> 22 tsa
#> title
#> 1 British Columbia Air Zones
#> 2 BC Boundary
#> 3 BC Boundary - High Resolution
#> 4 BC Major Cities Points 1:2,000,000 (Digital Baseline Mapping)
#> 5 British Columbia and neighbouring features
#> 6 British Columbia Ecoprovinces
#> 7 British Columbia Ecoregions
#> 8 British Columbia Ecosections
#> 9 British Columbia's developed ground water aquifers
#> 10 Hydrologic Zone Boundaries of British Columbia
#> 11 British Columbia Municipalities
#> 12 British Columbia Natural Resource (NR) Areas
#> 13 British Columbia Natural Resource (NR) Districts
#> 14 British Columbia Natural Resource (NR) Regions
#> 15 British Columbia Regional Districts
#> 16 British Columbia's Water Management Districts
#> 17 British Columbia's Water Management Precincts
#> 18 British Columbia watercourses at 1:15M scale
#> 19 British Columbia watercourses at 1:5M scale
#> 20 Water Survey of Canada Sub-Sub-Drainage Areas
#> 21 British Columbia BEC Map
#> 22 B.C. Timber Supply Areas & TSA Blocks
#> shortcut_function local
#> 1 TRUE TRUE
#> 2 TRUE TRUE
#> 3 TRUE TRUE
#> 4 TRUE TRUE
#> 5 TRUE TRUE
#> 6 TRUE TRUE
#> 7 TRUE TRUE
#> 8 TRUE TRUE
#> 9 TRUE TRUE
#> 10 TRUE TRUE
#> 11 TRUE TRUE
#> 12 TRUE TRUE
#> 13 TRUE TRUE
#> 14 TRUE TRUE
#> 15 TRUE TRUE
#> 16 TRUE TRUE
#> 17 TRUE TRUE
#> 18 TRUE TRUE
#> 19 TRUE TRUE
#> 20 TRUE TRUE
#> 21 TRUE FALSE
#> 22 TRUE FALSE
#>
#> ------------------------
#> Layers with a value of TRUE in the 'shortcut_function' column can be accessed
#> with a function with the same name as the layer (e.g., `bc_bound()`),
#> otherwise it needs to be accessed with the get_layer function.
#>
#> Layers with a value of FALSE in the 'local' column are not stored in the
#> bcmapsdata package but will be downloaded from the internet and cached
#> on your hard drive.
```

Most layers are accessible by a shortcut function by the same name as
Expand All @@ -162,7 +82,7 @@ bc <- bc_bound()
plot(st_geometry(bc))
```

![](tools/readme/unnamed-chunk-6-1.png)<!-- -->
![](tools/readme/unnamed-chunk-7-1.png)<!-- -->

Alternatively, you can use the `get_layer` function - simply type
`get_layer('layer_name')`, where `'layer_name'` is the name of the layer
Expand All @@ -179,7 +99,7 @@ ws <- get_layer("wsc_drainages", class = "sf")
plot(ws["SUB_SUB_DRAINAGE_AREA_NAME"], key.pos = NULL)
```

![](tools/readme/unnamed-chunk-7-1.png)<!-- -->
![](tools/readme/unnamed-chunk-8-1.png)<!-- -->

### Simple Features objects

Expand All @@ -203,31 +123,21 @@ plot(st_geometry(kootenays), col = "lightseagreen", add = TRUE)

![](tools/readme/plot-maps-1.png)<!-- -->

### Spatial (sp) objects

If you aren’t using the `sf` package and prefer the old standard
[`sp`](https://cran.r-project.org/package=sp) way of doing things, set
`class = "sp"` in either `get_layer` or the shortcut functions:

``` r
library("sp")
# Load watercourse data and plot with boundaries of B.C.
plot(get_layer("bc_bound", class = "sp"))
plot(watercourses_15M(class = "sp"), add = TRUE)
```

![](tools/readme/watercourses-1.png)<!-- -->

### It’s a beautiful day in the neighbourhood

A handy layer for creating maps for display is the `bc_neighbours`
layer, accessible with the function by the same name:
layer, accessible with the function by the same name. This example also
illustrates using the popular [ggplot2](https://ggplot2.tidyverse.org/)
package to plot maps in R using `geom_sf`:

``` r
library(ggplot2)
ggplot() +
geom_sf(data = bc_neighbours(), mapping = aes(fill = name)) +
geom_sf(data = bc_cities())
geom_sf(data = bc_cities()) +
coord_sf(datum = NA) +
scale_fill_discrete(name = "Jurisdiction") +
theme_minimal()
```

![](tools/readme/bc_neighbours-1.png)<!-- -->
Expand All @@ -239,8 +149,6 @@ Classification) map is available via the `bec()` function, and an
accompanying function `bec_colours()` function to colour it:

``` r
# This example requires ggplot2 3.0.0 or greater, which has the
# `geom_sf()` function (see https://ggplot2.tidyverse.org/reference/ggsf.html):
bec <- bec()
library(ggplot2)
ggplot() +
Expand All @@ -252,6 +160,21 @@ ggplot() +

![](tools/readme/bec-1.png)<!-- -->

### Spatial (sp) objects

If you aren’t using the `sf` package and prefer the old standard
[`sp`](https://cran.r-project.org/package=sp) way of doing things, set
`class = "sp"` in either `get_layer` or the shortcut functions:

``` r
library("sp")
# Load watercourse data and plot with boundaries of B.C.
plot(get_layer("bc_bound", class = "sp"))
plot(watercourses_15M(class = "sp"), add = TRUE)
```

![](tools/readme/watercourses-1.png)<!-- -->

### Vignettes

We have written a short vignette on plotting points on one of the layers
Expand Down
Binary file modified tools/readme/bc_neighbours-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/readme/bec-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/readme/plot-maps-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/readme/unnamed-chunk-7-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tools/readme/unnamed-chunk-8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tools/readme/watercourses-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de08408

Please sign in to comment.