Now, the objective is to know how much area is occupied by each country. However, the coordinates of country borders are expressed in latitude and longitude, and we can't calculate areas in this coordinate system. We want the area to be in the metric system, so first we need to convert the spatial reference system of the geometries.
Let's also take a step further in the programming techniques and start using functions to avoid the repetition of code. Perform the following steps:
Chapter1directory, name this file
world_areas.py, and program this first function:
import ogr def open_shapefile(file_path): """Open the shapefile, get the first layer and ...