Remove canvas_like and datashader references from source code

Open
#3,451 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
data

Research direction

Start in xrspatial/utils.py by locating canvas_like() and its datashader import, then inspect the docstring example in xrspatial/zonal.py and the comment at xrspatial/terrain.py:698. Remove the stale references and unused imports, then run pytest xrspatial/tests/; done means the tests pass and no test or module imports canvas_like.

Written by the indexing model from the issue text.

Description

area:utilities enhancement

Reason or Problem

xrspatial/utils.py defines canvas_like(), which wraps datashader.Canvas.raster() to resample a raster. It is the only place in the library source that imports datashader, it is not exported from __init__.py, and a repo-wide search finds no callers. A couple of docstrings and a comment also mention datashader.

Proposal

  • Delete canvas_like() from xrspatial/utils.py, including its lazy import datashader as ds and the try/except that raises ImportError. Remove any imports the deletion leaves unused.
  • Rewrite the suggest_zonal_canvas() docstring example in xrspatial/zonal.py to use arr.xrs.rasterize(...) instead of ds.Canvas().polygons(...). The function body has no datashader dependency, so this is a docstring-only change.
  • Reword the comment at xrspatial/terrain.py:698 so it describes the pixel-center coordinate convention without naming datashader.

Value

Removes the library's only datashader import and trims stale references, a prerequisite for dropping datashader from packaging.

Done when

  • pytest xrspatial/tests/ passes.
  • No test or module imports canvas_like.

Part of removing datashader as a dependency; final packaging removal is tracked in #3450.

Dominant language
Python
Stars
972
Forks
92
Avg merge
2d 12h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xarray-contrib/xarray-spatial

All issues in xarray-contrib/xarray-spatial

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.