Description Usage Arguments Details Value See Also Examples
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")
.
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), ...)
|
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 |
n |
|
width |
plot width in pixel (unless |
height |
plot height in pixel (unless |
units |
one of "px" (default), "in", "cm" or "mm".
Passed to |
res |
in ppi, by default set to 300ppi for print layout.
Passed to |
... |
any argument passed to |
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
Array of generated file names, one for each plot
hcapi
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.