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:
- What does the histogram of pairwise distances between all capital cities look like? Plot to be submitted.
- 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.
- Which two capitals are the farthest apart from each other?
- Which two capitals are the closest to each other?
- Which capital is the most isolated?
- Which capital is the most closest to most of the capitals of other countries?
- Which capital is the most equally distant from all other countries?
Hints
- You can use the distance measure from Assignment-1.
- You should first calculate a distance matrix that stores the pairwise distance between any two capitals.
- You can use the lecture notes on Numpy and matplotlib and links therein for help.
- 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:
- your code file
- A single document file containing answers to the questions 1 and 3-7
- csv file for question 2