|                                                                                                                                                                                     Tracking points through history                                                                                                      by                                                                    Eric Do
                                                                   Throughout this project I aimed to create a function that could return which countries a point was a part of throughout a certain point in time. Branching off of this function, I created visualizations displaying how country borders interacted with points throughout history. I also created a heat-map representing which points were the most contested throughout history.                                                                                                   There is a lot of data on how countries' borders have transformed throughout history, but not on specific points in relation to those transformations. I thought that it would be interesting to see how points have interacted with countries throughout history. From there, I wanted to figure out which points have been fought over most throughout history.                                                                                                                                                                             Retrieving Historical Country Dates                                                                                                       In order to find the countries a point was a part of throughout a period of time, I need to figure out which countries existed in which years.                                                                                                   Because constantly accessing entities would slow down my code, I created an association of the format                                                                    <|country -> {start year, end year}|> so I could easily figure out when countries existed.
                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           h                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                                                        =                                                                        I                                    f                                    [                                    !                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    Q                                    [                                    #                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    ]                                                                        &                                    &                                                                        !                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    Q                                    [                                    #                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    ]                                    ,                                    I                                    f                                    [                                    L                                    i                                    s                                    t                                    Q                                    [                                    #                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    ]                                    |                                    |                                    L                                    i                                    s                                    t                                    Q                                    [                                    #                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    ]                                    ,                                    {                                    #                                    [                                    "                                    N                                    a                                    m                                    e                                    "                                    ]                                    ,                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    T                                    a                                    b                                    l                                    e                                    [                                    I                                    f                                    [                                    !                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    Q                                    [                                    i                                    [                                    [                                    1                                    ]                                    ]                                    ]                                    &                                    &                                    !                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    Q                                    [                                    i                                    [                                    [                                    2                                    ]                                    ]                                    ]                                    ,                                    {                                    i                                    [                                    [                                    1                                    ,                                    1                                    ,                                    1                                    ]                                    ]                                    ,                                    i                                    [                                    [                                    2                                    ,                                    1                                    ,                                    1                                    ]                                    ]                                    }                                    ,                                                                        M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ]                                    ,                                    {                                    i                                    ,                                    T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    {                                    #                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    ,                                    #                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    }                                    ]                                    }                                    ]                                    ]                                    }                                    ,                                    {                                    #                                    [                                    "                                    N                                    a                                    m                                    e                                    "                                    ]                                    ,                                                                        {                                    #                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    [                                    [                                    1                                    ,                                    1                                    ]                                    ]                                    ,                                                                        #                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    [                                    [                                    1                                    ,                                    1                                    ]                                    ]                                    }                                    }                                                                                                            ]                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ]                                    &                                    /                                    @                                                                        E                                    n                                    t                                    i                                    t                                    y                                    L                                    i                                    s                                    t                                    [                                    "                                    H                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    C                                    o                                    u                                    n                                    t                                    r                                    y                                    "                                    ]                                    ;                                                                                                            h                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                                                        =                                    A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    T                                    h                                    r                                    e                                    a                                    d                                    [                                    T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    h                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ]                                    ]                                    [                                    [                                    1                                    ]                                    ]                                    -                                    >                                                                        T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    h                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ]                                    ]                                    [                                    [                                    2                                    ]                                    ]                                    ]                                    ;                                                                                                            c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                                                        =                                    {                                    #                                    [                                    "                                    N                                    a                                    m                                    e                                    "                                    ]                                    ,                                    {                                    #                                    [                                    "                                    I                                    n                                    d                                    e                                    p                                    e                                    n                                    d                                    e                                    n                                    c                                    e                                    Y                                    e                                    a                                    r                                    "                                    ]                                    [                                    [                                    1                                    ,                                    1                                    ]                                    ]                                    ,                                    2                                    0                                    2                                    1                                    }                                    }                                                                        &                                    /                                    @                                                                        E                                    n                                    t                                    i                                    t                                    y                                    L                                    i                                    s                                    t                                    [                                    E                                    n                                    t                                    i                                    t                                    y                                    C                                    l                                    a                                    s                                    s                                    [                                    "                                    C                                    o                                    u                                    n                                    t                                    r                                    y                                    "                                    ,                                                                        "                                    U                                    n                                    i                                    t                                    e                                    d                                    N                                    a                                    t                                    i                                    o                                    n                                    s                                    "                                    ]                                    ]                                    ;                                                                                                            c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                                                        =                                                                        A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    T                                    h                                    r                                    e                                    a                                    d                                    [                                    T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ]                                    [                                    [                                    1                                    ]                                    ]                                    -                                    >                                                                        T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ]                                    [                                    [                                    2                                    ]                                    ]                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    d                                    a                                    t                                    e                                    s                                                                        =                                                                        U                                    n                                    i                                    o                                    n                                    [                                    h                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ,                                                                        c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    d                                    a                                    t                                    e                                    s                                    ]                                                                                                                                                                               I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           c                                    o                                    u                                    n                                    t                                    r                                    y                                    d                                    a                                    t                                    e                                    s                                                                        =                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                         |                                                                                                                   A                                                          s                                                          s                                                          o                                                          c                                                          i                                                          a                                                          t                                                          i                                                          o                                                          n                                                          I                                                          c                                                          o                                                          n                                                         |                                                                                                                |  |                                            |                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                             H                                                          e                                                          a                                                          d                                                          :                                                                                                                                                                                                                                                                                                  A                                                          s                                                          s                                                          o                                                          c                                                          i                                                          a                                                          t                                                          i                                                          o                                                          n                                                         |                                                      |  |                                                      |                                                                                                                                                                             B                                                          y                                                          t                                                          e                                                                                                                                                                              c                                                          o                                                          u                                                          n                                                          t                                                          :                                                                                                                                                                                                                                                                                                  4                                                          1                                                          8                                                                                                                    8                                                          2                                                          4                                                         |  |                                                                          ;                                                                                                     The following function uses the association above and returns all the countries existing in a certain year.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           E                                    x                                    i                                    s                                    t                                    i                                    n                                    g                                    C                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    y                                    e                                    a                                    r                                    _                                    I                                    n                                    t                                    e                                    g                                    e                                    r                                    ]                                                                                                            :                                    =                                                                                                            D                                    e                                    l                                    e                                    t                                    e                                    D                                    u                                    p                                    l                                    i                                    c                                    a                                    t                                    e                                    s                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    F                                    l                                    a                                    t                                    t                                    e                                    n                                    [                                    T                                    a                                    b                                    l                                    e                                    [                                                                                                            I                                    f                                    [                                    i                                    [                                    [                                    1                                    ]                                    ]                                    <                                    =                                    y                                    e                                    a                                    r                                    <                                    =                                    i                                    [                                    [                                    2                                    ]                                    ]                                    ,                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                    I                                    n                                    d                                    e                                    x                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    d                                    a                                    t                                    e                                    s                                    ]                                    [                                    i                                    ]                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ]                                    ,                                    {                                    i                                    ,                                                                                                            V                                    a                                    l                                    u                                    e                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    d                                    a                                    t                                    e                                    s                                    ]                                    }                                    ]                                    ]                                    ]                                    ]                                                                                                                                                                               Tracking a Point Through Time                                                                                                       First I wanted to figure out which countries a point was a part of throughout a certain period in time. To do this, I planned to use polygons, which are useful for representing 2d spaces, for example, a country's boundaries.                                                                                                   The following function retrieves a country's polygon from its name.                                                                                                   c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  t                                  o                                  p                                  o                                  l                                  y                                  g                                  o                                  n                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  s                                  _                                  L                                  i                                  s                                  t                                  ,                                  y                                  e                                  a                                  r                                  _                                  I                                  n                                  t                                  e                                  g                                  e                                  r                                  ]                                  :                                  =                                                                                                      D                                  e                                  l                                  e                                  t                                  e                                  C                                  a                                  s                                  e                                  s                                  [                                  A                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  T                                  h                                  r                                  e                                  a                                  d                                  [                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  s                                                                                                      -                                  >                                                                                                      I                                  f                                  [                                  y                                  e                                  a                                  r                                                                                                      =                                  =                                                                                                      2                                  0                                  2                                  1                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  V                                  a                                  l                                  u                                  e                                  [                                  E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  #                                  ]                                                                                                      &                                  /                                  @                                                                                                      S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  s                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ,                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ]                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  V                                  a                                  l                                  u                                  e                                  [                                  E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  #                                  ]                                  &                                  /                                  @                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  s                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ,                                                                                                      D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ]                                  ]                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  _                                  _                                  _                                  ]                                  ]                                                                                                   Then I made a function that could tell which country a point was a part of in a particular year, given the polygons of each country in that year.                                                                                                   w                                  h                                  i                                  c                                  h                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  [                                  p                                  o                                  i                                  n                                  t                                  _                                  G                                  e                                  o                                  P                                  o                                  s                                  i                                  t                                  i                                  o                                  n                                  ,                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  a                                  n                                  d                                  p                                  o                                  l                                  y                                  g                                  o                                  n                                  s                                  _                                  A                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  ]                                  :                                  =                                                                                                                                                                          M                                  o                                  d                                  u                                  l                                  e                                  [                                  {                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  p                                  o                                  i                                  n                                  t                                  i                                  s                                  i                                  n                                  }                                  ,                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  y                                  p                                  o                                  i                                  n                                  t                                  i                                  s                                  i                                  n                                                                                                      =                                                                                                      D                                  e                                  l                                  e                                  t                                  e                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  I                                  f                                  [                                  G                                  e                                  o                                  W                                  i                                  t                                  h                                  i                                  n                                  Q                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  a                                  n                                  d                                  p                                  o                                  l                                  y                                  g                                  o                                  n                                  s                                  [                                  #                                  ]                                  ,                                  p                                  o                                  i                                  n                                  t                                  ]                                  ,                                  #                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  ]                                  ]                                                                                                      &                                  /                                  @                                                                                                      K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  a                                  n                                  d                                  p                                  o                                  l                                  y                                  g                                  o                                  n                                  s                                  ]                                  ]                                  ;                                                                                                      I                                  f                                  [                                  L                                  e                                  n                                  g                                  t                                  h                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  p                                  o                                  i                                  n                                  t                                  i                                  s                                  i                                  n                                  ]                                  =                                  =                                  0                                  ,                                  R                                  e                                  t                                  u                                  r                                  n                                  [                                  "                                  N                                  /                                  A                                  "                                  ]                                  ,                                  R                                  e                                  t                                  u                                  r                                  n                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  p                                  o                                  i                                  n                                  t                                  i                                  s                                  i                                  n                                  [                                  [                                  1                                  ]                                  ]                                  ]                                  ]                                  ]                                                                                                   This function helps format the years for the execution of the following function.                                                                                                   c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  y                                  e                                  a                                  r                                  s                                  [                                  y                                  e                                  a                                  r                                  s                                  _                                  L                                  i                                  s                                  t                                  ]                                  :                                  =                                  M                                  o                                  d                                  u                                  l                                  e                                  [                                  {                                  y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  }                                  ,                                  (                                  *                                  c                                  o                                  n                                  v                                  e                                  r                                  t                                                                                                      a                                                                                                      l                                  i                                  s                                  t                                                                                                      l                                  i                                  k                                  e                                                                                                      {                                  1                                  9                                  3                                  2                                  ,                                  1                                  9                                  3                                  3                                  ,                                  1                                  9                                  3                                  4                                  ,                                  1                                  9                                  3                                  5                                  ,                                  1                                  9                                  3                                  6                                  ,                                  1                                  9                                  4                                  8                                  ,                                  1                                  9                                  4                                  9                                  ,                                  1                                  9                                  7                                  0                                  }                                                                                                      t                                  o                                                                                                      {                                  1                                  9                                  3                                  2                                  -                                  1                                  9                                  3                                  6                                  ,                                  1                                  9                                  4                                  8                                  -                                  1                                  9                                  4                                  9                                  ,                                  1                                  9                                  7                                  0                                  }                                  *                                  )                                                                                                      y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                                                                                      =                                                                                                      F                                  l                                  a                                  t                                  t                                  e                                  n                                  [                                  {                                  F                                  l                                  a                                  t                                  t                                  e                                  n                                  [                                  T                                  a                                  b                                  l                                  e                                  [                                  I                                  f                                  [                                  y                                  e                                  a                                  r                                  s                                  [                                  [                                  i                                  +                                  1                                  ]                                  ]                                  -                                  y                                  e                                  a                                  r                                  s                                  [                                  [                                  i                                  ]                                  ]                                  =                                  =                                  1                                  ,                                  y                                  e                                  a                                  r                                  s                                  [                                  [                                  i                                  ]                                  ]                                  ,                                  {                                  y                                  e                                  a                                  r                                  s                                  [                                  [                                  i                                  ]                                  ]                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  ]                                  }                                  ]                                  ,                                  {                                  i                                  ,                                  L                                  e                                  n                                  g                                  t                                  h                                  [                                  y                                  e                                  a                                  r                                  s                                  ]                                  -                                  1                                  }                                  ]                                  ]                                  ,                                  {                                  y                                  e                                  a                                  r                                  s                                  [                                  [                                  -                                  1                                  ]                                  ]                                  }                                  }                                  ]                                  ;                                                                                                      y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                                                                                      =                                                                                                      D                                  e                                  l                                  e                                  t                                  e                                  C                                  a                                  s                                  e                                  s                                  [                                  S                                  p                                  l                                  i                                  t                                  B                                  y                                  [                                  y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  Q                                  ]                                  ,                                  {                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  ]                                  }                                  ]                                  ;                                                                                                      y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                                                                                      =                                                                                                      I                                  f                                  [                                  L                                  e                                  n                                  g                                  t                                  h                                  [                                  #                                  ]                                  >                                  1                                  ,                                  {                                  #                                  [                                  [                                  1                                  ]                                  ]                                  ,                                  #                                  [                                  [                                  -                                  1                                  ]                                  ]                                  }                                  ,                                  #                                  ]                                  &                                  /                                  @                                  y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  ;                                                                                                      R                                  e                                  t                                  u                                  r                                  n                                  [                                  y                                  e                                  a                                  r                                  s                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  ]                                                                                                      ]                                                                                                   The following function uses all of the ones created above and finds all the countries a point was a part of throughout a given period of time.                                                                                                   p                                  o                                  i                                  n                                  t                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  l                                  o                                  c                                  a                                  t                                  i                                  o                                  n                                  _                                  G                                  e                                  o                                  P                                  o                                  s                                  i                                  t                                  i                                  o                                  n                                  ,                                                                                                      p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  _                                  L                                  i                                  s                                  t                                  ]                                  :                                  =                                                                                                      M                                  o                                  d                                  u                                  l                                  e                                  [                                  {                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ,                                  t                                  i                                  m                                  e                                  s                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  o                                  c                                  c                                  u                                  p                                  i                                  e                                  d                                  ,                                  k                                  e                                  y                                  s                                  t                                  o                                  d                                  r                                  o                                  p                                  }                                  ,                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                                                                                      =                                                                                                      w                                  h                                  i                                  c                                  h                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  [                                  l                                  o                                  c                                  a                                  t                                  i                                  o                                  n                                  ,                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  n                                  a                                  m                                  e                                  t                                  o                                  p                                  o                                  l                                  y                                  g                                  o                                  n                                  [                                  E                                  x                                  i                                  s                                  t                                  i                                  n                                  g                                  C                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  #                                  ]                                  ,                                  #                                  ]                                  ]                                  &                                  /                                  @                                                                                                      R                                  a                                  n                                  g                                  e                                  [                                  p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  [                                  [                                  1                                  ]                                  ]                                  ,                                  p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  [                                  [                                  2                                  ]                                  ]                                  ]                                  ;                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                                                                                      =                                                                                                      M                                  e                                  r                                  g                                  e                                  [                                  T                                  a                                  b                                  l                                  e                                  [                                  <                                  |                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  [                                  i                                  ]                                  ]                                  -                                  >                                  i                                  +                                  p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  [                                  [                                  1                                  ]                                  ]                                  -                                  1                                  |                                  >                                  ,                                  {                                  i                                  ,                                  L                                  e                                  n                                  g                                  t                                  h                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                  }                                  ]                                  ,                                  I                                  d                                  e                                  n                                  t                                  i                                  t                                  y                                  ]                                  ;                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                                                                                      =                                                                                                      A                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  T                                  h                                  r                                  e                                  a                                  d                                  [                                  K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                  -                                  >                                  (                                  c                                  o                                  n                                  d                                  e                                  n                                  s                                  e                                  d                                  y                                  e                                  a                                  r                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  #                                  ]                                  ]                                  &                                  /                                  @                                                                                                      K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                  )                                  ]                                  ;                                                                                                      R                                  e                                  t                                  u                                  r                                  n                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                                                                                      ]                                                                                                   For example, we can use the following piece of code to figure out which countries had control of 49 latitude 2 longitude throughout the early 1900s.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           e                                    x                                    a                                    m                                    p                                    l                                    e                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    =                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    G                                    e                                    o                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                    [                                    {                                    4                                    9                                    ,                                    2                                    }                                    ]                                    ,                                    {                                    1                                    9                                    0                                    0                                    ,                                    1                                    9                                    5                                    0                                    }                                    ]                                    ;                                                                                                                                                                               I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           e                                    x                                    a                                    m                                    p                                    l                                    e                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                                                                                               O                                      u                                      t                                      [                                                                            ]                                      =                                                                                                                                                                                   F                                    r                                    e                                    n                                    c                                    h                                                                                                            T                                    h                                    i                                    r                                    d                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                            {                                    {                                    1                                                                        9                                    0                                    0                                    ,                                    1                                                                        9                                    4                                    0                                    }                                    }                                    ,                                                                        N                                    a                                    z                                    i                                                                                                            G                                    e                                    r                                    m                                    a                                    n                                    y                                                                                                            {                                    {                                    1                                                                        9                                    4                                    1                                    ,                                    1                                                                        9                                    4                                    4                                    }                                    }                                    ,                                                                        P                                    r                                    o                                    v                                    i                                    s                                    i                                    o                                    n                                    a                                    l                                                                                                            G                                    o                                    v                                    e                                    r                                    n                                    m                                    e                                    n                                    t                                                                                                            O                                    f                                                                                                            T                                    h                                    e                                                                                                            F                                    r                                    e                                    n                                    c                                    h                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                            {                                    {                                    1                                                                        9                                    4                                    5                                    }                                    }                                    ,                                                                        F                                    r                                    e                                    n                                    c                                    h                                                                                                            F                                    o                                    u                                    r                                    t                                    h                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                            {                                    {                                    1                                                                        9                                    4                                    6                                    ,                                    1                                                                        9                                    5                                    0                                    }                                    }                                                                                                                                         This function allows you to instead of inputting a point with latitude and longitude, to input a current city and find which countries it has been a part of.                                                                                                   c                                  i                                  t                                  y                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  c                                  i                                  t                                  y                                  _                                  E                                  n                                  t                                  i                                  t                                  y                                  ,                                  p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  _                                  L                                  i                                  s                                  t                                  ]                                  :                                  =                                                                                                      p                                  o                                  i                                  n                                  t                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  G                                  e                                  o                                  P                                  o                                  s                                  i                                  t                                  i                                  o                                  n                                  [                                  c                                  i                                  t                                  y                                  [                                  "                                  C                                  o                                  o                                  r                                  d                                  i                                  n                                  a                                  t                                  e                                  s                                  "                                  ]                                  ]                                  ,                                  p                                  e                                  r                                  i                                  o                                  d                                  o                                  f                                  t                                  i                                  m                                  e                                  ]                                                                                                   We can do the same as above but for an actual city, the code below returns the countries Berlin was a part of from 1850 to 1950.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           b                                    e                                    r                                    l                                    i                                    n                                    s                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    =                                    c                                    i                                    t                                    y                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                           ,                                    {                                    1                                    8                                    5                                    0                                    ,                                    1                                    9                                    5                                    0                                    }                                                                        ;                                                                                                                                                                               I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           b                                    e                                    r                                    l                                    i                                    n                                    s                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                                                                                               O                                      u                                      t                                      [                                                                            ]                                      =                                                                                                                                                                                   N                                    /                                    A                                                                                                            {                                    {                                    1                                                                        8                                    5                                    0                                    ,                                    1                                                                        8                                    6                                    6                                    }                                    ,                                    {                                    1                                                                        9                                    4                                    6                                    ,                                    1                                                                        9                                    4                                    9                                    }                                    }                                    ,                                                                        N                                    o                                    r                                    t                                    h                                                                                                            G                                    e                                    r                                    m                                    a                                    n                                                                                                            C                                    o                                    n                                    f                                    e                                    d                                    e                                    r                                    a                                    t                                    i                                    o                                    n                                                                                                            {                                    {                                    1                                                                        8                                    6                                    7                                    ,                                    1                                                                        8                                    7                                    0                                    }                                    }                                    ,                                                                        G                                    e                                    r                                    m                                    a                                    n                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                                                            {                                    {                                    1                                                                        8                                    7                                    1                                    ,                                    1                                                                        9                                    1                                    7                                    }                                    }                                    ,                                                                        W                                    e                                    i                                    m                                    a                                    r                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                            {                                    {                                    1                                                                        9                                    1                                    8                                    ,                                    1                                                                        9                                    3                                    2                                    }                                    }                                    ,                                                                        N                                    a                                    z                                    i                                                                                                            G                                    e                                    r                                    m                                    a                                    n                                    y                                                                                                            {                                    {                                    1                                                                        9                                    3                                    3                                    ,                                    1                                                                        9                                    4                                    5                                    }                                    }                                    ,                                                                        E                                    a                                    s                                    t                                                                                                            G                                    e                                    r                                    m                                    a                                    n                                    y                                                                                                            {                                    {                                    1                                                                        9                                    5                                    0                                    }                                    }                                                                                                                                         As the output of the function above isn't as visually appealing as it could be, I created a function to format that output                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           f                                    o                                    r                                    m                                    a                                    t                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    a                                    n                                    d                                    d                                    a                                    t                                    e                                    s                                    _                                    A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    ]                                    :                                    =                                                                                                            S                                    t                                    r                                    i                                    n                                    g                                    D                                    r                                    o                                    p                                    [                                                                                                            S                                    t                                    r                                    i                                    n                                    g                                    J                                    o                                    i                                    n                                    [                                                                                                            T                                    a                                    b                                    l                                    e                                    [                                    S                                    t                                    r                                    i                                    n                                    g                                    J                                    o                                    i                                    n                                    [                                    J                                    o                                    i                                    n                                    [                                    {                                    "                                    ,                                                                                                            "                                    ,                                    i                                    ,                                    "                                    :                                    "                                    }                                    ,                                                                                                            I                                    f                                    [                                    L                                    e                                    n                                    g                                    t                                    h                                    [                                    #                                    ]                                                                                                            >                                                                                                            1                                    ,                                                                                                            S                                    t                                    r                                    i                                    n                                    g                                    J                                    o                                    i                                    n                                    [                                    {                                    "                                                                                                            "                                    ,                                    T                                    o                                    S                                    t                                    r                                    i                                    n                                    g                                    [                                    #                                    [                                    [                                    1                                    ]                                    ]                                    ]                                    ,                                    "                                    -                                    "                                    ,                                    T                                    o                                    S                                    t                                    r                                    i                                    n                                    g                                    [                                    #                                    [                                    [                                    2                                    ]                                    ]                                    ]                                    }                                    ]                                    ,                                                                                                            S                                    t                                    r                                    i                                    n                                    g                                    J                                    o                                    i                                    n                                    [                                    "                                                                                                            "                                    ,                                    T                                    o                                    S                                    t                                    r                                    i                                    n                                    g                                    [                                    #                                    [                                    [                                    1                                    ]                                    ]                                    ]                                    ]                                    ]                                                                                                            &                                    /                                    @                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    a                                    n                                    d                                    d                                    a                                    t                                    e                                    s                                    [                                    [                                    i                                    ]                                    ]                                    ]                                    ]                                    ,                                    {                                    i                                    ,                                    K                                    e                                    y                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    a                                    n                                    d                                    d                                    a                                    t                                    e                                    s                                    ]                                    }                                    ]                                                                                                            ]                                    ,                                                                                                            1                                    ;                                    ;                                    2                                    ]                                                                                                     f                                  o                                  r                                  m                                  a                                  t                                  p                                  o                                  i                                  n                                  t                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  b                                  e                                  r                                  l                                  i                                  n                                  s                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                                                                                   Throughout history, there are many times where a country has changed its name without changing its borders (e.g. the French Revolution and the French First Republic becoming the First French Empire under Napoleon ). Because of this, needs to be a way to figure out when a country isn't changing its borders, just its names.                                                                                                   The following functions check whether two countries who end and start on the same year or one year apart, have the same polygon, meaning, the name of the country was changed.                                                                                                   s                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  1                                  _                                  S                                  t                                  r                                  i                                  n                                  g                                  ,                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  _                                  S                                  t                                  r                                  i                                  n                                  g                                  ,                                  y                                  e                                  a                                  r                                  _                                  I                                  n                                  t                                  e                                  g                                  e                                  r                                  ]                                  :                                  =                                                                                                      I                                  f                                  [                                  !                                  M                                  a                                  t                                  c                                  h                                  Q                                  [                                  E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  1                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  _                                  _                                  _                                  ]                                  ]                                  &                                  &                                                                                                      (                                  !                                  M                                  a                                  t                                  c                                  h                                  Q                                  [                                  E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  _                                  _                                  _                                  ]                                  ]                                  |                                  |                                                                                                      !                                  M                                  a                                  t                                  c                                  h                                  Q                                  [                                  E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  +                                  1                                  ]                                  ]                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  _                                  _                                  _                                  ]                                  ]                                  )                                  ,                                                                                                      S                                  a                                  m                                  e                                  Q                                  [                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  1                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ,                                                                                                      I                                  f                                  [                                  y                                  e                                  a                                  r                                  =                                  =                                                                                                      2                                  0                                  2                                  1                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ]                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  +                                  1                                  ]                                  ]                                  ]                                  ]                                  |                                  |                                                                                                      S                                  a                                  m                                  e                                  Q                                  [                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  1                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ,                                                                                                      I                                  f                                  [                                  y                                  e                                  a                                  r                                  =                                  =                                                                                                      2                                  0                                  2                                  1                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ]                                  ,                                                                                                      E                                  n                                  t                                  i                                  t                                  y                                  [                                  "                                  H                                  i                                  s                                  t                                  o                                  r                                  i                                  c                                  a                                  l                                  C                                  o                                  u                                  n                                  t                                  r                                  y                                  "                                  ,                                  S                                  t                                  r                                  i                                  n                                  g                                  D                                  e                                  l                                  e                                  t                                  e                                  [                                  C                                  a                                  p                                  i                                  t                                  a                                  l                                  i                                  z                                  e                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  2                                  ,                                  "                                  A                                  l                                  l                                  W                                  o                                  r                                  d                                  s                                  "                                  ]                                  ,                                  "                                                                                                      "                                  ]                                  ]                                  [                                  D                                  a                                  t                                  e                                  d                                  [                                  "                                  P                                  o                                  l                                  y                                  g                                  o                                  n                                  "                                  ,                                  y                                  e                                  a                                  r                                  ]                                  ]                                  ]                                  ]                                                                                                      ,                                  F                                  a                                  l                                  s                                  e                                  ]                                  ;                                                                                                   c                                  o                                  u                                  n                                  t                                  r                                  y                                  c                                  o                                  n                                  t                                  i                                  n                                  u                                  i                                  t                                  y                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  _                                  ]                                  :                                  =                                  M                                  e                                  r                                  g                                  e                                  [                                                                                                                                                                          D                                  e                                  l                                  e                                  t                                  e                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                                                                                      T                                  a                                  b                                  l                                  e                                  [                                  P                                  r                                  i                                  n                                  t                                  [                                  i                                  ]                                  ;                                                                                                      D                                  e                                  l                                  e                                  t                                  e                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  T                                  a                                  b                                  l                                  e                                  [                                                                                                      I                                  f                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  [                                  i                                  ]                                  [                                  [                                  -                                  1                                  ]                                  ]                                  =                                  =                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  [                                  j                                  ]                                  [                                  [                                  1                                  ]                                  ]                                  |                                  |                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  [                                  i                                  ]                                  [                                  [                                  -                                  1                                  ]                                  ]                                  =                                  =                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  [                                  j                                  ]                                  [                                  [                                  1                                  ]                                  ]                                  ,                                                                                                      I                                  f                                  [                                  s                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  [                                  i                                  ,                                  j                                  ,                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  [                                  i                                  ]                                  [                                  [                                  -                                  1                                  ]                                  ]                                  ]                                  ,                                  <                                  |                                  i                                  -                                  >                                  j                                  |                                  >                                  ,                                  M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  ]                                  ]                                  ,                                                                                                      M                                  i                                  s                                  s                                  i                                  n                                  g                                  [                                  ]                                  ]                                  ,                                                                                                      {                                  j                                  ,                                  K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  ]                                  }                                  ]                                  ]                                  ,                                                                                                      {                                  i                                  ,                                  K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  ]                                  }                                  ]                                  ]                                  ,                                  I                                  d                                  e                                  n                                  t                                  i                                  t                                  y                                  ]                                                                                                   The variable below holds an association between countries that are the same, but just changed their names.                                                                                                   d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  =                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  c                                  o                                  n                                  t                                  i                                  n                                  u                                  i                                  t                                  y                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  d                                  a                                  t                                  e                                  s                                  ]                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           d                                    i                                    f                                    f                                    n                                    a                                    m                                    e                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                        =                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                         |                                                                                                                   A                                                          s                                                          s                                                          o                                                          c                                                          i                                                          a                                                          t                                                          i                                                          o                                                          n                                                          I                                                          c                                                          o                                                          n                                                         |                                                                                                                |  |                                            |                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                             H                                                          e                                                          a                                                          d                                                          :                                                                                                                                                                                                                                                                                                  A                                                          s                                                          s                                                          o                                                          c                                                          i                                                          a                                                          t                                                          i                                                          o                                                          n                                                         |                                                      |  |                                                      |                                                                                                                                                                             B                                                          y                                                          t                                                          e                                                                                                                                                                              c                                                          o                                                          u                                                          n                                                          t                                                          :                                                                                                                                                                                                                                                                                                  1                                                                                                                    6                                                          0                                                          0                                                         |  |                                                                                                                                              O                                      u                                      t                                      [                                                                            ]                                      =                                                                                                                                                                                   E                                    a                                    s                                    t                                                                                                            F                                    r                                    a                                    n                                    c                                    i                                    a                                                                                                                                                H                                    o                                    l                                    y                                                                                                            R                                    o                                    m                                    a                                    n                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                        ,                                                                        F                                    r                                    e                                    n                                    c                                    h                                                                                                            F                                    i                                    r                                    s                                    t                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                                                                F                                    i                                    r                                    s                                    t                                                                                                            F                                    r                                    e                                    n                                    c                                    h                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                        ,                                                                        F                                    r                                    e                                    n                                    c                                    h                                                                                                            S                                    e                                    c                                    o                                    n                                    d                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                                                                S                                    e                                    c                                    o                                    n                                    d                                                                                                            F                                    r                                    e                                    n                                    c                                    h                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                        ,                                                                        H                                    e                                    l                                    v                                    e                                    t                                    i                                    c                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                                                                S                                    w                                    i                                    s                                    s                                                                                                            C                                    o                                    n                                    f                                    e                                    d                                    e                                    r                                    a                                    t                                    i                                    o                                    n                                                                                                            M                                    e                                    d                                    i                                    a                                    t                                    i                                    o                                    n                                                                        ,                                                                        N                                    e                                    w                                                                                                            H                                    e                                    b                                    r                                    i                                    d                                    e                                    s                                                                                                                                                V                                    a                                    n                                    u                                    a                                    t                                    u                                                                        ,                                                                        P                                    o                                    r                                    t                                    u                                    g                                    u                                    e                                    s                                    e                                                                                                            F                                    i                                    r                                    s                                    t                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                                                                D                                    i                                    t                                    a                                    d                                    u                                    r                                    a                                                                                                            N                                    a                                    c                                    i                                    o                                    n                                    a                                    l                                                                                                            P                                    o                                    r                                    t                                    u                                    g                                    a                                    l                                                                        ,                                                                        S                                    a                                    f                                    a                                    v                                    i                                    d                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                                                                                                A                                    f                                    s                                    h                                    a                                    r                                    i                                    d                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                        ,                                                                        S                                    e                                    c                                    o                                    n                                    d                                                                                                            F                                    r                                    e                                    n                                    c                                    h                                                                                                            E                                    m                                    p                                    i                                    r                                    e                                                                                                                                                F                                    r                                    e                                    n                                    c                                    h                                                                                                            T                                    h                                    i                                    r                                    d                                                                                                            R                                    e                                    p                                    u                                    b                                    l                                    i                                    c                                                                                                                                                                             This function uses the association above to figure out the actual number of countries a point was a part of.                                                                                                   n                                  u                                  m                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  a                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  _                                  A                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  ,                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  _                                  A                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  ]                                  :                                  =                                                                                                      M                                  o                                  d                                  u                                  l                                  e                                  [                                  {                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  }                                  ,                                                                                                      c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                                                                                      =                                                                                                      D                                  e                                  l                                  e                                  t                                  e                                  D                                  u                                  p                                  l                                  i                                  c                                  a                                  t                                  e                                  s                                  [                                  I                                  f                                  [                                  M                                  e                                  m                                  b                                  e                                  r                                  Q                                  [                                  K                                  e                                  y                                  s                                  [                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                  ,                                  #                                  ]                                  ,                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  #                                  ]                                  ,                                  #                                  ]                                  &                                  /                                  @                                  K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  a                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  ]                                  ]                                  ;                                                                                                      R                                  e                                  t                                  u                                  r                                  n                                  [                                  L                                  e                                  n                                  g                                  t                                  h                                  [                                  D                                  e                                  l                                  e                                  t                                  e                                  D                                  u                                  p                                  l                                  i                                  c                                  a                                  t                                  e                                  s                                  [                                  I                                  f                                  [                                  M                                  e                                  m                                  b                                  e                                  r                                  Q                                  [                                  K                                  e                                  y                                  s                                  [                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  ]                                  ,                                  #                                  ]                                  ,                                  d                                  i                                  f                                  f                                  n                                  a                                  m                                  e                                  c                                  o                                  u                                  n                                  t                                  r                                  i                                  e                                  s                                  [                                  #                                  ]                                  ,                                  #                                  ]                                  &                                  /                                  @                                  K                                  e                                  y                                  s                                  [                                  c                                  o                                  u                                  n                                  t                                  r                                  y                                  a                                  s                                  s                                  o                                  c                                  i                                  a                                  t                                  i                                  o                                  n                                  ]                                  ]                                  ]                                  ]                                  ]                                                                                                                                                                             Visualizing the Transformation of Borders Surrounding a Point                                                                                                       I thought that the best way to visualize the interaction between a point and the countries around it was through an interactive map.                                                                                                   This function will get all the years necessary for the interactive map.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    _                                    ]                                    :                                    =                                    M                                    o                                    d                                    u                                    l                                    e                                    [                                    {                                    d                                    a                                    t                                    e                                    r                                    a                                    n                                    g                                    e                                    }                                    ,                                                                                                            I                                    f                                    [                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    Q                                    [                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    ,                                    "                                    Y                                    e                                    a                                    r                                    "                                    ]                                    ]                                    ,                                                                                                            d                                    a                                    t                                    e                                    r                                    a                                    n                                    g                                    e                                                                                                            =                                                                                                            D                                    a                                    t                                    e                                    R                                    a                                    n                                    g                                    e                                    [                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    ,                                    "                                    Y                                    e                                    a                                    r                                    "                                    ]                                    ,                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    "                                    E                                    n                                    d                                    D                                    a                                    t                                    e                                    "                                    ]                                    ,                                    "                                    Y                                    e                                    a                                    r                                    "                                    ]                                    ]                                    ,                                                                                                            d                                    a                                    t                                    e                                    r                                    a                                    n                                    g                                    e                                                                                                            =                                                                                                            D                                    a                                    t                                    e                                    R                                    a                                    n                                    g                                    e                                    [                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    "                                    S                                    t                                    a                                    r                                    t                                    D                                    a                                    t                                    e                                    "                                    ]                                    ,                                    "                                    Y                                    e                                    a                                    r                                    "                                    ]                                    ,                                    D                                    a                                    t                                    e                                    O                                    b                                    j                                    e                                    c                                    t                                    [                                    N                                    o                                    w                                    ,                                    "                                    Y                                    e                                    a                                    r                                    "                                    ]                                    ]                                                                                                            ]                                    ;                                                                                                            R                                    e                                    t                                    u                                    r                                    n                                    [                                    d                                    a                                    t                                    e                                    r                                    a                                    n                                    g                                    e                                    ]                                    ]                                                                                                     For example,  Austria-Hungary existed in the following years:                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                                                                                                                                                                                                                                                                                                                                                                               |                                                                                                                                               A                                                u                                                s                                                t                                                r                                                i                                                a                                                -                                                H                                                u                                                n                                                g                                                a                                                r                                                y                                                                                               |                                                                                                                                               H                                                I                                                S                                                T                                                O                                                R                                                I                                                C                                                A                                                L                                                                                                                                                C                                                O                                                U                                                N                                                T                                                R                                                Y                                                                                               |                                                                                                                                                                                                                     O                                      u                                      t                                      [                                                                            ]                                      =                                                                                                                                                                                  ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                       ,                                                                                                                                                                            This function helps format some previous outputs so that they are compatible for these visualizations.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           g                                    e                                    t                                    r                                    a                                    n                                    g                                    e                                    s                                    [                                    y                                    e                                    a                                    r                                    s                                    _                                    L                                    i                                    s                                    t                                    ]                                    :                                    =                                    F                                    l                                    a                                    t                                    t                                    e                                    n                                    [                                    I                                    f                                    [                                    L                                    e                                    n                                    g                                    t                                    h                                    [                                    #                                    ]                                    >                                    1                                    ,                                    R                                    a                                    n                                    g                                    e                                    [                                    #                                    [                                    [                                    1                                    ]                                    ]                                    ,                                    #                                    [                                    [                                    2                                    ]                                    ]                                    ]                                    ,                                    #                                    [                                    [                                    1                                    ]                                    ]                                    ]                                    &                                    /                                    @                                    y                                    e                                    a                                    r                                    s                                    ]                                                                                                     The following function creates the maps necessary for the visualization in a later function.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           g                                    e                                    o                                    l                                    i                                    s                                    t                                    [                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    _                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    _                                    ,                                    l                                    i                                    s                                    t                                    f                                    r                                    o                                    m                                    g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                    _                                    ,                                    p                                    o                                    i                                    n                                    t                                    _                                    G                                    e                                    o                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                    ]                                    :                                    =                                                                                                            S                                    e                                    l                                    e                                    c                                    t                                    [                                                                                                            A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    T                                    h                                    r                                    e                                    a                                    d                                    [                                                                                                            l                                    i                                    s                                    t                                    f                                    r                                    o                                    m                                    g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                    ,                                                                                                            T                                    a                                    b                                    l                                    e                                    [                                                                                                            G                                    e                                    o                                    G                                    r                                    a                                    p                                    h                                    i                                    c                                    s                                    [                                    {                                    G                                    e                                    o                                    S                                    t                                    y                                    l                                    i                                    n                                    g                                    [                                    N                                    o                                    n                                    e                                    ]                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    D                                    a                                    t                                    e                                    d                                    [                                    "                                    P                                    o                                    l                                    y                                    g                                    o                                    n                                    "                                    ,                                    y                                    e                                    a                                    r                                    ]                                    ]                                    ,                                    G                                    e                                    o                                    S                                    t                                    y                                    l                                    i                                    n                                    g                                    [                                    A                                    u                                    t                                    o                                    m                                    a                                    t                                    i                                    c                                    ]                                    ,                                    R                                    e                                    d                                    ,                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    "                                    P                                    o                                    l                                    y                                    g                                    o                                    n                                    "                                    ]                                    ,                                    G                                    e                                    o                                    M                                    a                                    r                                    k                                    e                                    r                                    [                                    p                                    o                                    i                                    n                                    t                                    ]                                    }                                    ,                                    G                                    e                                    o                                    R                                    a                                    n                                    g                                    e                                    -                                    >                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    ]                                    ,                                                                                                            {                                    y                                    e                                    a                                    r                                    ,                                                                                                            l                                    i                                    s                                    t                                    f                                    r                                    o                                    m                                    g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                    }                                    ]                                    ]                                    ,                                                                                                            F                                    r                                    e                                    e                                    Q                                    [                                    #                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    "                                    N                                    o                                    t                                    A                                    p                                    p                                    l                                    i                                    c                                    a                                    b                                    l                                    e                                    "                                    ]                                    ]                                    &                                    ]                                                                                                     The following function uses all the functions above to create maps of a point and the current country its in overlaid on the country it was in during a certain year                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           v                                    i                                    s                                    u                                    a                                    l                                    i                                    z                                    e                                    p                                    o                                    i                                    n                                    t                                    [                                    p                                    o                                    i                                    n                                    t                                    _                                    G                                    e                                    o                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                    ,                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    _                                    A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    ]                                    :                                    =                                                                                                            M                                    o                                    d                                    u                                    l                                    e                                    [                                    {                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    ,                                    i                                    m                                    a                                    g                                    e                                    s                                    }                                    ,                                                                                                            c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                                                                                            =                                                                                                            w                                    h                                    i                                    c                                    h                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    [                                    p                                    o                                    i                                    n                                    t                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    E                                    x                                    i                                    s                                    t                                    i                                    n                                    g                                    C                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    2                                    0                                    2                                    1                                    ]                                    ,                                    2                                    0                                    2                                    1                                    ]                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                                                                                            =                                                                                                            g                                    e                                    t                                    y                                    e                                    a                                    r                                    s                                    [                                    E                                    n                                    t                                    i                                    t                                    y                                    [                                    "                                    H                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    C                                    o                                    u                                    n                                    t                                    r                                    y                                    "                                    ,                                    S                                    t                                    r                                    i                                    n                                    g                                    D                                    e                                    l                                    e                                    t                                    e                                    [                                    C                                    a                                    p                                    i                                    t                                    a                                    l                                    i                                    z                                    e                                    [                                    #                                    ,                                    "                                    A                                    l                                    l                                    W                                    o                                    r                                    d                                    s                                    "                                    ]                                    ,                                    "                                                                                                            "                                    ]                                    ]                                    ]                                    &                                    /                                    @                                                                                                            D                                    e                                    l                                    e                                    t                                    e                                    C                                    a                                    s                                    e                                    s                                    [                                    K                                    e                                    y                                    s                                    [                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ]                                    ,                                    "                                    N                                    /                                    A                                    "                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                                                                                            =                                                                                                            A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    T                                    h                                    r                                    e                                    a                                    d                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    C                                    a                                    s                                    e                                    s                                    [                                    K                                    e                                    y                                    s                                    [                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ]                                    ,                                    "                                    N                                    /                                    A                                    "                                    ]                                    -                                    >                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                                                                                            =                                                                                                            T                                    a                                    b                                    l                                    e                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    T                                    a                                    b                                    l                                    e                                    [                                    I                                    f                                    [                                    M                                    e                                    m                                    b                                    e                                    r                                    Q                                    [                                    g                                    e                                    t                                    r                                    a                                    n                                    g                                    e                                    s                                    [                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    i                                    ]                                    ]                                    ,                                    j                                    [                                    [                                    1                                    ,                                    1                                    ]                                    ]                                    ]                                    ,                                    j                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ]                                    ,                                    {                                    j                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    [                                    i                                    ]                                    }                                    ]                                    ]                                    ,                                    {                                    i                                    ,                                    K                                    e                                    y                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    ]                                    }                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                                                                                            =                                                                                                            A                                    s                                    s                                    o                                    c                                    i                                    a                                    t                                    i                                    o                                    n                                    T                                    h                                    r                                    e                                    a                                    d                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    C                                    a                                    s                                    e                                    s                                    [                                    K                                    e                                    y                                    s                                    [                                    p                                    o                                    i                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ]                                    ,                                    "                                    N                                    /                                    A                                    "                                    ]                                    -                                    >                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    ]                                    ;                                                                                                            i                                    m                                    a                                    g                                    e                                    s                                                                                                            =                                                                                                            M                                    e                                    r                                    g                                    e                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    C                                    a                                    s                                    e                                    s                                    [                                    g                                    e                                    o                                    l                                    i                                    s                                    t                                    [                                    E                                    n                                    t                                    i                                    t                                    y                                    [                                    "                                    C                                    o                                    u                                    n                                    t                                    r                                    y                                    "                                    ,                                    S                                    t                                    r                                    i                                    n                                    g                                    D                                    e                                    l                                    e                                    t                                    e                                    [                                    C                                    a                                    p                                    i                                    t                                    a                                    l                                    i                                    z                                    e                                    [                                    c                                    u                                    r                                    r                                    e                                    n                                    t                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    ,                                    "                                    A                                    l                                    l                                    W                                    o                                    r                                    d                                    s                                    "                                    ]                                    ,                                    "                                                                                                            "                                    ]                                    ]                                    ,                                    E                                    n                                    t                                    i                                    t                                    y                                    [                                    "                                    H                                    i                                    s                                    t                                    o                                    r                                    i                                    c                                    a                                    l                                    C                                    o                                    u                                    n                                    t                                    r                                    y                                    "                                    ,                                    S                                    t                                    r                                    i                                    n                                    g                                    D                                    e                                    l                                    e                                    t                                    e                                    [                                    C                                    a                                    p                                    i                                    t                                    a                                    l                                    i                                    z                                    e                                    [                                    #                                    ,                                    "                                    A                                    l                                    l                                    W                                    o                                    r                                    d                                    s                                    "                                    ]                                    ,                                    "                                                                                                            "                                    ]                                    ]                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    [                                    #                                    ]                                    ,                                    p                                    o                                    i                                    n                                    t                                    ]                                    &                                    /                                    @                                    K                                    e                                    y                                    s                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    y                                    e                                    a                                    r                                    s                                    ]                                    ,                                    <                                    |                                    |                                    >                                    ]                                    ,                                    I                                    d                                    e                                    n                                    t                                    i                                    t                                    y                                    ]                                    ;                                                                                                                                                                                    R                                    e                                    t                                    u                                    r                                    n                                    [                                    i                                    m                                    a                                    g                                    e                                    s                                    ]                                                                                                            ]                                                                                                     Then we use the output of the function above to create a visualization of how the borders surrounding a point have transformed over the years.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           p                                    o                                    i                                    n                                    t                                    v                                    i                                    s                                    u                                    a                                    l                                    i                                    z                                    a                                    t                                    i                                    o                                    n                                    [                                    i                                    m                                    a                                    g                                    e                                    s                                    _                                    ]                                    :                                    =                                                                                                            M                                    a                                    n                                    i                                    p                                    u                                    l                                    a                                    t                                    e                                    [                                    i                                    m                                    a                                    g                                    e                                    s                                    [                                    Y                                    e                                    a                                    r                                    ]                                    [                                    [                                    1                                    ]                                    ]                                    ,                                    {                                    Y                                    e                                    a                                    r                                    ,                                    K                                    e                                    y                                    s                                    [                                    i                                    m                                    a                                    g                                    e                                    s                                    ]                                    }                                    ,                                    C                                    o                                    n                                    t                                    r                                    o                                    l                                    T                                    y                                    p                                    e                                                                        S                                    l                                    i                                    d                                    e                                    r                                    ]                                                                                                     In the  visualization below, the area covered in black is the country that occupied the given point during that year (which can be changed by moving the slider on top), and the transparent red area is its current country.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           p                                    o                                    i                                    n                                    t                                    v                                    i                                    s                                    u                                    a                                    l                                    i                                    z                                    a                                    t                                    i                                    o                                    n                                                                        v                                    i                                    s                                    u                                    a                                    l                                    i                                    z                                    e                                    p                                    o                                    i                                    n                                    t                                                                        G                                    e                                    o                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                                                                                           [                                    "                                    C                                    o                                    o                                    r                                    d                                    i                                    n                                    a                                    t                                    e                                    s                                    "                                    ]                                                                        ,                                    b                                    e                                    r                                    l                                    i                                    n                                    s                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                                                                                                                                                                       Visualizing the most contested areas throughout history                                                                                                       I thought that the best way to do this, was to calculate the differences in polygons of the same country between years, and the differences between them would be land that had change hands. To represent this, I planned to plot these polygons transparently, making it so that when land had changed hands multiple times, the transparent polygons would stack on top of each other making the more contested areas darker.                                                                                                   In order to figure out the differences between polygons, I needed to reformat their polygons.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           c                                    o                                    r                                    r                                    e                                    c                                    t                                    p                                    r                                    o                                    j                                    e                                    c                                    t                                    i                                    o                                    n                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    _                                                                                                            ]                                    :                                    =                                                                                                            (                                    *                                    c                                    o                                    n                                    v                                    e                                    r                                    t                                    s                                                                                                            t                                    h                                    e                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                                                                                            i                                    n                                    t                                    o                                                                                                            t                                    h                                    e                                                                                                            E                                    q                                    u                                    i                                    r                                    e                                    c                                    t                                    a                                    n                                    g                                    u                                    l                                    a                                    r                                                                                                            p                                    r                                    o                                    j                                    e                                    c                                    t                                    i                                    o                                    n                                                                                                            (                                    l                                    a                                    t                                                                                                            a                                    n                                    d                                                                                                            l                                    o                                    n                                    g                                                                                                            l                                    i                                    n                                    e                                                                                                            u                                    p                                    )                                    *                                    )                                                                                                            I                                    f                                    [                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    Q                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    ]                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                                                                                            /                                    .                                                                                                            g                                    p                                    _                                    G                                    e                                    o                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                                                                                            :                                    >                                                                                                            G                                    e                                    o                                    G                                    r                                    i                                    d                                    P                                    o                                    s                                    i                                    t                                    i                                    o                                    n                                    [                                    g                                    p                                    ,                                                                                                            "                                    E                                    q                                    u                                    i                                    r                                    e                                    c                                    t                                    a                                    n                                    g                                    u                                    l                                    a                                    r                                    "                                    ]                                    [                                    [                                    1                                    ]                                    ]                                    ]                                                                                                     Next, I created a function to calculate all the land that had been lost or gained by countries in a span of 1 year.                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           a                                    r                                    e                                    a                                    c                                    h                                    a                                    n                                    g                                    e                                    d                                    [                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    _                                    I                                    n                                    t                                    e                                    g                                    e                                    r                                    ,                                                                                                            e                                    n                                    d                                    y                                    e                                    a                                    r                                    _                                    I                                    n                                    t                                    e                                    g                                    e                                    r                                    ]                                    :                                    =                                                                                                            M                                    o                                    d                                    u                                    l                                    e                                    [                                    {                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ,                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ,                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    c                                    h                                    a                                    n                                    g                                    i                                    n                                    g                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    s                                    }                                    ,                                                                                                            s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                            =                                                                                                            E                                    x                                    i                                    s                                    t                                    i                                    n                                    g                                    C                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    ]                                    ;                                                                                                            e                                    n                                    d                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                                                                                            =                                                                                                            E                                    x                                    i                                    s                                    t                                    i                                    n                                    g                                    C                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    [                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    ]                                    ;                                                                                                            c                                    o                                    u                                    n                                    t                                    r                                    y                                    c                                    h                                    a                                    n                                    g                                    i                                    n                                    g                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    s                                                                                                            =                                                                                                            I                                    f                                    [                                    M                                    e                                    m                                    b                                    e                                    r                                    Q                                    [                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ,                                    #                                    ]                                                                                                            &                                    &                                                                                                            L                                    e                                    n                                    g                                    t                                    h                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    ]                                    ]                                                                                                            !                                    =                                                                                                            0                                                                                                            &                                    &                                                                                                            L                                    e                                    n                                    g                                    t                                    h                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    ]                                    ]                                                                                                            !                                    =                                                                                                            0                                    ,                                                                                                            I                                    f                                    [                                    !                                    S                                    a                                    m                                    e                                    Q                                    [                                    T                                    o                                    S                                    t                                    r                                    i                                    n                                    g                                    [                                    H                                    e                                    a                                    d                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    ]                                    [                                    #                                    ]                                    ]                                    ]                                    ,                                    "                                    F                                    i                                    l                                    l                                    e                                    d                                    C                                    u                                    r                                    v                                    e                                    "                                    ]                                                                                                            &                                    &                                                                                                            !                                    S                                    a                                    m                                    e                                    Q                                    [                                    T                                    o                                    S                                    t                                    r                                    i                                    n                                    g                                    [                                    H                                    e                                    a                                    d                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    ]                                    [                                    #                                    ]                                    ]                                    ]                                    ,                                    "                                    F                                    i                                    l                                    l                                    e                                    d                                    C                                    u                                    r                                    v                                    e                                    "                                    ]                                    ,                                                                                                            {                                    #                                    ,                                    R                                    e                                    g                                    i                                    o                                    n                                    S                                    y                                    m                                    m                                    e                                    t                                    r                                    i                                    c                                    D                                    i                                    f                                    f                                    e                                    r                                    e                                    n                                    c                                    e                                    [                                    c                                    o                                    r                                    r                                    e                                    c                                    t                                    p                                    r                                    o                                    j                                    e                                    c                                    t                                    i                                    o                                    n                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    ]                                    [                                    #                                    ]                                    ]                                    ,                                    c                                    o                                    r                                    r                                    e                                    c                                    t                                    p                                    r                                    o                                    j                                    e                                    c                                    t                                    i                                    o                                    n                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    n                                    a                                    m                                    e                                    t                                    o                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    [                                    {                                    #                                    }                                    ,                                    e                                    n                                    d                                    y                                    e                                    a                                    r                                    ]                                    [                                    #                                    ]                                    ]                                    ]                                    }                                    ,                                                                                                            M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                                                                                            ]                                    ,                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    ]                                    ]                                                                                                            &                                    /                                    @                                                                                                            s                                    t                                    a                                    r                                    t                                    y                                    e                                    a                                    r                                    c                                    o                                    u                                    n                                    t                                    r                                    i                                    e                                    s                                    ;                                                                                                            R                                    e                                    t                                    u                                    r                                    n                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    C                                    a                                    s                                    e                                    s                                    [                                    D                                    e                                    l                                    e                                    t                                    e                                    M                                    i                                    s                                    s                                    i                                    n                                    g                                    [                                    c                                    o                                    u                                    n                                    t                                    r                                    y                                    c                                    h                                    a                                    n                                    g                                    i                                    n                                    g                                    p                                    o                                    l                                    y                                    g                                    o                                    n                                    s                                    ]                                    ,                                    {                                    _                                    _                                    _                                    ,                                    E                                    m                                    p                                    t                                    y                                    R                                    e                                    g                                    i                                    o                                    n                                    [                                    _                                    ]                                    }                                    ]                                    ]                                                                                                            (                                    *                                    R                                    E                                    T                                    U                                    R                                    N                                    S                                                                                                            A                                                                                                            L                                    I                                    S                                    T                                                                                                            O                                    F                                                                                                            P                                    O                                    L                                    Y                                    G                                    O                                    N                                    S                                                                                                            R                                    E                                    P                                    R                                    E                                    S                                    E                                    N                                    T                                    I                                    N                                    G                                                                                                            T                                    H                                    E                                                                                                            L                                    A                                    N                                    D                                                                                                            T                                    H                                    A                                    T                                                                                                            C                                    H                                    A                                    N                                    G                                    E                                    D                                                                                                            C                                    O                                    U                                    N                                    T                                    R                                    I                                    E                                    S                                    *                                    )                                                                                                            ]                                                                                                     The following plot displays land that changed countries more frequently darker.                                                                                                   m                                  i                                  d                                  t                                  w                                  e                                  n                                  t                                  y                                  t                                  h                                  c                                  e                                  n                                  t                                  u                                  r                                  y                                  a                                  r                                  e                                  a                                  =                                  F                                  l                                  a                                  t                                  t                                  e                                  n                                  [                                  T                                  a                                  b                                  l                                  e                                  [                                  a                                  r                                  e                                  a                                  c                                  h                                  a                                  n                                  g                                  e                                  d                                  [                                  i                                  ,                                  i                                  +                                  1                                  ]                                  ,                                  {                                  i                                  ,                                                                    R                                  a                                  n                                  g                                  e                                  [                                  1                                  9                                  2                                  1                                  ,                                  1                                  9                                  3                                  9                                  ]                                  }                                  ]                                  ]                                                                                                                                                                             I                                      n                                      [                                                                            ]                                      :                                      =                                                                                                           G                                    e                                    o                                    G                                    r                                    a                                    p                                    h                                    i                                    c                                    s                                    [                                    {                                    O                                    p                                    a                                    c                                    i                                    t                                    y                                    [                                    0                                    .                                    1                                    ]                                    ,                                    R                                    e                                    d                                    ,                                    T                                    r                                    a                                    n                                    s                                    p                                    o                                    s                                    e                                    [                                    m                                    i                                    d                                    t                                    w                                    e                                    n                                    t                                    y                                    t                                    h                                    c                                    e                                    n                                    t                                    u                                    r                                    y                                    a                                    r                                    e                                    a                                    ]                                    [                                    [                                    2                                    ]                                    ]                                    }                                    ,                                                                        G                                    e                                    o                                    P                                    r                                    o                                    j                                    e                                    c                                    t                                    i                                    o                                    n                                                                                                            "                                    E                                    q                                    u                                    i                                    r                                    e                                    c                                    t                                    a                                    n                                    g                                    u                                    l                                    a                                    r                                    "                                    ,                                                                        G                                    e                                    o                                    B                                    a                                    c                                    k                                    g                                    r                                    o                                    u                                    n                                    d                                    -                                    >                                    "                                    S                                    t                                    r                                    e                                    e                                    t                                    M                                    a                                    p                                    N                                    o                                    L                                    a                                    b                                    e                                    l                                    s                                    "                                    ]                                                                                                                                                                                                                                                       Through this project, I was able to create a function that took a point, and gives back the countries it was in and what year it was in each of them throughout a certain period of time.                                                                                                                                                                                                                                                           The main improvement I can make on this project is to try to make these functions faster. Iterating through a bunch of polygons to figure out which country a point is in is inefficient, and I need to find a way to lessen the number of polygons the function needs to iterate through without slowing down the function.                                                                                                                                                                                                                                                           I think that it would be really interesting to try to create an algorithm that takes in a point, and based on the time period and where the point is, predict how many countries it has been a part of.                                                                                                  Attachments: | 
                    
0 Response to "Mathematica Find Out History of a Tracked Symbol"
Post a Comment