def features_keep_using_features(obj, bounds):
<EOL>bounds_shapes = [<EOL>(feature, shapely.geometry.shape(feature['<STR_LIT>'])) <EOL>for feature in tqdm(bounds['<STR_LIT>'])<EOL>if feature['<STR_LIT>'] is not None<EOL>]<EOL>index = rtree.index.Index()<EOL>for i in tqdm(range(len(bounds_shapes))):<EOL><INDENT>(feature, shape) = bounds_shapes[i]<EOL>index.insert(i, shape.bounds)<EOL><DEDENT>features_keep = []<EOL>for feature in tqdm(obj['<STR_LIT>']):<EOL><INDENT>if '<STR_LIT>' in feature and '<STR_LIT>' in feature['<STR_LIT>']:<EOL><INDENT>coordinates = feature['<STR_LIT>']['<STR_LIT>']<EOL>if any([<EOL>shape.contains(shapely.geometry.Point(lon, lat))<EOL>for (lon, lat) in coordinates<EOL>for (feature, shape) in [bounds_shapes[i]<EOL>for i in index.nearest((lon,lat,lon,lat), <NUM_LIT:1>)]<EOL>]):<EOL><INDENT>features_keep.append(feature)<EOL>continue<EOL><DEDENT><DEDENT><DEDENT>obj['<STR_LIT>'] = features_keep<EOL>return obj<EOL>
Filter all features in a collection by retaining only those that
fall within the features in the second collection.