Bin the valid pixel values of a single-band raster into classes and tabulate pixel count and ground area per class. Bins are right-closed (lower, upper], matching R's cut(). Ground area is derived from the pixel size in the geotransform (count x |px_w x px_h|), so results are correct in any projected CRS. Nodata, NaN, and values outside [min_valid, max_valid] are excluded. Implemented directly against the GDAL/NumPy Python bindings rather than wrapping a single gdal_* command-line utility.
Single-band raster to tabulate (e.g. a county canopy height model).
breaks
string
Comma-separated ascending bin edges, e.g. "0,5,10,15,20,25,30,35". N edges define N-1 right-closed bins; a value equal to the lowest edge or above the highest edge falls outside all bins and is excluded.
labels
string
Optional comma-separated labels, one per bin (i.e. one fewer than breaks). Empty (default) labels each bin by its upper edge, matching height classes like 5, 10, ..., 35.
min_valid
number
Values strictly below this are treated as nodata. Leave unset to skip.
max_valid
number
Values strictly above this are treated as nodata. Leave unset to skip.
area_scale
number
Multiplier applied to the per-pixel ground area, e.g. 1e-6 to convert square metres to square kilometres. Default 1 (area in CRS units squared).