Skip to content

Commit 1ceb329

Browse files
committed
Fix catalogue record id, precompile vignettes
1 parent 43774d6 commit 1ceb329

11 files changed

+57
-54
lines changed

vignettes/bcdata.Rmd

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ See the License for the specific language governing permissions and limitations
2626

2727
The `bcdata` [R](https://www.r-project.org/) package contains functions for searching & retrieving data from the [B.C. Data Catalogue]( https://catalogue.data.gov.bc.ca).
2828

29-
The [B.C. Data Catalogue](https://www2.gov.bc.ca/gov/content?id=79B5224167334667A44C9E8B5143D0C5) is the place to find British Columbia Government data, applications and web services. Much of the data are released under the [Open Government Licence --- British Columbia](https://www2.gov.bc.ca/gov/content/data/policy-standards/data-policies/open-data/open-government-licence-bc), as well as numerous other [licences](https://catalogue.data.gov.bc.ca/dataset?download_audience=Public).
29+
The [B.C. Data Catalogue](https://www2.gov.bc.ca/gov/content?id=79B5224167334667A44C9E8B5143D0C5) is the place to find British Columbia Government data, applications and web services. Much of the data are released under the [Open Government Licence --- British Columbia](https://www2.gov.bc.ca/gov/content/data/policy-standards/open-data/open-government-licence-bc), as well as numerous other [licences](https://catalogue.data.gov.bc.ca/dataset?download_audience=Public).
3030

3131

3232

@@ -141,23 +141,25 @@ bcdc_search_facets(facet = "license_id")
141141
#> 12 license_id 45 Open Data Commons - Public Domain Dedication and Licence
142142
#> 13 license_id 25 King's Printer Licence - British Columbia
143143
#> 14 license_id 42 Elections BC Open Data Licence
144-
#> 15 license_id 22 Access Only
144+
#> 15 license_id 51 BC Energy Regulator Open Data License
145+
#> 16 license_id 22 Access Only
145146
#> count
146-
#> 1 70
147+
#> 1 80
147148
#> 2 2
148149
#> 3 12
149150
#> 4 13
150151
#> 5 5
151152
#> 6 3
152-
#> 7 61
153-
#> 8 1638
153+
#> 7 62
154+
#> 8 1672
154155
#> 9 2
155156
#> 10 5
156157
#> 11 1
157158
#> 12 2
158159
#> 13 1
159-
#> 14 18
160-
#> 15 1642
160+
#> 14 19
161+
#> 15 5
162+
#> 16 1457
161163
```
162164

163165
Finally, you can retrieve the _metadata_ for a single catalogue record by using the record name or permanent ID with `bcdc_get_record()`. It is advised to use the permanent ID rather than the human-readable name in non-interactive situations---like scripts---to guard against future name changes of a record:
@@ -188,9 +190,9 @@ Once you have located the B.C. Data Catalogue record with the data you want, you
188190

189191

190192
``` r
191-
## Get the data resource for the `bc-highway-cams` catalogue record
192-
bcdc_get_data("bc-highway-cams")
193-
#> # A tibble: 1,007 × 13
193+
## Get the data resource for the `bc-highwaycams` catalogue record
194+
bcdc_get_data("bc-highwaycams")
195+
#> # A tibble: 1,035 × 13
194196
#> links_bchighwaycam links_imageDisplay links_imageThumbnail links_replayTheDay id
195197
#> <chr> <chr> <chr> <chr> <dbl>
196198
#> 1 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 2
@@ -203,13 +205,13 @@ bcdc_get_data("bc-highway-cams")
203205
#> 8 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 11
204206
#> 9 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 12
205207
#> 10 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 13
206-
#> # ℹ 997 more rows
208+
#> # ℹ 1,025 more rows
207209
#> # ℹ 8 more variables: highway_number <chr>, highway_locationDescription <chr>, camName <chr>,
208210
#> # caption <chr>, credit <chr>, orientation <chr>, latitude <dbl>, longitude <dbl>
209211

210212
## OR use the permanent ID, which is better for scripts or non-interactive use
211213
bcdc_get_data("6b39a910-6c77-476f-ac96-7b4f18849b1c")
212-
#> # A tibble: 1,007 × 13
214+
#> # A tibble: 1,035 × 13
213215
#> links_bchighwaycam links_imageDisplay links_imageThumbnail links_replayTheDay id
214216
#> <chr> <chr> <chr> <chr> <dbl>
215217
#> 1 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 2
@@ -222,14 +224,14 @@ bcdc_get_data("6b39a910-6c77-476f-ac96-7b4f18849b1c")
222224
#> 8 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 11
223225
#> 9 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 12
224226
#> 10 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 13
225-
#> # ℹ 997 more rows
227+
#> # ℹ 1,025 more rows
226228
#> # ℹ 8 more variables: highway_number <chr>, highway_locationDescription <chr>, camName <chr>,
227229
#> # caption <chr>, credit <chr>, orientation <chr>, latitude <dbl>, longitude <dbl>
228230

229231
## OR use the result from bcdc_get_record()
230232
my_record <- bcdc_get_record("6b39a910-6c77-476f-ac96-7b4f18849b1c")
231233
bcdc_get_data(my_record)
232-
#> # A tibble: 1,007 × 13
234+
#> # A tibble: 1,035 × 13
233235
#> links_bchighwaycam links_imageDisplay links_imageThumbnail links_replayTheDay id
234236
#> <chr> <chr> <chr> <chr> <dbl>
235237
#> 1 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 2
@@ -242,7 +244,7 @@ bcdc_get_data(my_record)
242244
#> 8 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 11
243245
#> 9 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 12
244246
#> 10 https://images.drivebc.ca/bchig… https://images.dr… https://images.driv… https://images.dr… 13
245-
#> # ℹ 997 more rows
247+
#> # ℹ 1,025 more rows
246248
#> # ℹ 8 more variables: highway_number <chr>, highway_locationDescription <chr>, camName <chr>,
247249
#> # caption <chr>, credit <chr>, orientation <chr>, latitude <dbl>, longitude <dbl>
248250
```

vignettes/bcdata.Rmd.orig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ bcdc_get_record("a29ad492-29a2-44b9-8693-d27a8cc8e686")
120120
Once you have located the B.C. Data Catalogue record with the data you want, you can use `bcdata::bcdc_get_data()` to download and read the data from the record. You can use the record name, permanent ID or the result from `bcdc_get_record()`. Let's look at the B.C. Highway Web Cameras data:
121121

122122
```{r}
123-
## Get the data resource for the `bc-highway-cams` catalogue record
124-
bcdc_get_data("bc-highway-cams")
123+
## Get the data resource for the `bc-highwaycams` catalogue record
124+
bcdc_get_data("bc-highwaycams")
125125

126126
## OR use the permanent ID, which is better for scripts or non-interactive use
127127
bcdc_get_data("6b39a910-6c77-476f-ac96-7b4f18849b1c")

vignettes/efficiently-query-spatial-data-in-the-bc-data-catalogue.Rmd

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Querying Spatial Data with bcdata"
3-
date: "2024-12-11"
3+
date: "2026-02-06"
44
output: rmarkdown::html_vignette
55
vignette: >
66
%\VignetteIndexEntry{Querying Spatial Data with bcdata}
@@ -194,28 +194,28 @@ Again we recognize this is [WFS-enabled](https://en.wikipedia.org/wiki/Web_Featu
194194
``` r
195195
bcdc_query_geodata("6a2fea1b-0cc4-4fc2-8017-eaf755d516da")
196196
#> Querying 'local-and-regional-greenspaces' record
197-
#> • Using collect() on this object will return 9143 features and 19 fields
197+
#> • Using collect() on this object will return 9212 features and 19 fields
198198
#> • At most six rows of the record are printed here
199199
#> ────────────────────────────────────────────────────────────────────────────────────────────────────
200200
#> Simple feature collection with 6 features and 19 fields
201-
#> Geometry type: MULTIPOLYGON
201+
#> Geometry type: POLYGON
202202
#> Dimension: XY
203-
#> Bounding box: xmin: 1205812 ymin: 461894.2 xmax: 1210343 ymax: 463217.4
203+
#> Bounding box: xmin: 1205933 ymin: 459093.3 xmax: 1212220 ymax: 460485.6
204204
#> Projected CRS: NAD83 / BC Albers
205205
#> # A tibble: 6 × 20
206206
#> id LOCAL_REG_GREENSPACE…¹ PARK_NAME PARK_TYPE PARK_PRIMARY_USE REGIONAL_DISTRICT MUNICIPALITY
207207
#> <chr> <int> <chr> <chr> <chr> <chr> <chr>
208-
#> 1 WHSE_B… 40 Wowk Nei… Local Park Metro Vancouver Richmond
209-
#> 2 WHSE_B… 41 Hugh Boy… Local Park Metro Vancouver Richmond
210-
#> 3 WHSE_B… 42 Sandifor… Local Park Metro Vancouver Richmond
211-
#> 4 WHSE_B… 43 Kozier N… Local Park Metro Vancouver Richmond
212-
#> 5 WHSE_B… 44 Maple La… Local Park Metro Vancouver Richmond
213-
#> 6 WHSE_B… 45 South Ar… Local Park Metro Vancouver Richmond
208+
#> 1 WHSE_B… 49 Woodward… Local Park Metro Vancouver Richmond
209+
#> 2 WHSE_B… 50 Woodward… Local Park Metro Vancouver Richmond
210+
#> 3 WHSE_B… 51 Doggie P… Local Park Metro Vancouver Richmond
211+
#> 4 WHSE_B… 52 Bike Ter… Local Athletic Metro Vancouver Richmond
212+
#> 5 WHSE_B… 53 Great We… Local Trail Metro Vancouver Richmond
213+
#> 6 WHSE_B… 54 Imperial… Local Park Metro Vancouver Richmond
214214
#> # ℹ abbreviated name: ¹​LOCAL_REG_GREENSPACE_ID
215215
#> # ℹ 13 more variables: CIVIC_NUMBER <int>, CIVIC_NUMBER_SUFFIX <chr>, STREET_NAME <chr>,
216216
#> # LATITUDE <dbl>, LONGITUDE <dbl>, WHEN_UPDATED <date>, WEBSITE_URL <chr>,
217217
#> # LICENCE_COMMENTS <chr>, FEATURE_AREA_SQM <dbl>, FEATURE_LENGTH_M <dbl>, OBJECTID <int>,
218-
#> # SE_ANNO_CAD_DATA <chr>, geometry <MULTIPOLYGON [m]>
218+
#> # SE_ANNO_CAD_DATA <chr>, geometry <POLYGON [m]>
219219
```
220220

221221
Since we are interested in only "Park" data we can subset our query:
@@ -225,28 +225,28 @@ Since we are interested in only "Park" data we can subset our query:
225225
bcdc_query_geodata("6a2fea1b-0cc4-4fc2-8017-eaf755d516da") %>%
226226
filter(PARK_PRIMARY_USE == "Park")
227227
#> Querying 'local-and-regional-greenspaces' record
228-
#> • Using collect() on this object will return 4517 features and 19 fields
228+
#> • Using collect() on this object will return 4528 features and 19 fields
229229
#> • At most six rows of the record are printed here
230230
#> ────────────────────────────────────────────────────────────────────────────────────────────────────
231231
#> Simple feature collection with 6 features and 19 fields
232-
#> Geometry type: MULTIPOLYGON
232+
#> Geometry type: POLYGON
233233
#> Dimension: XY
234-
#> Bounding box: xmin: 1205812 ymin: 461894.2 xmax: 1210343 ymax: 463217.4
234+
#> Bounding box: xmin: 1205029 ymin: 459093.3 xmax: 1212220 ymax: 461188.7
235235
#> Projected CRS: NAD83 / BC Albers
236236
#> # A tibble: 6 × 20
237237
#> id LOCAL_REG_GREENSPACE…¹ PARK_NAME PARK_TYPE PARK_PRIMARY_USE REGIONAL_DISTRICT MUNICIPALITY
238238
#> <chr> <int> <chr> <chr> <chr> <chr> <chr>
239-
#> 1 WHSE_B… 40 Wowk Nei… Local Park Metro Vancouver Richmond
240-
#> 2 WHSE_B… 41 Hugh Boy… Local Park Metro Vancouver Richmond
241-
#> 3 WHSE_B… 42 Sandifor… Local Park Metro Vancouver Richmond
242-
#> 4 WHSE_B… 43 Kozier N… Local Park Metro Vancouver Richmond
243-
#> 5 WHSE_B… 44 Maple La… Local Park Metro Vancouver Richmond
244-
#> 6 WHSE_B… 45 South Ar… Local Park Metro Vancouver Richmond
239+
#> 1 WHSE_B… 49 Woodward… Local Park Metro Vancouver Richmond
240+
#> 2 WHSE_B… 50 Woodward… Local Park Metro Vancouver Richmond
241+
#> 3 WHSE_B… 51 Doggie P… Local Park Metro Vancouver Richmond
242+
#> 4 WHSE_B… 54 Imperial… Local Park Metro Vancouver Richmond
243+
#> 5 WHSE_B… 55 Stevesto… Local Park Metro Vancouver Richmond
244+
#> 6 WHSE_B… 56 Mariner'… Local Park Metro Vancouver Richmond
245245
#> # ℹ abbreviated name: ¹​LOCAL_REG_GREENSPACE_ID
246246
#> # ℹ 13 more variables: CIVIC_NUMBER <int>, CIVIC_NUMBER_SUFFIX <chr>, STREET_NAME <chr>,
247247
#> # LATITUDE <dbl>, LONGITUDE <dbl>, WHEN_UPDATED <date>, WEBSITE_URL <chr>,
248248
#> # LICENCE_COMMENTS <chr>, FEATURE_AREA_SQM <dbl>, FEATURE_LENGTH_M <dbl>, OBJECTID <int>,
249-
#> # SE_ANNO_CAD_DATA <chr>, geometry <MULTIPOLYGON [m]>
249+
#> # SE_ANNO_CAD_DATA <chr>, geometry <POLYGON [m]>
250250
```
251251

252252
Here we see that this greatly reduces the number of features that we are dealing with (and correspondingly the amount of data that needs to be transferred over the web). Remember also that we still have not actually requested the full data set. This is just still a preview. Also this query still includes all municipal parks in BC while we only want the ones in the three school districts - the polygons defined by the `districts` object. To find that subset of parks we can make use of the built-in geometric operators which allow us to perform spatial operations remotely fine tuning our query even further. Here using the `INTERSECTS` function is appropriate and since this is a last tuning step, we can call `collect` and assign a name to this object. These requests can sometimes take quite a long:
@@ -433,7 +433,7 @@ bcdc_query_geodata("WHSE_IMAGERY_AND_BASE_MAPS.GSR_AIRPORTS_SVW") %>%
433433
#> Simple feature collection with 6 features and 11 fields
434434
#> Geometry type: POINT
435435
#> Dimension: XY
436-
#> Bounding box: xmin: 833323.9 ymin: 406886.6 xmax: 1266385 ymax: 1054950
436+
#> Bounding box: xmin: 1047036 ymin: 456228.3 xmax: 1612700 ymax: 827672.5
437437
#> Projected CRS: NAD83 / BC Albers
438438
#> # A tibble: 6 × 12
439439
#> id CUSTODIAN_ORG_DESCRI…¹ BUSINESS_CATEGORY_CL…² BUSINESS_CATEGORY_DE…³ OCCUPANT_TYPE_DESCRI…⁴

vignettes/explore-silviculture-data-using-bcdata.Rmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Exploring Silviculture Data with bcdata"
3-
date: "2024-12-11"
3+
date: "2026-02-06"
44
output: rmarkdown::html_vignette
55
vignette: >
66
%\VignetteIndexEntry{Exploring Silviculture Data with bcdata}
@@ -88,8 +88,8 @@ We see that this is a [Web Feature Service-enabled](https://en.wikipedia.org/wik
8888
# Query the data using the permanent ID of the record to guard against name changes
8989
bcdc_query_geodata("258bb088-4113-47b1-b568-ce20bd64e3e3")
9090
#> Querying 'results-forest-cover-silviculture' record
91-
#> • Using collect() on this object will return 957189 features and 159 fields
92-
#> • Accessing this record requires pagination and will make 96 separate requests to the WFS.
91+
#> • Using collect() on this object will return 976169 features and 159 fields
92+
#> • Accessing this record requires pagination and will make 98 separate requests to the WFS.
9393
#> • See ?bcdc_options
9494
#> • At most six rows of the record are printed here
9595
#> ────────────────────────────────────────────────────────────────────────────────────────────────────
@@ -182,7 +182,7 @@ Let's look at the dimensions of this now much more manageable data object we hav
182182

183183
``` r
184184
dim(trees_dpg)
185-
#> [1] 261 160
185+
#> [1] 253 160
186186
```
187187

188188
We can see there are several treatment units planted with western larch, and we can make a quick map of these harvested openings for the Prince George Natural Resource District:

vignettes/local-filter.Rmd

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Update to `filter()` behaviour in bcdata v0.4.0"
3-
date: "2024-12-11"
3+
date: "2026-02-06"
44
output: rmarkdown::html_vignette
55
vignette: >
66
%\VignetteIndexEntry{Update to `filter()` behaviour in bcdata v0.4.0}
@@ -52,7 +52,8 @@ bcdc_query_geodata("local-and-regional-greenspaces") %>%
5252
```
5353

5454
```
55-
## Error: Error : Cannot translate a <sfc_POINT> object to SQL.
55+
## Error:
56+
## ! Error : Cannot translate a <sfc_POINT> object to SQL.
5657
## ℹ Do you want to force evaluation in R with (e.g.) `!!x` or `local(x)`?
5758
```
5859

@@ -68,25 +69,25 @@ bcdc_query_geodata("local-and-regional-greenspaces") %>%
6869

6970
```
7071
## Querying 'local-and-regional-greenspaces' record
71-
## • Using collect() on this object will return 1158 features and 19 fields
72+
## • Using collect() on this object will return 1236 features and 19 fields
7273
## • At most six rows of the record are printed here
7374
## ────────────────────────────────────────────────────────────────────────────────────────────────────
7475
## Simple feature collection with 6 features and 19 fields
7576
## Geometry type: POLYGON
7677
## Dimension: XY
77-
## Bounding box: xmin: 1200113 ymin: 385903.5 xmax: 1202130 ymax: 388026
78+
## Bounding box: xmin: 1187080 ymin: 409342.1 xmax: 1191300 ymax: 410578
7879
## Projected CRS: NAD83 / BC Albers
7980
## # A tibble: 6 × 20
8081
## id LOCAL_REG_GREENSPACE…¹ PARK_NAME PARK_TYPE PARK_PRIMARY_USE REGIONAL_DISTRICT MUNICIPALITY
8182
## <chr> <int> <chr> <chr> <chr> <chr> <chr>
82-
## 1 WHSE_B… 689 Cranford… Local Water Access Capital District of
83-
## 2 WHSE_B… 634 <NA> Local Water Access Capital District of
84-
## 3 WHSE_B… 725 <NA> Local Water Access Capital District of
85-
## 4 WHSE_B… 665 Konukson… Local Green Space Capital District of
86-
## 5 WHSE_B… 622 <NA> Local Trail Capital District of
87-
## 6 WHSE_B… 698 <NA> Local Water Access Capital District of
83+
## 1 WHSE_B… 8423 Lillian … Local Park Capital North Saani
84+
## 2 WHSE_B… 8422 Nymph Po… Local Park Capital North Saani
85+
## 3 WHSE_B… 8447 H.M.S. P… Local Park Capital North Saani
86+
## 4 WHSE_B… 8434 Wain Park Local Park Capital North Saani
87+
## 5 WHSE_B… 8446 Prentice… Local Park Capital North Saani
88+
## 6 WHSE_B… 8448 <NA> Local Park Capital North Saani
8889
## # ℹ abbreviated name: ¹​LOCAL_REG_GREENSPACE_ID
89-
## # ℹ 13 more variables: CIVIC_NUMBER <chr>, CIVIC_NUMBER_SUFFIX <chr>, STREET_NAME <chr>,
90+
## # ℹ 13 more variables: CIVIC_NUMBER <int>, CIVIC_NUMBER_SUFFIX <chr>, STREET_NAME <chr>,
9091
## # LATITUDE <dbl>, LONGITUDE <dbl>, WHEN_UPDATED <date>, WEBSITE_URL <chr>,
9192
## # LICENCE_COMMENTS <chr>, FEATURE_AREA_SQM <dbl>, FEATURE_LENGTH_M <dbl>, OBJECTID <int>,
9293
## # SE_ANNO_CAD_DATA <chr>, geometry <POLYGON [m]>
2 Bytes
Loading

vignettes/vignette-fig-bbox-1.png

2 Bytes
Loading
-2 Bytes
Loading
-24 Bytes
Loading
1.67 KB
Loading

0 commit comments

Comments
 (0)