mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-11 12:10:59 +08:00
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:
committed by
Joris Van den Bossche
parent
cc59a58181
commit
cf6c1f25a2
@@ -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
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user