similar: Rank spatial units by similarity

Description Usage Arguments Details Value Examples

Description

Rank regions, districts, or pixels by similarity to a reference unit across a set of indicators. To generate a distance score, we center and scale all numeric variables and convert classified variables to 0 or 1 (1 if same as reference unit, 0 otherwise). For each variable we compute the absolute percent deviation between each unit and the reference unit, and we then sum the deviations across all variables to generate an aggregate distance score. The lower the score, the more similar the unit for the selected indicators.

Usage

1
similar(x, var, by = 0, iso3 = "SSA")

Arguments

x

single integer code for the reference geography, either a region code (ADM1_CODE_ALT), district code (ADM2_CODE_ALT), or gridcell code (CELL5M) to rank against

var

character array of HarvestChoice variable codes used in the ranking

by

single integer indicating the type of reference geography (0-gridcell, 1-region, 2-district)

iso3

optional country or region filter (3-letter code)

Details

API call: rank Ghana districts by similarity to district 16657 (Kpando) based on length of growing period, irrigated area, and cassava value of production

$ curl http://hcapi.harvestchoice.org/ocpu/library/hcapi3/R/similar/json \ -d '{"x" : 16657, "var" : ["LGP_AVG", "GMIA_V5", "cass_v"], "by" : 2, "iso3" : "GHA"}' \ -X POST -H "Content-Type:application/json"

Value

a data.table of regions, districts, or pixels ranked by similarity to a reference geography x

Examples

1
2
3
4
# Rank all districts in Ghana by similarity to district 16657 (Kpando)
# based on length of growing period (LGP_AVG), irrigated cropland (GMIA_V5),
# and cassava value of production (cass_v).
similar(16657, c("LGP_AVG", "GMIA_V5", "cass_v"), by=2, iso3="GHA")

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