Repository navigation
Open
Description
Epic: rasterize() correctness and clean-up
Note
This list was compiled by Claude Opus 5.5 while reviewing #1167. Items marked new are not filed elsewhere yet.
rasterize() does several jobs behind one signature:
- vector → label mask (shapes/points with
return_regions_as_labels=True) - vector → value image (count/sum/first of
value_key,count_cat→ channels) - raster → raster resampling (images, labels)
- labels → image of table values (
value_keyon labels)
Many open issues come from these jobs sharing code paths and parameters. This epic collects them. The API stays as is unless noted.
Vector → label mask
- exceeding rasterize's maximum label index #987 Labels limited to uint16 (65,535 regions). Fixed by feat: support raster labels up to 2^53-1 (old limit: 2^16-1) #1167 (
_get_uint_dtype, in review for the next bugfix release). - feat: support raster labels up to 2^53-1 (old limit: 2^16-1) #1167 Labels of 2**53 or higher (also from summing overlapping labels) now raise instead of being silently rounded. xfail tests document the root cause.
- new: Labels are computed via a float64 aggregation (datashader
first/sumalways return float64). Make them exact withds.where(ds.first(...))(int64 row index, then look up the ID). Then remove the 2**53 guard and the xfail markers from feat: support raster labels up to 2^53-1 (old limit: 2^16-1) #1167. - new: With a numeric
value_keyandreturn_regions_as_labels=True, the default aggregation issum, so overlapping regions get the sum of their labels, an ID that doesn't exist. Default tofirstfor labels and rejectsum/count/count_cat. - rasterize messes up label to shape mapping when rastering only a subset of shapes #966 The label → shape mapping (
label_index_to_category) is wrong whenmin/max_coordinatedoesn't include all shapes. - new, proposal:
label_key(column or"index") to use existing integer IDs as label values instead of positional 1..N, so the result matches the table'sinstance_keywithout remapping. - feat: add opt-in rasterization tiles #1166 Opt-in output tiles to bound memory for large canvases. Feature, needs its own design review; its "Closes exceeding rasterize's maximum label index #987" is wrong.
Vector → value image
- Collection of minor issues found by an automated bug hunt (validation edge cases, misleading errors, small inefficiencies) #1244 (comment) An explicit
agg_func="sum"etc. fails withspecified column not foundwhenvalue_keycomes from a table:ds.<agg>(column=value_key)should useVALUES_COLUMN. - new: Dead
assert agg_func == "count" or value_key is not None(value_keyis neverNoneat that point; the message "cannot be done" should read "cannot be None"). Replace asserts on user input with up-frontValueErrors. - Cases not currently covered by the aggergation #216 / Aggregate points by labels #209 Aggregation cases not yet covered (points/shapes/labels by labels, multiscale). Related
aggregate()work.
Raster → raster (resampling)
- Interpolation when resampling images #166 Interpolation when resampling images: images also use nearest neighbour (
order=0), which aliases when downsampling. - Expose interpolation
kwargsfordask_image.ndinterp.affine_transform()#725 Expose the interpolation kwargs ofdask_image.ndinterp.affine_transform()inrasterize()andtransform(). - Offset when rasterizing data #165 Half-pixel offset when rasterizing or resampling (pixel corner vs centre).
- rasterize() mis-positions the output by 0.5·(1 − s) units (up to half an output pixel) whenever the output pixel size s ≠ 1 #1220 Output shifted by 0.5·(1 − s) units whenever the pixel size s ≠ 1. Likely the same root cause as Offset when rasterizing data #165.
- new:
rasterize(labels)returns an image of label IDs by default (return_regions_as_labels=False). Deprecate that default. Seerasterizeconverts labels to images #783 / Fixtransform_to_data_extentconverting labels to images #791 for an earlier occurrence. - Done: transform() of multiscale labels uses linear interpolation and invents label ids #1202 / fix: resample multiscale labels with nearest neighbour in transform() #1267
transform()of multiscale labels interpolated and created non-existent IDs; now nearest neighbour.
Labels → image of table values
- rasterize(labels, value_key=...) crashes for categorical table columns and for labels absent from the table #1236
rasterize(labels, value_key=...)crashes for categorical table columns and for labels absent from the table. - new: Averaging table values onto a coarser grid isn't possible: labels are resampled (nearest) before the lookup, so each output pixel gets one region's value. A correct mean needs lookup at native resolution, then aggregation (lazily, chunk by chunk).
Dtypes, tests, related
- convert integers indexes to
int32#187 Integer dtypes for interoperability (JS/R have no int64/uint64): use the smallest dtype that fits. - rasterize_bins(value_key=None) declares dtype=uint32 while blocks hold X.dtype; writing the result silently zeroes non-integer values #1209
rasterize_bins(value_key=None)declares uint32 while blocks holdX.dtype; writing silently zeroes non-integer values. - Increase test coverage of rasterization #177 Increase rasterization test coverage. Still untested:
count_caterror paths,agg_funcpassed as a reduction object, shapes with more than 65,535 labels.
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat: support raster labels up to 2^53-1 (old limit: 2^16-1) (#1167)