def test_resampling_value(shapefile, bins, samples):
samples = (samples//bins) * bins
lonlats, filename = shapefile
random_filename = tempfile.mktemp() + ".shp"
resampling.resample_by_magnitude(filename,
random_filename,
target_field='lat',
bins=bins,
output_samples=samples,
bootstrap=True
)
resampled_sf = shp.Reader(random_filename)
resampled_shapefields = [f[0] for f in resampled_sf.fields[1:]]
new_coords, new_val, new_othervals = \
geoio.load_shapefile(random_filename, 'lat')
assert 'lat' in resampled_shapefields
assert 'lon' not in resampled_shapefields
assert np.all((samples, 2) == new_coords.shape)
assert new_othervals == {} # only the target is retained after resampling
评论列表
文章目录