Skip to content

Commit d5ac8e4

Browse files
committed
Add the base maps as data sets loadable with data()
1 parent 6c4ab9e commit d5ac8e4

10 files changed

+125
-0
lines changed

R/gcammaptools.R

+36
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,39 @@
5252
#' @import ggplot2
5353
#' @importFrom magrittr %>%
5454
NULL
55+
56+
#' Base map for 14-region GCAM
57+
#'
58+
#' This is the region map used in versions of GCAM prior to GCAM 4.0. It is
59+
#' largely obsolete, but there are still some data from those days floating
60+
#' around in the wild
61+
#'
62+
#' @format Spatial data frame
63+
"map.rgn14"
64+
65+
#' Base map for 32-region GCAM
66+
#'
67+
#' This is the region map used in GCAM 4.0 and subsequent. This version of the
68+
#' map does not include the Taiwan region.
69+
#'
70+
#' @format Spatial data frame
71+
"map.rgn32"
72+
73+
#' Base map for 235 global water basins
74+
#'
75+
#' This is the map of the 235 global water basins. For compatibility with the
76+
#' other map data frames it refers to the basins as "regions". Thus, any GCAM
77+
#' data with a "basin" column will need to have a "region" column added. There
78+
#' is also some variability in how the basin names are represented, so this data
79+
#' set will need some work.
80+
#'
81+
#' @format Spatial data frame
82+
"map.basin235"
83+
84+
#' Base map for 32-region GCAM with China subregions
85+
#'
86+
#' This map has the 32 GCAM regions, plus the subregions corresponding to
87+
#' China's provinces, municipalities, autonomous regions, and SARs.
88+
#'
89+
#' @format Spatial data frame
90+
"map.chn"

data-raw/gen-maps.R

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### Run this script in an interactive session and call \code{devtools::use_data}
2+
### on the resulting outputs. It assumes you are at the package top level
3+
### directory.
4+
5+
library('magrittr')
6+
7+
load.geojson <- function(file, property) {
8+
map <- rgdal::readOGR(file) %>% ggplot2::fortify(region=property)
9+
}
10+
11+
gen.data <- function() {
12+
map.rgn14 <- load.geojson('inst/extdata/rgn14/GCAM_region.geojson', 'GCAM_regio')
13+
map.rgn32 <- load.geojson('inst/extdata/rgn32/GCAM_32_wo_Taiwan_clean.geojson', 'GCAM_ID')
14+
map.basin235 <- load.geojson('inst/extdata/rgnbasin/Global235_CLM_05_dissolve.geojson', 'GCAM_ID_1')
15+
map.chn <- load.geojson('inst/extdata/rgnchn/GCAM_China.geojson', 'GCAM_ID')
16+
## TODO: add GCAM-USA dataset here
17+
18+
devtools::use_data(map.rgn14, map.rgn32, map.basin235, map.chn)
19+
}
20+
21+
gen.data()

data/map.basin235.rda

44.2 KB
Binary file not shown.

data/map.chn.rda

2.02 MB
Binary file not shown.

data/map.rgn14.rda

304 KB
Binary file not shown.

data/map.rgn32.rda

331 KB
Binary file not shown.

man/map.basin235.Rd

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/map.chn.Rd

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/map.rgn14.Rd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/map.rgn32.Rd

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)