All Projects β†’ bcgov β†’ bcmaps

bcgov / bcmaps

Licence: Apache-2.0 License
An R package of map layers for British Columbia

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to bcmaps

NLMR
πŸ“¦ R package to simulate neutral landscape models πŸ”
Stars: ✭ 57 (+7.55%)
Mutual labels:  rstats, r-package
dotwhisker
Dot-and-Whisker Plots of Regression Results
Stars: ✭ 51 (-3.77%)
Mutual labels:  rstats, r-package
paleobioDB
R interface to the Paleobiology Database
Stars: ✭ 36 (-32.08%)
Mutual labels:  rstats, r-package
mutant
mutation testing for R
Stars: ✭ 13 (-75.47%)
Mutual labels:  rstats, r-package
rsnps
Wrapper to a number of SNP web APIs
Stars: ✭ 44 (-16.98%)
Mutual labels:  rstats, r-package
WikidataQueryServiceR
An R package for the Wikidata Query Service API
Stars: ✭ 23 (-56.6%)
Mutual labels:  rstats, r-package
miner
R package for controlling Minecraft via API
Stars: ✭ 74 (+39.62%)
Mutual labels:  rstats, r-package
pbapply
Adding progress bar to '*apply' functions in R
Stars: ✭ 115 (+116.98%)
Mutual labels:  rstats, r-package
getCRUCLdata
CRU CL v. 2.0 Climatology Client for R
Stars: ✭ 17 (-67.92%)
Mutual labels:  rstats, r-package
schtools
Schloss Lab Tools for Reproducible Microbiome Research πŸ’©
Stars: ✭ 22 (-58.49%)
Mutual labels:  rstats, r-package
rglobi
R library to access species interaction data of http://globalbioticinteractions.org
Stars: ✭ 12 (-77.36%)
Mutual labels:  rstats, r-package
roadoi
Use Unpaywall with R
Stars: ✭ 60 (+13.21%)
Mutual labels:  rstats, r-package
rinat
A programmatic interface to iNaturalist
Stars: ✭ 36 (-32.08%)
Mutual labels:  rstats, r-package
rredlist
IUCN Red List API Client
Stars: ✭ 31 (-41.51%)
Mutual labels:  rstats, r-package
rfishbase
R interface to the fishbase.org database
Stars: ✭ 79 (+49.06%)
Mutual labels:  rstats, r-package
rdryad
R client for Dryad web services
Stars: ✭ 25 (-52.83%)
Mutual labels:  rstats, r-package
antiword
R wrapper for antiword utility
Stars: ✭ 47 (-11.32%)
Mutual labels:  rstats, r-package
cyphr
Humane encryption
Stars: ✭ 91 (+71.7%)
Mutual labels:  rstats, r-package
bc-population-indicator
R scripts for an indicator on trends in B.C.'s population size & distribution published on Environmental Reporting BC
Stars: ✭ 12 (-77.36%)
Mutual labels:  rstats, env
checkers
β›” ARCHIVED β›” Automated checking of best practices for research compendia βœ”οΈ
Stars: ✭ 53 (+0%)
Mutual labels:  rstats, r-package

bcmaps

Version 1.0.2.9000

img License R build status CRAN_Status_Badge CRAN Downloads

Overview

An R package of spatial map layers for British Columbia.

Features

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 Albers projection, which is the B.C. Government standard as sf or Spatial objects.

Most layers are assessed directly from the B.C. Data Catalogue using the bcdata R package. See each layers individual help file for more detail.

Installation

You can install bcmaps from CRAN:

install.packages("bcmaps")

To install the development version of the bcmaps package, you need to install the remotes package then the bcmaps package.

install.packages("remotes")
remotes::install_github("bcgov/bcmaps")

Usage

To see the layers that are available, run the available_layers() function:

library(bcmaps)
available_layers()

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 sf or Spatial object. The first time you run try to access a layer, you will be prompted for permission to download that layer to your hard drive. Subsequently that layer is available locally for easy future access. For example:

library(sf)

bc <- bc_bound()
plot(st_geometry(bc))

Simple Features objects

By default, all layers are returned as sf spatial objects:

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 Kootenays
rd <- regional_districts()
kootenays <- rd[rd$ADMIN_AREA_NAME == "Regional District of Central Kootenay", ]
plot(st_geometry(kootenays), col = "lightseagreen", add = TRUE)

Digital Elevation Model for British Columbia 1:250,000

The cded_raster and cded_stars functions return the 1:250,000 digital elevation model for British Columbia bounded by some area of interest. Here we are retrieving the area bounded by the Logan Lake census subdivision:

library(raster)

aoi <- census_subdivision()[census_subdivision()$CENSUS_SUBDIVISION_NAME == "Logan Lake", ]
aoi_raster <- cded_raster(aoi)
plot(aoi_raster)

It’s a beautiful day in the neighbourhood

A handy layer for creating maps for display is the bc_neighbours layer, accessible with the function by the same name. This example also illustrates using the popular ggplot2 package to plot maps in R using geom_sf:

library(ggplot2)
ggplot() + 
  geom_sf(data = bc_neighbours(), mapping = aes(fill = name)) + 
  geom_sf(data = bc_cities()) +
  coord_sf(datum = NA) +
  scale_fill_viridis_d(name = "Jurisdiction") +
  theme_minimal()

Biogeoclimatic Zones

As of version 0.15.0 the B.C. BEC (Biogeoclimatic Ecosystem Classification) map is available via the bec() function, and an accompanying function bec_colours() function to colour it:

bec <- bec()
library(ggplot2)
bec_sub <- bec[bec$ZONE %in% c("BG", "PP"),]
ggplot() +
  geom_sf(data = bec_sub,
          aes(fill = ZONE, col = ZONE)) +
  scale_fill_manual(values = bec_colors()) +
  scale_colour_manual(values = bec_colours())

Spatial (sp) objects

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(bc_bound(class = "sp"))
plot(watercourses_15M(class = "sp"), add = TRUE)

Updating layers

When you first call a layer function bcmaps will remind you when that layer was last updated in your cache with a message. For a number of reasons, it might be necessary to get a fresh layer in your bcmaps cache. The easiest way to update is to use the force argument:

ep <- ecoprovinces(force = TRUE)

Another option is to actively manage your cache by deleting the old layer and calling the function again:

delete_cache('ecoprovinces')
ep <- ecoprovinces(force = TRUE)

Vignettes

After installing the package you can view vignettes by typing browseVignettes("bcmaps") in your R session.

Utility Functions

The package also contains a couple of handy utility functions:

  1. fix_geo_problems() for fixing invalid topologies in sf or Spatial objects such as orphaned holes and self-intersections
  2. transform_bc_albers() for transforming any sf or Spatial object to BC Albers projection.
  3. self_union() Union a SpatialPolygons* object with itself to remove overlaps, while retaining attributes

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

How to Contribute

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.

Source Data

The source datasets used in this package come from various sources under open licences, including DataBC (Open Government Licence - British Columbia) and Statistics Canada (Statistics Canada Open Licence Agreement). See the data-raw folder for details on each source dataset.

Licence

# 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.

This repository is maintained by Environmental Reporting BC. Click here for a complete list of our repositories on GitHub.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].