Description Usage Arguments Details Examples
This function produces a map visualization of a data set containing GCAM
output data. The required argument is a data frame of GCAM results by
region. The function getQuery
produces suitable data
frames.
1 2 3 4 5 |
mapdata |
The data frame containing both geometric data (simple features collection and id) and regional metadata. This is the only mandatory variable. If used alone, will produce the default map. |
col |
If plotting categorical/continuous data, the name of the column to plot. Will automatically determine type of style of plot based on type of data (numeric or character). |
proj |
Map projection to use in the display map. This should be a proj4
string, except for a few special cases. There are also symbols defined for
some frequently used projections (e.g. |
proj_type |
Either esri, epsg, or sr-org as string. These correspond to available reference types hosted by http://spatialreference.org/. |
extent |
Numeric bounds [xmin, xmax, ymin, ymax] to zoom display to. |
title |
Text to be displayed as the plot title. |
legend |
Boolean flag: True = display map legend; False = do not display legend. |
gcam_df |
A data frame generated from the |
gcam_key |
The field name containing a join identifier in the gcam_df data frame. |
mapdata_key |
The field name containing a join identifier in the mapdata. |
zoom |
A distance to buffer the bounding box extent by for on-the-fly adjustments needed when fitting area to maps. |
graticules |
Where to position any graticules. One of 'top', 'bottom',
or ” (empty string). Note that 'bottom' places them under the map
background and will not be visible without a setting the
|
agr_type |
Aggregate-geometry-relationship type. Either 'constant' (default), 'aggregate', or 'identity' classified as follows: [constant] a variable that has a constant value at every location over a spatial extent; examples: soil type, climate zone, land use. [aggregate] values are summary values (aggregates) over the geometry, e.g. population density, dominant land use. [identity] values identify the geometry: they refer to (the whole of) this and only this geometry. See the sf vignette for further explanation. |
background_color |
Color for the areas with no regions (the oceans) |
padding |
Boolean flag: Add space between map edge and plot edge? |
We don't try to take the color mapping, legend title, etc. as arguments to this function. The ggplot2 way of specifying this information is way more flexible. To customize your color mapping, use one of
scale_fill_manual
: A list of colors to map to
categorical data.
scale_fill_gradient
: A
gradient from one color to another.
scale_fill_gradient2
: A diverging gradient from one
color to another, passing through white in the middle. You can set the data
value that gets assigned to white with the midpoint
argument.
scale_fill_gradientn
: A smooth gradient between an
arbitrary selection of colors.
If you choose to display a legend for the
color mapping, you will have to give it a title using the title
argument to any of the above gradient functions. You have to do this even if
you want a legend with no title at all. Use an empty string in that case.
For specifying the projection you can use any Proj4 string. For convenience, this package defines the following proj4 strings:
wgs84
- WGS84 (EPSG:4326)
eck3
- Eckert III
robin
- Robinson
na_aea
- Albers
equal area (North America)
ch_aea
- Albers equal area
(China)
af_ortho
- Orthographic projection over Africa
The extent
argument gives the bounding box of the area to be plotted.
Its format is c(lon.min, lon.max, lat.min, lat.max)
. For convenience
we have defined the following frequently used map extents:
EXTENT_WORLD
- Entire world
EXTENT_USA
-
Continental United States
EXTENT_CHINA
- China
EXTENT_AFRICA
- Africa
EXTENT_LA
- Latin
America
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
## Plot a map of GCAM regions; color it with the default theme palette.
plot_GCAM(map.rgn32.simple, col = 'region_name', proj = eck3) +
ggplot2::scale_fill_manual(values = gcam32_colors, na.value=gray(0.75))
## Plot refined liquids production by region for the year 2050
prj <- loadProject(system.file('sample-gcam-data',
'gcam-longform-sample.dat',
package='gcammaptools'))
ref_liquids <- rgcam::getQuery(prj, 'Refined liquids production by region', 'Reference')
ref_liquids <- add_region_ID(ref_liquids, lookupfile=rgn32, drops=rgn32)
ref_liquids <- dplyr::filter(ref_liquids, year==2050)
plot_GCAM(map.rgn32.simple, col='value', proj=robin, title="Robinson World",
legend=T, gcam_df=co2, gcam_key='id', mapdata_key="region_id") +
ggplot2::scale_fill_gradientn(colors = c("white", "red"),
na.value = gray(0.75),
name="CO2 Emissions (MTC)")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.