def test_resampling_spatial(shapefile, rows, cols, samples):
tiles = rows * cols
samples = (samples // tiles) * tiles
lonlats, filename = shapefile
random_filename = tempfile.mktemp() + ".shp"
resampling.resample_spatially(filename,
random_filename,
target_field='lat',
rows=rows,
cols=cols,
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
评论列表
文章目录