genPlot: Plot HarvestChoice 5-arc-minute spatial indicators

Description Usage Arguments Details Value See Also Examples

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").

Usage

1
2
3
4
5
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 options (e.g. "kmeans" or "pretty") or "default" to use default breaks

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

res

in ppi, by default set to 300ppi for print layout. Passed to png

...

any argument passed to png, e.g. pointsize

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

Value

Array of generated file names, one for each plot

See Also

hcapi

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Generate standard raster plot of 2012 population density for sub-Saharan Africa
x <- genPlot("PD12_TOT", pal="OrRd")
x


# 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


# 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

harvestchoice/hc-api3 documentation built on May 17, 2019, 3:04 p.m.