Rank spatial units by similarity

Usage

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)

Value

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

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.

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"

Examples

# 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")
ISO3 ADM0_NAME ADM2_CODE_ALT LGP_AVG GMIA_V5 cass_v Score 1: GHA Ghana 16657 278 0 3021856 0.0000000 2: GHA Ghana 16575 287 0 3172796 0.2157802 3: GHA Ghana 16595 265 28 3176379 0.3335517 4: GHA Ghana 16651 273 0 5486071 0.3914655 5: GHA Ghana 16652 271 97 5449375 0.5322633 --- 106: GHA Ghana 16636 181 3008 3471751 5.3190665 107: GHA Ghana 16658 230 0 41057948 5.3987159 108: GHA Ghana 16644 169 3096 0 5.9687622 109: GHA Ghana 16618 283 4633 17700273 6.6024348 110: GHA Ghana 16628 178 153 45721318 7.2371012