lambda x: len(x) <= second_layer_screen or len(x) >= 10000) not_blds.reset_index(inplace=True) # Recluster buildings in only x-y to negate the effects of funny-shaped rooves. db = DBSCAN(eps=eps, min_samples=min_samples).fit(blds[['x', 'y']].as_matrix()) blds = pd.DataFrame([blds.id, db.labels_]).T blds.columns = ['id', 'label'] blds['id'] = blds['id'].astype(int) # Is as building: id, label # Not a building: id return blds, not_blds['id'] if __name__ == '__main__': import os from pgMethods import Methods m = Methods(projection=32610) df = m.pg_df('SELECT x, y, z, id FROM lidar_nyc_small') print 'df loaded' #df = pd.read_csv('../tests/data/CrossValidationData.csv') blds, not_blds = dbscan(df) m.df_pg(blds, 'temp12345678') m.pg_post( 'DROP TABLE IF EXISTS checkcheck; CREATE TABLE checkcheck AS SELECT a.* FROM z_20130805_usgsnyc14_18TWL835075 a RIGHT JOIN temp12345678 b ON a.id=b.id;' ) m.pg_post('DROP TABLE temp12345678;')
# Recluster buildings in only x-y to negate the effects of funny-shaped rooves. db = DBSCAN(eps=eps, min_samples=min_samples).fit(blds[['x', 'y']].as_matrix()) blds = pd.DataFrame([blds.id, db.labels_]).T blds.columns = ['id', 'label']; blds['id'] = blds['id'].astype(int) # Is as building: id, label # Not a building: id return blds, not_blds['id'] if __name__ == '__main__': import os from pgMethods import Methods m = Methods(projection=32610); df = m.pg_df('SELECT x, y, z, id FROM lidar_nyc_small') print 'df loaded' #df = pd.read_csv('../tests/data/CrossValidationData.csv') blds, not_blds = dbscan(df) m.df_pg(blds, 'temp12345678'); m.pg_post('DROP TABLE IF EXISTS checkcheck; CREATE TABLE checkcheck AS SELECT a.* FROM z_20130805_usgsnyc14_18TWL835075 a RIGHT JOIN temp12345678 b ON a.id=b.id;') m.pg_post('DROP TABLE temp12345678;')