Skip to content

rasterize: add type annotations to geometries, columns, merge params #2250

@brendancol

Description

@brendancol

Summary

xrspatial.rasterize.rasterize annotates 13 of 16 parameters plus the return type. Three are missing: geometries, columns, merge. The docstring already states the intended types, so the signature trails the docs:

  • geometries: "GeoDataFrame or iterable of (geometry, value)"
  • columns: "list of str, optional"
  • merge: "str or callable, default 'last'"

Proposed fix

Add annotations matching the docstring. polygonize already annotates every public parameter, so this brings rasterize in line.

Union[str, Callable] is enough for merge. Spelling out Callable[[float, np.ndarray, int], float] is more precise but not needed on the public surface.

No behaviour change. No deprecation needed.

Sweep context

Found by /sweep-api-consistency on 2026-05-21. Cat 3 (type hints / docstring), MEDIUM.

The same sweep noted cross-module drifts that are out of scope here (per template rules they get documented, not filed per module):

  • clip_polygon(nodata=...) vs rasterize(fill=...) for the same concept.
  • clip_polygon(name: Optional[str] = None) vs rasterize(name: str = 'rasterize') for default-resolution convention.
  • polygonize(column_name=...) vs rasterize(column=...) for the column selector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions