BUG: fixed fiona filter results where bbox is not None (#372)

* fixed fiona filter resulsts where bbox is not None

* adds test to ensure bbox used in read_file returns a filtered subset of features
This commit is contained in:
nickwg03
2016-10-28 18:42:51 +02:00
committed by Joris Van den Bossche
parent cc59a58181
commit cf6c1f25a2
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ def read_file(filename, **kwargs):
f_filt = f.filter(bbox=bbox)
else:
f_filt = f
gdf = GeoDataFrame.from_features(f, crs=crs)
gdf = GeoDataFrame.from_features(f_filt, crs=crs)
return gdf
+12
View File
@@ -54,3 +54,15 @@ class TestIO(unittest.TestCase):
df = self.df.rename(columns=lambda x: x.lower())
validate_boro_df(self, df)
self.assert_(df.crs == self.crs)
def test_filtered_read_file(self):
full_df_shape = self.df.shape
nybb_filename, nybb_zip_path = download_nybb()
vfs = 'zip://' + nybb_filename
bbox = (1031051.7879884212, 224272.49231459625, 1047224.3104931959, 244317.30894023244)
filtered_df = read_file(nybb_zip_path, vfs=vfs, bbox=bbox)
filtered_df_shape = filtered_df.shape
assert(full_df_shape != filtered_df_shape)
assert(filtered_df_shape == (2, 5))