Skip to content

Refactor GeoTIFF Phase 5f: extract _encode.py from _writer.py (PR-L of #2211) #2260

@brendancol

Description

@brendancol

Summary

Follow-up under epic #2211. Phase 5f deliverable: extract the write-side encode helpers (strip/tile encode + photometric + predictor + compression block) out of _writer.py into a new _encode.py. Mirrors the _decode.py extraction (PR-G) on the read side.

Scope

Mechanical extraction. Behavior-neutral.

Hold for dispatch until PR-K (_overview.py) merges — both PRs touch _writer.py and serial landing avoids a heavy rebase.

Files

  • Create: xrspatial/geotiff/_encode.py.
  • Modify: xrspatial/geotiff/_writer.py — remove the helpers being moved; import them from _encode.
  • Modify: any module that imports those helpers (likely _writers/eager.py, _writers/gpu.py, _writers/vrt.py).

What to move

Encode helpers in _writer.py (verify each name in the current file post-PR-K):

  • _invert_nodata_for_miniswhite
  • _apply_photometric_miniswhite_invert
  • _resolve_photometric
  • _reject_disagreeing_photometric_override
  • normalize_predictor
  • _apply_predictor_encode
  • _compression_tag
  • _prepare_strip
  • _write_stripped
  • _prepare_tile
  • _write_tiled
  • _compress_block

Leave in _writer.py: _write, _write_streaming, _validate_lowlevel_write_kwargs, fsspec write helpers.

Acceptance

  • _writer.py line count drops by ~500 lines. Combined with PR-I and PR-K, target ending around ~1300 lines.
  • All encode-related tests pass unchanged: photometric, predictor, strip/tile encode, miniswhite invert, compression tag, plus the broader geotiff write suite.
  • Public import paths preserved.
  • No public API change.

Non-goals

  • Splitting _write / _write_streaming further.
  • Performance work.

Closes part of #2211.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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