-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.Rmd
143 lines (100 loc) · 6.6 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
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%"
)
```
# VicmapR <img src='man/figures/logo.png' align="right" height="139" />
<!-- badges: start -->
[](https://app.codecov.io/gh/JustinCally/VicmapR?branch=master)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- [](https://github.com/JustinCally/VicmapR/actions) -->
[](https://CRAN.R-project.org/package=VicmapR)
[](https://cran.r-project.org/package=VicmapR)
<!-- [](https://github.com/JustinCally/VicmapR) -->
<!-- [](https://github.com/JustinCally/VicmapR) -->
[](https://github.com/JustinCally/VicmapR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
**From November 2024 (version 0.3.0) `VicmapR` will be renamed to `vicspatial`. Unfortunately this change has been requested by the trademark holders of `VICMAP` (Department of Transport and Planning). While redirections should be in place for GitHub and CRAN websites, please check existing code for explicit mentions of `VicmapR`.**
The goal of VicmapR is to provide functions to easily access Victorian Government spatial data through their WFS (Web Feature Service). VicmapR leverages code and a lazy querying approach developed by [Teucher et al. (2021)](https://joss.theoj.org/papers/10.21105/joss.02927) for the [{bcdata} R package](https://bcgov.github.io/bcdata/), which allows for a responsive and precise querying process.
## Migration of Victoria's Open Data Geoserver
**From March 2023 (`VicmapR v0.2.0`) the way `VicmapR` obtains data has changed**
In March 2023 the data platform used by `VicmapR` will be migrated with the legacy platform discontinued. Changes have been to the `VicmapR` package to allow for the conversion and translation of of code in an effort to ensure legacy code still works. However, the migration may have unseen consequences and users are encouraged to review code.
## Installation
You can install the released version from CRAN with:
``` r
install.packages("VicmapR")
```
Or you can install the the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("JustinCally/VicmapR")
```
### Dependencies
Currently, the ability to use accurate geometric filters using `VicmapR` requires GDAL > 3.0. To see how to upgrade your version of GDAL and link it to the `sf` package visit: https://r-spatial.github.io/sf/#installing
```{r dependencies}
library(sf)
sf::sf_extSoftVersion()
```
## Example
### Searching for data
```{r example}
library(VicmapR)
# Check to see if the geoserver is working. It will error if it is not working
check_geoserver()
listLayers(pattern = "watercourse", ignore.case = T)
```
### Reading in data
As of VicmapR version `0.1.0` data is read in using a lazy evaluation method with the convenience of pipe operators (`%>%`). A lot of the methods and code have already been written for a similar package ([bcdata](https://github.com/bcgov/bcdata)) that downloads data from the British Columbia WFS catalogues. Using a similar approach, VicmapR allows users to construct a WFS query in a step-wise format. In doing so a query is reserved until `collect()` is used on the `vicmap_promise`. The example below shows an extensive example of how the to easily read in spatial data:
```{r query_example}
# Read in an example shape to restrict our query to using geometric filtering
melbourne <- sf::st_read(system.file("shapes/melbourne.geojson", package="VicmapR"), quiet = T)
# Obtain a promise of what data will be returned for a given layer
vicmap_query(layer = "open-data-platform:hy_watercourse")
# Build a more specific query and collect the results
vicmap_query(layer = "open-data-platform:hy_watercourse") %>% # layer to query
filter(hierarchy == "L" & feature_type_code == 'watercourse_channel_drain') %>% # simple filter for a column
filter(INTERSECTS(melbourne)) %>% # more advanced geometric filter
select(hierarchy, pfi) %>%
collect()
```
VicmapR translates numerous geometric filter functions available in the Victorian Government's WFS Geoserver supports numerous [geometric filters](https://docs.geoserver.org/stable/en/user/tutorials/cql/cql_tutorial.html#geometric-filters):
+ `EQUALS`
+ `DISJOINT`
+ `INTERSECTS`
+ `TOUCHES`
+ `CROSSES`
+ `WITHIN`
+ `CONTAINS`
+ `OVERLAPS`
+ `DWITHIN`
+ `BEYOND`
+ `BBOX`
These filters can be used within the `filter()` function by providing them an object of class `sf/sfc/sfg/bbox` as shown above with the `melbourne` object.
### Using other WFS urls
Using `options(vicmap.base_url)` VicmapR can query data from other WFS services; while this remains somewhat untested it is relatively easy to point VicmapR to another WFS url. This option would need to be set every session to override the base VicmapR url. For instance, the BOM WFS can be used as follows:
```{r, eval=FALSE}
# set the new base url
options(vicmap.base_url = "http://geofabric.bom.gov.au/simplefeatures/ahgf_shcatch/wfs")
# collect a data sample
catchments <- vicmap_query("ahgf_shcatch:AHGFCatchment") %>%
head(10) %>%
collect()
```
*__Note__: Using other Geoserver WFS urls will not necessarily work as expected due to the potential differences in the capabilities of the Geoserver instance*
### License
Copyright 2018 Province of British Columbia
Modifications Copyright 2020 Justin Cally
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.