unhcr / koboloadeR

deprecated please use {kobocruncher} - https://edouard-legoupil.github.io/kobocruncher/
https://unhcr.github.io/koboloadeR/docs/
28 stars 28 forks source link

Add map output in the report #10

Open Edouard-Legoupil opened 6 years ago

Edouard-Legoupil commented 6 years ago

Started building some raw map output from data + dictionary: https://github.com/unhcr/koboloadeR/blob/master/R/kobo_map_cat.R https://github.com/unhcr/koboloadeR/blob/master/R/kobo_map_int.R

This should be included in the report generation scripts

Edouard-Legoupil commented 6 years ago

Brainstorming:

The objective is to include basic mapping of the variable

STEP 1 Define 2 additional columns in the xlsform (aka data analysis plan)

to indicate whether the variable should be mapped as:

STEP 2 Add configuration to set up the polygons for the maps.

2 options for the join between the dataset and the polygons:

STEP 3 Define default spatial visualization for the map:

Case 1: the variable is numeric

image

image

_Case 2: the variable is categoric (aka select_one or selectmultiple)

Maps will have to be faceted using as many facet as modalities within the variable.

SCRIPT TO WRITE

  1. Automatic parsing of the dataset using the dico to generate spatialpointdataframe
  2. Automatic interserction of the spatialpoint with spatialpolygondataframe
  3. Automatic classification of average/sum or frequency/proportion - probably using ClassInt Jenks algorithm -
  4. Insertion of small histogram in the chart to present the result of the univariate classification
  5. A series of test to ensure that the configuration is ok... (points does intersect polygon, key matching works correctly - cf function: https://github.com/AndySouth/rworldmap/blob/master/R/joinCountryData2Map.R
Edouard-Legoupil commented 5 years ago

As a lot of map will be created, it would make sense to compute l-morand index to help identifying the most meaningful ones. Some references below:

http://rspatial.org/analysis/rst/3-spauto.html https://stats.idre.ucla.edu/r/faq/how-can-i-calculate-morans-i-in-r/ http://www.bias-project.org.uk/ASDARcourse/unit6_slides.pdf https://mgimond.github.io/Spatial/spatial-autocorrelation-in-r.html https://s3.amazonaws.com/geoda/docs/LA_multivariateGeary1.pdf http://www.econ.uiuc.edu/~lab/workshop/Spatial_in_R.html#testing-for-spatial-autocorrelation