✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
import geopandas as gpd
def spatial_query(buildings_gdf, rivers_gdf, distance=50): rivers_buffer = rivers_gdf.buffer(distance) rivers_buffer_union = gpd.GeoSeries(rivers_buffer).unary_union buildings_in_buffer = buildings_gdf[buildings_gdf.intersects(rivers_buffer_union)] return buildings_in_buffer