Assignment 4: Numpy for some geography

In this assignment you will use the GPS coordinates (latitude,longitude) of the capital cities of different countries (attached file: countries.csv) to answer simple geography questions. You are required to do this through Numpy and matplotlib. Here are the questions:

  1. What does the histogram of pairwise distances between all capital cities look like? Plot to be submitted.
  2. Find the nearest and farthest capital with respect to the capital of each country in the input file. A comma separated value (csv) file is to be submitted which, on each line, contains: Name of country, name of its capital city, closest capital, farthest capital. It will be interesting to look at these results for Pakistan.
  3. Which two capitals are the farthest apart from each other?
  4. Which two capitals are the closest to each other?
  5. Which capital is the most isolated?
  6. Which capital is the most closest to most of the capitals of other countries?
  7. Which capital is the most equally distant from all other countries?

Hints

  1. You can use the distance measure from Assignment-1.
  2. You should first calculate a distance matrix that stores the pairwise distance between any two capitals.
  3. You can use the lecture notes on Numpy and matplotlib and links therein for help.
  4. You can find help on the csv python module to read and write csv files. You are also free to write your own file reader/writer.

Submission

Please submit the following:

  1. your code file
  2. A single document file containing answers to the questions 1 and 3-7
  3. csv file for question 2