Describe the bug
Some tools build an output grid at a different resolution than their input but don't write the correct res into the output attrs. get_dataarray_resolution() reads attrs['res'] in preference to deriving cell size from the coordinates, so a stale or missing res feeds the wrong cell size to downstream distance- and area-based ops like slope, aspect, and proximity.
Affected tools:
rasterize(..., like=template) when the caller overrides the grid (explicit width/height/bounds/resolution) so the output no longer matches the template. The reshape path drops the template's stale res (correct) but never writes the new res it computes from the output grid, so the result carries no res at all.
kde(..., template=None) and line_density(..., template=None) build a fresh grid with a known cell spacing dx/dy, then return a DataArray with no res attr.
resample() already does the right thing and is the model to follow: it recomputes res (and transform) from the rebuilt coordinates on every path, including downsample, upsample, 3D per-band, and target_resolution.
Expected behavior
Each of these outputs should carry attrs['res'] = (abs(dx), abs(dy)) matching its actual output cell size, so downstream tools read the true resolution.
Additional context
preview() has the same class of issue but is being fixed in a separate PR, so it's out of scope here.
Describe the bug
Some tools build an output grid at a different resolution than their input but don't write the correct
resinto the outputattrs.get_dataarray_resolution()readsattrs['res']in preference to deriving cell size from the coordinates, so a stale or missingresfeeds the wrong cell size to downstream distance- and area-based ops like slope, aspect, and proximity.Affected tools:
rasterize(..., like=template)when the caller overrides the grid (explicitwidth/height/bounds/resolution) so the output no longer matches the template. The reshape path drops the template's staleres(correct) but never writes the newresit computes from the output grid, so the result carries noresat all.kde(..., template=None)andline_density(..., template=None)build a fresh grid with a known cell spacingdx/dy, then return a DataArray with noresattr.resample()already does the right thing and is the model to follow: it recomputesres(andtransform) from the rebuilt coordinates on every path, including downsample, upsample, 3D per-band, andtarget_resolution.Expected behavior
Each of these outputs should carry
attrs['res'] = (abs(dx), abs(dy))matching its actual output cell size, so downstream tools read the true resolution.Additional context
preview()has the same class of issue but is being fixed in a separate PR, so it's out of scope here.