You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/bcdata.Rmd
+17-15Lines changed: 17 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ See the License for the specific language governing permissions and limitations
26
26
27
27
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).
28
28
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).
#> 12 license_id 45 Open Data Commons - Public Domain Dedication and Licence
142
142
#> 13 license_id 25 King's Printer Licence - British Columbia
143
143
#> 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
145
146
#> count
146
-
#> 1 70
147
+
#> 1 80
147
148
#> 2 2
148
149
#> 3 12
149
150
#> 4 13
150
151
#> 5 5
151
152
#> 6 3
152
-
#> 7 61
153
-
#> 8 1638
153
+
#> 7 62
154
+
#> 8 1672
154
155
#> 9 2
155
156
#> 10 5
156
157
#> 11 1
157
158
#> 12 2
158
159
#> 13 1
159
-
#> 14 18
160
-
#> 15 1642
160
+
#> 14 19
161
+
#> 15 5
162
+
#> 16 1457
161
163
```
162
164
163
165
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
188
190
189
191
190
192
```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
194
196
#> links_bchighwaycam links_imageDisplay links_imageThumbnail links_replayTheDay id
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:
121
121
122
122
```{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")
125
125
126
126
## OR use the permanent ID, which is better for scripts or non-interactive use
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:
@@ -182,7 +182,7 @@ Let's look at the dimensions of this now much more manageable data object we hav
182
182
183
183
```r
184
184
dim(trees_dpg)
185
-
#> [1] 261 160
185
+
#> [1] 253 160
186
186
```
187
187
188
188
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:
0 commit comments