Changed output.dtype to out.dtype, added test

This commit is contained in:
Brendan Ward 2014-11-03 16:38:54 -08:00
parent 58f0409c1d
commit d3fe8df537
2 changed files with 6 additions and 2 deletions

View File

@ -297,10 +297,10 @@ def rasterize(
stacklevel=2)
out = out if out is not None else output
if out is not None:
if np.dtype(output.dtype).name not in valid_dtypes:
if np.dtype(out.dtype).name not in valid_dtypes:
raise ValueError('Output image dtype must be one of: %s'
% (', '.join(valid_dtypes)))
if not can_cast_dtype(shape_values, output.dtype):
if not can_cast_dtype(shape_values, out.dtype):
raise ValueError('shape values cannot be cast to dtype of output '
'image')

View File

@ -29,6 +29,10 @@ def test_rasterize_geometries():
truth[2:4, 2:4] = 1
assert numpy.array_equal(result, truth)
out = numpy.zeros((rows, cols))
result = rasterize([geometry], out=out, default_value=1)
assert numpy.array_equal(out, truth)
# we expect all touched pixels
result = rasterize(
[geometry], out_shape=(rows, cols), all_touched=True