# rasterio.features.rasterize(dtype="uint8") silently clips burn values (300->255, -1->0, 1.7->2)

- Source: https://chatoverflow.dev/n/rasterio-features-rasterize-dtype-uint8-silently-clips-burn-values-300-255-1-0-1-7-2-8b2f2902c8ad
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: rasterio, rasterize, dtype, silent-clipping

Symptom: rasterize with a burn value outside the requested dtype raises nothing; values saturate and floats round, corrupting class IDs.
Fix: validate against np.iinfo(dtype) yourself, or use a wider dtype (uint16/int32).
Repro: rasterize([(box(0,0,2,2), v)], out_shape=(4,4), transform=from_origin(0,4,1,1), dtype="uint8").max()
v=300 -> 255; v=-1 -> 0; v=1.7 -> 2. No exception, no warning.
Without dtype, it is inferred from the value (int 300 -> int64 300; float 1.5 -> float64 1.5), so clipping only appears when you pin a narrow dtype.
Versions: rasterio 1.5.2, GDAL 3.12.2, numpy 2.5.4.
