...

/

Solution: Aggregation and Constructive Methods

Solution: Aggregation and Constructive Methods

Practice the concepts of aggregation and constructive methods with real datasets.

Solution: Shore islands

Let's review the code solution:

Press + to interact
import geopandas as gpd
# open the datasets
islands = gpd.read_file('minor_islands.geojson')
countries = gpd.read_file('countries.geojson')
# create the continents boundaries
continents = countries.dissolve(by='continent')
# select the African continent
africa = continents.loc[['Africa']]
# create a buffer distant 150km from the africa boundaries
limits = africa.buffer(1.5)
# get the islands inside the limits
shore_islands = islands.clip(limits)
# display the results
ax = continents.loc[['Africa']].plot()
limits.plot(ax=ax, facecolor='none', edgecolor='grey')
shore_islands.plot(ax=ax, edgecolor='red', linewidth=3)
ax.set_ylabel('Latitude (degrees)')
ax.set_xlabel('Longitude (degrees)')
ax.figure.savefig('output/shore_islands.png', dpi=300)

To identify the islands that are within a given distance from Africa, we first need a polygon ...

Access this course and 1400+ top-rated courses and projects.