Provides access to various spatial layers for B.C., such as administrative boundaries, natural resource management boundaries, etc. All layers are imported from the 'bcmaps.rdata' package as 'sf' or 'Spatial' objects through function calls in this package. All layers are in B.C. 'Albers' equal-area projection < http://spatialreference.org/ref/epsg/nad83-bc-albers/>, which is the B.C. government standard.
An R package of spatial map layers for British Columbia.
Provides access to various spatial layers of British Columbia, such as
administrative boundaries, natural resource management boundaries,
watercourses etc. All layers are available in the BC
projection, which is the B.C. Government standard as
You can install
bcmaps from CRAN:
To install the development version of the
bcmaps package, you need to
remotes package then the
To get full usage of the package, you will also need to install the bcmaps.rdata package, which holds all of the datasets.
Note that unlike most packages it is not necessary to actually load the
bcmaps.rdata package (i.e., with
library(bcmaps.rdata)) - in fact
it is less likely to cause problems if you don’t.
To see the layers that are available, run the
library(bcmaps)available_layers()#> layer_name#> 1 airzones#> 2 bc_bound#> 3 bc_bound_hres#> 4 bc_cities#> 5 ecoprovinces#> 6 ecoregions#> 7 ecosections#> 8 gw_aquifers#> 9 hydrozones#> 10 municipalities#> 11 nr_areas#> 12 nr_districts#> 13 nr_regions#> 14 regional_districts#> 15 water_districts#> 16 water_precincts#> 17 watercourses_15M#> 18 watercourses_5M#> 19 wsc_drainages#> 20 bec#> 21 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 Ecoprovinces#> 6 British Columbia Ecoregions#> 7 British Columbia Ecosections#> 8 British Columbia's developed ground water aquifers#> 9 Hydrologic Zone Boundaries of British Columbia#> 10 British Columbia Municipalities#> 11 British Columbia Natural Resource (NR) Areas#> 12 British Columbia Natural Resource (NR) Districts#> 13 British Columbia Natural Resource (NR) Regions#> 14 British Columbia Regional Districts#> 15 British Columbia's Water Management Districts#> 16 British Columbia's Water Management Precincts#> 17 British Columbia watercourses at 1:15M scale#> 18 British Columbia watercourses at 1:5M scale#> 19 Water Survey of Canada Sub-Sub-Drainage Areas#> 20 British Columbia BEC Map#> 21 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 FALSE#> 21 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#> bcmaps.rdata 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
the object. Then you can use the data as you would any
object. For example:
library(sf)#> Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3bc <- bc_bound()plot(st_geometry(bc))
Alternatively, you can use the
get_layer function - simply type
'layer_name' is the name of the layer
of interest. The
get_layer function is useful if the back-end
bcmaps.rdata package has had a layer added to it, but there is as yet
no shortcut function created in
library(sf)library(dplyr)ws <- get_layer("wsc_drainages", class = "sf")plot(ws["SUB_SUB_DRAINAGE_AREA_NAME"], key.pos = NULL)
By default, all layers are returned as
library(bcmaps)library(sf)# Load and plot the boundaries of B.C.bc <- bc_bound()plot(st_geometry(bc))## Next load the Regional Districts data, then extract and plot the Kootenaysrd <- regional_districts()kootenays <- rd[rd$ADMIN_AREA_NAME == "Regional District of Central Kootenay", ]plot(st_geometry(kootenays), col = "lightseagreen", add = TRUE)
If you aren’t using the
sf package and prefer the old standard
sp way of doing things, set
class = "sp" in either
get_layer or the shortcut functions:
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)
As of version 0.15.0 the B.C. BEC (Biogeoclimatic Ecosystem
Classification) map is available via the
bec() function, and an
bec_colours() function to colour
# This example requires the development version of ggplot2 which has the# `geom_sf()` function:# remotes::install_github("tidyverse/ggplot2")bec <- bec()library(ggplot2)ggplot() +geom_sf(data = bec[bec$ZONE %in% c("BG", "PP"),],aes(fill = ZONE, col = ZONE)) +scale_fill_manual(values = bec_colors()) +scale_colour_manual(values = bec_colours())
We have written a short vignette on plotting points on one of the layers
bcmaps. You can view the vignette online
or if you installed the package you can open it using
The package also contains a couple of handy utility functions:
fix_geo_problems()for fixing invalid topologies in
Spatialobjects such as orphaned holes and self-intersections
transform_bc_albers()for transforming any
Spatialobject to BC Albers projection.
SpatialPolygons*object with itself to remove overlaps, while retaining attributes
To report bugs/issues/feature requests, please file an issue.
Pull requests of new B.C. layers are welcome. If you would like to contribute to the package, please see our CONTRIBUTING guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
The source datasets used in this package come from various sources under
open licences, including DataBC (Open
Government Licence - British
and Statistics Canada
(Statistics Canada Open Licence
Agreement). See the
data-raw folder for details on each source dataset.
# Copyright 2017 Province of British Columbia # # 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 # # http://www.apache.org/licenses/LICENSE-2.0 # # 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.
self_union()would fail due to a change in the
shortcut_functioncolumn is now logical, uses better column names, and has a custom print function that gives more information. (#34)
municipalities(). This function combines Regional Districts with the Northern Rockies Regional Municipalites to create a full provincial layer of 'Regional-District-like' polygons.
bec(and other large downloadable layers) show up in the output of
get_layer("bec")works so that getting downloadable datasets is indistinguishable from getting local datasets. (#32)
sffunctions that have been moved to the
lwgeompackage. They now use the
lwgeomfunction (Fixes CRAN CHECK NOTE; #33).
bc_cities()which is a point layer of B.C.'s major cities.
raster_by_polyto overlay a SpatialPolygonsDataFrmae or sf polygons layer on a raster layer and clip the raster to each polygon, and
summarize_raster_listto summarize the results of
get_layer()now only accepts characters (#31)
check_write_to_data_dirwhere it was not creating data directory
bec(), which uses the new function
bec_colors()) to generate a vector of colours that match the standard colours used to colour Biogeoclimatic Zone maps.
getNamespaceExports("bcmaps")so that you can call layers without loading the package via
watershedslayer from package
This is a major new release with breaking changes.
All data has been removed from the
bcmaps package and moved to the
package, which is hosted on the bcgov drat repository: https://github.com/bcgov/drat.
That package must be installed in order for
bcmaps to access the data. It can
be installed with:
In previous versions of
bcmaps, data was stored in the package and loaded by
data("layername") or simply
Now loading data requires a function call - either using a shortcut function that
is the same name as the dataset (e.g.,
bc_bound() whereas previously one would
bc_bound). Alternatively, one can use the
Another major change is that all the layers are now returned as
sf classes by
default, rather than
Spatial versions of the data can still be
obtained by setting the
class argument to
get_layer() and the shortcut
bc_bound(class = "sp") or
get_layer("bc_bound", class = "sp")).
fix_geo_problemsfunction to set the maximum number of iterations it should go through in attempting to repair topological issues.
watercourses_5Mdatasets to UTF-8.
transform_bc_albersare Generic functions with methods for
sfobjects as well as
fix_self_intersectis now defunct
fix_self_intersecthas been renamed to
fix_geo_problems(but kept as an alias for now)
fix_geo_problemscan often also fix orphaned holes in addition to self-intersections.
watershedsdataset (#15, @markjohnsonubc)
NEWS.mdfile to track changes to the package.
Added two new functions to create and work with SpatailPolygonsDataFrames with nested data frames:
self_unionperforms a union on a single
SpatialPolygons*object to take into account overlaps. Polygon attributes are combined in a nested dataframe.
get_poly_attributeallows you to easily parse a nested data frame column (created by
self_union) to extract or calculate the attributes you want
Added a couple of convenience functions:
transform_bc_albers()transforms a Spatial object to BC Albers projection
fix_self_intersect()checks for and repairs self-intersecting polygons
Added 3 Natural Resource layers (areas, regions and districts)
Added high resolution BC boundaries (