In [2]:
import json, shapely, fiona, os
import seaborn as sns
import pandas as pd
import geopandas as gpd
import networkx as nx
import matplotlib.pyplot as plt

%matplotlib inline

In [4]:
buildings = gpd.read_file('data/Building_Footprints.shp')
print("Found {0} buildings".format(len(buildings)))
buildings.head(1);


Found 45728 buildings

In [6]:
flood_extent = gpd.read_file('data/Flood2013Extents.shp')
flood_extent.head()


Out[6]:
OBJECTID CREEK MAPPING_ST SHAPE_AREA SHAPE_LEN geometry
0 1 Gregory Canyon Creek Complete 2.105969e+06 33078.761777 POLYGON ((3060082.675777227 1246067.801150128,...
1 2 Sunshine Canyon Creek Complete 1.128345e+06 25405.394518 POLYGON ((3058244.465214819 1249329.027567297,...
2 3 Boulder Slough Complete 1.152517e+06 24891.760136 (POLYGON ((3064533.865365639 1249084.573987961...
3 4 Goose Creek Complete 2.479010e+06 49036.323199 (POLYGON ((3065561.063770562 1253580.064996973...
4 5 Elmers Twomile Creek Complete 1.441207e+05 4564.338099 (POLYGON ((3067065.181169137 1254926.188617051...

In [10]:
flood_extent = flood_extent.to_crs(buildings.crs)

In [12]:
flooded_buildings = gpd.sjoin(buildings, flood_extent)
flooded_buildings.head()

In [16]:
with open('/home/cc/www/flooded_buildings.geojson','w') as outFile:
    outFile.write(flooded_buildings.to_json())
print("Now open http://townsendjennings.com/geo/?src=http://yetilabs.science/flooded_buildings.geojson")


Now open http://townsendjennings.com/geo/?src=http://yetilabs.science/flooded_buildings.geojson

In [ ]: