pylerc
raw JSON → 4.1.0 verified Fri May 01 auth: no python
Limited Error Raster Compression (LERC) library with Python bindings. Version 4.1 supports compression/decompression of rasters with a user-specified max error. Release cadence: approximately yearly, aligned with ArcGIS releases.
pip install pylerc Common errors
error ModuleNotFoundError: No module named 'lerc' ↓
cause Package renamed to pylerc in v4.1. Importing 'lerc' refers to an older package or nothing.
fix
pip install pylerc, then import pylerc
error TypeError: Lerc.encode() got multiple values for argument 'data' ↓
cause Using old positional argument order (maxzerror, data) with pylerc >=4.0.
fix
Call encode with keyword: Lerc().encode(data, maxzerror=0.1)
error ValueError: Invalid LERC binary blob ↓
cause Trying to decode data that is not LERC-encoded or is corrupted.
fix
Ensure input is the bytes object returned by encode() from the same or compatible version.
Warnings
breaking Package renamed from 'lerc' to 'pylerc' starting v4.1.0. 'pip install lerc' will install an older (pre-4.0) version. Uninstall old lerc package before installing pylerc. ↓
fix pip uninstall lerc && pip install pylerc
breaking The Lerc class API changed in v4.0.0: encode() now takes data as the first positional argument (previously took maxzerror first). Old code using Lerc().encode(maxzerror, data) will silently produce incorrect results or raise TypeError. ↓
fix Change to Lerc().encode(data, maxzerror=0.1)
gotcha The Lerc class instance is stateful; do not use the same instance for concurrent encoding/decoding without locking. Reuse is safe sequentially. ↓
fix Create separate Lerc instances per thread or synchronize access.
deprecated Conda package is no longer updated for pylerc; only pip install is supported. ↓
fix Use pip install pylerc
Imports
- Lerc wrong
import Lerccorrectfrom pylerc import Lerc
Quickstart
import numpy as np
from pylerc import Lerc
# Create a sample 2D float array (height, width)
data = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)
# Encode with max error 0.1
encoder = Lerc()
encoded = encoder.encode(data, maxzerror=0.1)
print(f"Encoded size: {len(encoded)} bytes")
# Decode back
decoded = encoder.decode(encoded)
print("Decoded array:", decoded)