Here is the explanation for the code:
- shpfilename = shpreader.natural_earth(resolution='110m', category='cultural', name='admin_0_countries') downloads the required shapefile from the Natural Earth data website.
- reader = shpreader.Reader(shpfilename) sets up the reader to extract data from shapefile.
- countries = reader.records() sets up a generator object to start reading the file.
- country = next(countries) extracts the next country record.
- population = lambda country: country.attributes['POP_EST'] defines an anonymous function that returns the population for a given country record.'POP_EST' is one of the attributes of the imported country record. lambda is a Python construct for defining temporary, one-time use anonymous ...