Friday, February 16, 2018

Vietnam interactive map with R (part 2)

This is the update on the Vietnam choropleth map from the previous post. I thank Loan Vu for providing me with the VHLSS data.

This map presents average annual household income from two sources : "Employment" (primary and secondary jobs-related) and "Agriculture" (a sum of income from "Cultivation", "Animal Husbandry" and "Agricultural, Forestry and Aquaculture" sources). The total income is shown in this. The updates are:
  • I provide values converted to $US here, rather than in VND as before (although doing this disregard purchasing power parity altogether!). 
  • A toggle button to select income types, plus a legend for each variable, are added.
  • As before, map is zoom-able. The min and max zoom parameters are slightly changed.
I haven't figured out how to add more than 2 layers without significantly reduce the loading time (not that the current loading time is that impressive!). Additionally, to make it more interactive, the legends should be toggled together with the map layers. I did write a better UI with Shiny, but publishing it requires premium account for Rstudio. Hopefully I can do more tinkering in the future, maybe after finishing my studies.

Disclaimer:  The information on this map was derived from digital databases from OpenStreetMap. OpenStreetMap is open data, licensed under the Open Data Commons Open Database License (ODbL) by the OpenStreetMap Foundation (OSMF). The map tile used is licenced as CC BY-SA.  For more about copyright, please see https://www.openstreetmap.org/copyright 

Sunday, February 4, 2018

Vietnam interactive map with R

 

This is my first attempt at drawing an interactive map with leaflet, created by the Rstudio team (a nice introduction to the package, which I follow to create this map, can be found here). Quite a bit of data involved, so the map might load rather slowly.
The data are from the Vietnam Household Living Standard Survey (VHLSS), 2014 round. They are available for purchase from the Vietnam's General Statistics Office. Here I only use income data ("Muc 4"). I aggregated the multiple income sources at the household level (summing across all family members), and take the unweighted mean of income across all households surveyed in each province.

  • The gradient color scaling is based on the magnitude of the mean income from all sources. The darker the color scheme, the more affluence the average household there.
  • To see the underlying data for the provinces, hover your mouse over the corresponding provinces. Keep in mind that this is only a prototype. I'm planning to break the map into layers (each shows one category of income) and better representations.
  • Zoom in using mouse scroll or the buttons on the left. Click, hold and drag left mouse to refocus.
Feel free to contact me for details.