This time, we'll do a join based on location.
Import pandas, geopandas, matplotlib.pyplot, and os.
>>> import pandas as pd
>>> import geopandas as gpd
>>> import matplotlib.pyplot as plt
>>> import os
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import os
>>> os.chdir('../')
>>> os.getcwd()
os.chdir('../')
os.getcwd()
>>> floods = gpd.read_file('workshopdata/Flood2013Extents.shp')
>>> floods
floods = gpd.read_file('workshopdata/Flood2013Extents.shp')
floods.plot()
buildings = gpd.read_file('https://opendata.arcgis.com/datasets/0d43652d038a4a0dbca68f0501151bb0_0.geojson')
>>> buildings.plot(figsize=(12,12))
buildings.plot(figsize=(12,12))
>>> len(buildings)
len(buildings)
>>> flooded_buildings = gpd.sjoin(buildings, floods)
flooded_buildings = gpd.sjoin(buildings, floods)
>>> print(buildings.crs)
>>> print(floods.crs)
print(buildings.crs)
print(floods.crs)
>>> buildings = buildings.to_crs(floods.crs)
>>> buildings.crs
buildings = buildings.to_crs(floods.crs)
buildings.crs
>>> flooded_buildings = gpd.sjoin(buildings, floods)
flooded_buildings = gpd.sjoin(buildings, floods)
>>> len(flooded_buildings)
len(flooded_buildings)
>>> ax = floods.plot(alpha=0.5, figsize=(15,15))
>>> flooded_buildings.plot(ax=ax, color='green', edgecolor='green')
ax = floods.plot(alpha=0.5, figsize=(15,15))
flooded_buildings.plot(ax=ax, color='green', edgecolor='green')