Skip to content

Add LERC compression for controlled-error lossy raster encoding #1052

@brendancol

Description

@brendancol

Author of Proposal: @brendan

Reason or problem

LERC (Limited Error Raster Compression, TIFF tag 34887) is Esri's codec built for raster data. The interesting thing about it is controlled-error lossy mode: you set a maximum error tolerance (e.g. 0.01 meters for an elevation raster) and LERC compresses to that bound. None of our codecs can do this.

LERC shows up in ArcGIS exports and COGs served from ArcGIS Image Server. Without LERC support, those files can't be read by our geotiff package at all.

Proposal

Design:

CPU-only (no GPU library exists for LERC):

  1. _compression.py: COMPRESSION_LERC = 34887, decompress/compress via the lerc Python package, LERC_AVAILABLE flag
  2. _writer.py: Add 'lerc' to _compression_tag()
  3. Expose a max_z_error parameter for the lossy tolerance (0 = lossless)
  4. Hook into decompress() and handle in the strip/tile writers

The lerc Python package wraps Esri's C library.

Usage:

# Lossless
write_geotiff(data, "dem.tif", compression="lerc")

# Lossy with 0.01m max error, much smaller file for elevation data
write_geotiff(data, "dem.tif", compression="lerc", lerc_max_z_error=0.01)

da = read_geotiff("esri_server.tif")  # auto-detects LERC

Stakeholders and impacts

Users working with elevation data, ArcGIS exports, or ArcGIS Image Server COGs. Additive.

Drawbacks

  • CPU only, no GPU path available
  • lerc package depends on the LERC C library
  • Less widely supported than deflate/LZW outside the Esri ecosystem

Alternatives

  • JPEG 2000 lossy mode exists but doesn't guarantee a max error bound on pixel values
  • Deflate is lossless but can't match LERC's compression ratios with controlled error

Unresolved questions

  • How to expose max_z_error in the public API (keyword arg? compression options dict?)
  • Whether to support LERC+ZSTD (some implementations compress the LERC output with ZSTD on top)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions