Skip to content

rasterize: invalid resolution and chunks values are accepted (chunks=0 hangs) #2066

@brendancol

Description

@brendancol

Describe the bug

rasterize() accepts invalid values for resolution and chunks instead of rejecting them.

resolution:

  • resolution=-1 produces a 1x1 raster
  • resolution=inf produces a 1x1 raster
  • resolution=0 raises ZeroDivisionError
  • resolution=nan raises an opaque integer conversion error

chunks:

  • chunks=0 hangs the process. _normalize_chunks() loops while remaining > 0 and subtracts min(rchunk, remaining) from remaining. With rchunk=0 the subtraction is zero and the loop never terminates.
  • Negative chunks makes remaining grow without bound.

Expected behavior

Validate resolution is finite and > 0 before any dimension math, with a clear ValueError. Validate chunks > 0 at the top of _normalize_chunks().

Files: xrspatial/rasterize.py:2230, xrspatial/rasterize.py:1520

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    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