Home assignment 3#
Last updated: 2024-05-12 09:35:29
Question 1#
Read the
'world_cities.csv'
file into aDataFrame
object.Calculate and print a new table, where each row represents a country, with the following columns:
'country'
—Country name
'capital'
—The name of the capital city
'biggest_city'
—The name of the biggest city, i.e., the city which has the largest population in that countryPrint the subset of countries where the capital is not the same as the biggest city.
Note that for some countries there is more than one value marked as the capital! The resulting table still needs to have one row per country: capital name (
'capital'
) should be the first if there is more than one.
country | capital | biggest_city | |
---|---|---|---|
3 | American Samoa | Pago Pago | Tafuna |
11 | Australia | Canberra | Sydney |
20 | Belize | Belmopan | Belize |
21 | Benin | Porto Novo | Cotonou |
22 | Bermuda | Hamilton | Saint George |
... | ... | ... | ... |
209 | Turks and Caicos | Cockburn Town | Cockburn Harbour |
213 | USA | Washington | New York |
216 | United Arab Emirates | Abu Dhabi | Dubai |
221 | Venezuela | Caracas | Maracaibo |
222 | Vietnam | Ha Noi | Ho Chi Minh City |
46 rows × 3 columns
Question 2#
The text file named
'bgu.wkt'
(see Sample data) contains a WKT string representing the geometry of the BGU logo.Read the WKT string from the
'bgu.wkt'
file, using theopen
and.readline
methods (see Working with files). Convert the string into ashapely
geometryNote: Do not copy and paste the WKT string into your code! You need to read it from the
'bgu.wkt'
file.Display the logo graphically.
Calculate the area of the logo.
0.21286694897980007
Calculate a circle that is enclosing the logo. To do that, first calculate the average of x-axis bounds and the average of the y-axis bounds, then construct a point according to those x and y values, and finally buffer the point to a distance of your choice so that the logo is completely within the buffer.
Calculate the geometry of the difference between the logo and the bouding circle you calculated, then plot it.