Plot HarvestChoice 5-arc-minute spatial indicators

Usage

genPlot(var, iso3 = "SSA", pal = character(0), layout = "default", style = "default", n = integer(0), width = switch(layout, default = 640, print = 5, thumbnail = 120), height = switch(layout, default = 640, print = 5, thumbnail = 120), units = switch(layout, default = "px", print = "in", thumbnail = "px"), res = switch(layout, print = 300, NA), ...)

Arguments

var
character array of variable codes to plot
iso3
optional ISO3 country or region code(s)
pal
optional Brewer color palette used for plotting, e.g. "Blues"
layout
one of "default", "print", or "thumbnail" to control legend and axes
style
one of classIntervals style
n
classIntervals n argument to control the number of breaks
width
plot width in pixel (unless units is specified)
height
plot height in pixel (unless units is specified)
units
one of "px" (default), "in", "cm" or "mm". Passed to png
...
any argument passed to png, e.g. pointsize
resolution
in ppi, by default set to 300ppi for print layout. Passed to png options (e.g. "kmeans" or "pretty") or "default" to use default breaks

Value

Array of generated file names, one for each plot

Description

Method to plot HarvestChoice rasters with mutiple layout and symbology options. See examples below. Note that calling genPlot(...) is equivalent to calling the convenience function hcapi(..., format="png").

Details

API call: generate 2 plots showing farming systems and 2012 population density for Ghana

$ curl http://hcapi.harvestchoice.org/ocpu/library/hcapi3/R/hcapi \ -d '{"var":["FS_2012_TX", "PD12_TOT"], "iso3":"GHA", "format":"png"}' \ -X POST -H 'Content-Type:application/json' -- /ocpu/tmp/x03d5aa8e98/R/.val /ocpu/tmp/x03d5aa8e98/stdout /ocpu/tmp/x03d5aa8e98/source /ocpu/tmp/x03d5aa8e98/console /ocpu/tmp/x03d5aa8e98/info /ocpu/tmp/x03d5aa8e98/files/DESCRIPTION /ocpu/tmp/x03d5aa8e98/files/FS_2012_TX.GHA.png /ocpu/tmp/x03d5aa8e98/files/PD12_TOT.GHA.png

GET all generated plots in a ZIP archive

$ wget http://hcapi.harvestchoice.org/ocpu/tmp/x03d5aa8e98/zip

Examples

# Generate standard raster plot of 2012 population density for sub-Saharan Africa x <- genPlot("PD12_TOT", pal="OrRd") x
[1] "PD12_TOT.png"
# Generate 3 raster plots for Ghana with legend and title but not axes x <- genPlot(c("AEZ16_CLAS", "cass_h"), iso3="GHA", layout="print") x
[1] "AEZ16_CLAS.GHA.print.png" "cass_h.GHA.print.png"
# Generate 3 raster plots for Nigeria with the specified dimensions x <- genPlot(c("FS_2012", "yield_l_cv", "soc_d15"), iso3="NGA", width=5, height=5, units="in", res=200, pointsize=8) x
[1] "FS_2012.NGA.png" "yield_l_cv.NGA.png" "soc_d15.NGA.png"

See also

hcapi