Git Product home page Git Product logo

migrationviz's Introduction

Migrationviz readme

Visualizing international migration flows using UN migrants stock data

  • A shiny app for visualizing international migration flows to and from a region using UN migrants stock data.

  • Colors to visualize direction of movement, and number of arcs to visualize size of movement.

  • It's very easy to use, just select the region, theme, year to update the output. That's it!

**Try it at** https://asheshwor.shinyapps.io/migrationviz/

Screenshot Screenshot of options

--- .class #id bg:#F0F0F0

2 | Getting the data

  • The migration data was obtained from [United Nations, Department of Economic and Social Affairs, Population Division] (http://esa.un.org/unmigration/TIMSA2013/data/UN_MigrantStock_2013.xls)

  • The world map shape file was obtained from [NaturalEarthData.com] (naturalearthdata.com). The location and population of cities were obtained from the cities database at [geonames.org] (geonames.org)

  • Code for reading migration data, world map shape file and cities database:

data2013 <- read.xlsx2("data/UN_MigrantStockByOriginAndDestination_2013.xls",
                       sheetName = "Table 10",
                       startRow = 16, colIndex = c(2, 4 , 10:241),
                       colClasses = c("character", rep("numeric", 232)))
wmap <- readShapeSpatial("data/110m_cultural/ne_110m_admin_0_countries.shp")
places <- read.csv("data/cities1000.csv", header=FALSE, stringsAsFactors=FALSE)

--- .class #id bg:#F0F0F0

3 | Data processing

  • With some processing, a data-frame with the required arc connections is created. Following is an example a section of the dataframe for Australia
##   source destination stock lat.d lon.d lat.s lon.s stocklog id
## 1     AD          AU    22   -27   133  42.5   1.5        3  1
## 2     AD          AU    22   -27   133  42.5   1.5        3  1
## 3     AD          AU    22   -27   133  42.5   1.5        3  1
## 4     AE          AU  5890   -27   133  24.0  54.0        9  2
## 5     AE          AU  5890   -27   133  24.0  54.0        9  2
## 6     AE          AU  5890   -27   133  24.0  54.0        9  2
## 7     AE          AU  5890   -27   133  24.0  54.0        9  2
## 8     AE          AU  5890   -27   133  24.0  54.0        9  2
  • In the next step, the source and destination coordinates are replaced with locations of cities in the from the country or region.

--- .class #id bg:#F0F0F0

4 | Migrant origin and destination points

  • The coordinates for each origin or destination in a region are sampled from 15 most populated cities in that region with probability based on the population.

  • Since the sampling is done at random, the map generated each time is different.

More populated cities are more likely to get selected

Cities with higher population are more likely to get selected

--- .class #id bg:#F0F0F0

5 | Generating the final map

  • Finally the great circle arcs obtained using gcIntermediate function are and plotted using ggplot2 over the world map.

Final plot example for Nepal with dark map theme

An example plot for Nepal with 'dark' map theme Try the app at https://asheshwor.shinyapps.io/migrationviz/

migrationviz's People

Contributors

asheshwor avatar

Stargazers

e.o.ozdamar avatar

Watchers

James Cloos avatar e.o.ozdamar avatar Daniel Emaasit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.