-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
112 lines (84 loc) · 4.3 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fwatlasbc <img src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![R-CMD-check](https://github.com/poissonconsulting/fwatlasbc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/fwatlasbc/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/fwatlasbc/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/fwatlasbc)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
<!-- badges: end -->
`fwatlasbc` is an R package for querying data from the [Freshwater Atlas](https://www2.gov.bc.ca/gov/content/data/geographic-data-services/topographic-data/freshwater) (FWA) of British Columbia.
Spatial data are returned as [simple features](https://github.com/r-spatial/sf).
`fwatlasbc` wraps [`fwapgr`](https://github.com/poissonconsulting/fwapgr) an R package that uses the [fwapg API](https://www.hillcrestgeo.ca/fwapg/index.html).
## Installation
You can install the latest version of `fwatlasbc` from [GitHub](https://github.com/poissonconsulting/fwatlasbc) with:
```r
# install.packages("devtools")
devtools::install_github("poissonconsulting/fwatlasbc")
```
## Demonstration
Find stream names using regular expression.
There may be more than one stream name that matches the regular expression.
```{r}
library(fwatlasbc)
streams <- fwa_find_stream_names("steep c")
streams
```
Add blue line keys (blk) to stream names.
There may be multiple streams with the same name.
```{r}
blks <- fwa_add_blks_to_stream_name(streams)
blks
blks <- blks[blks$blk == 356534225, ]
```
Alternatively get the nearest blue line key and river meter (rm) from the longitude and latitude.
The river meter is the distance in meters as the fish swims from the mouth of the river.
The distance_to_lon_lat is the how far the original point was from the stream in meters.
```{r}
fwa_add_blk_to_lon_lat(data.frame(lon = -132.26, lat = 53.36))
```
Get watershed (by aggregating fundamental watersheds) for a blue line key and river meter (by default 0).
If it errors try increasing the river meter.
```{r}
wshed <- fwa_add_watershed_to_blk(blks)
wshed
```
Get stream network for the watershed polygon.
Note that rm is from the original watershed while downstream/upstream_route_measure are the equivalents for the stream segment in the network.
```{r}
network <- fwa_add_collection_to_polygon(wshed, "stream_network")
network
```
Convert the stream network into a table of blue line keys with regularly spaced river meters starting at 0.
```{r}
# rms <- fwa_convert_stream_network_to_rms(network, interval = 100)
# rms
```
Plot the watershed, network and river meters.
```{r dpi=300, fig.width=7, fig.height=7}
ggplot2::ggplot() +
ggplot2::geom_sf(data = wshed) +
ggplot2::geom_sf(data = network, color = "blue") +
# ggplot2::geom_sf(data = rms) +
NULL
```
## Inspiration
`fwatlasbc` supersedes the archived [`fwabc`](https://github.com/poissonconsulting/fwabc) which retrieved data via [WFS](https://openmaps.gov.bc.ca/geo/pub/wfs?service=WFS&version=2.0.0&request=GetFeature&typeName=WHSE_BASEMAPPING.FWA_LAKES_POLY&outputFormat=json&SRSNAME=epsg%3A3005&CQL_FILTER=GNIS_NAME_1=%27Quamichan%20Lake%27) using [`bcdata`](https://github.com/bcgov/bcdata).
## Creditation
`fwatlasbc` relies on [fwapg API](https://www.hillcrestgeo.ca/fwapg/index.html) which is created, maintained and hosted by [Simon Norris](https://github.com/smnorris/fwapg) at [Hillcrest Geographics](https://hillcrestgeo.ca/main/).
## Contribution
Please report any [issues](https://github.com/poissonconsulting/fwatlasbc/issues).
[Pull requests](https://github.com/poissonconsulting/fwatlasbc/pulls) are always welcome.
### Code of Conduct
Please note that `fwatlasbc` is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.