Skip to main content

pylerc is the LERC Python package

LERC is an open-source raster format which supports rapid encoding and decoding for any pixel type, with user-set maximum compression error per pixel.

What's new in Lerc 4.2?

Lerc 4.2 adds stricter size limits for improved safety:

  • Input data to encode is limited to 2 GB per band.
  • Compressed Lerc blob size is limited to 2 GB per band.
  • Total compressed Lerc blob size is limited to 4 GB across all bands.

What's new in Lerc 4.0?

Option 1, uses numpy masked array

An encoded image tile (2D, 3D, or 4D), of data type byte to double, can have any value set to invalid. There are new and hopefully easy to use numpy functions to decode from or encode to Lerc. They make use of the numpy masked array.

(result, npmaArr, nDepth, npmaNoData) = decode_ma(lercBlob)

  • lercBlob is the compressed Lerc blob as a string buffer or byte array as read in from disk or passed in memory.
  • result is 0 for success or an error code for failure.
  • npmaArr is the masked numpy array with the data and mask of the same shape.
  • nDepth == nValuesPerPixel. E.g., 3 for RGB, or 2 for complex numbers.
  • npmaNoData is a 1D masked array of size nBands. It can hold one noData value per band. The caller can usually ignore it as npmaArr has all mask info. It may be useful if the data needs to be Lerc encoded again.

(result, nBytesWritten, lercBlob) = encode_ma(npmaArr, nDepth, maxZErr, nBytesHint, npmaNoData = None)

  • npmaArr is the image tile (2D, 3D, or 4D) to be encoded, as a numpy masked array.

  • nDepth == nValuesPerPixel. E.g., 3 for RGB, or 2 for complex numbers.

  • maxZErr is the max encoding error allowed per value. 0 means lossless.

  • nBytesHint can be

    • 0 - compute num bytes needed for output buffer, but do not encode it (faster than encode)
    • 1 - do both, compute exact buffer size needed and encode (slower than encode alone)
    • N - create buffer of size N and encode, if buffer too small encode will fail.
  • npmaNoData is a 1D masked array of size nBands. It can hold one noData value per band. It can be used as an alternative to masks. It must be used for the so called mixed case of valid and invalid values at the same pixel, only possible for nDepth > 1. In most cases None can be passed. Note Lerc does not take NaN as a noData value here. It is enough to set the data values to NaN and not specify a noData value.

Option 2, uses regular numpy arrays for data and mask

As an alternative to the numpy masked array above, there is also the option to have data and masked as separate numpy arrays.

(result, npArr, npValidMask, npmaNoData) = decode_4D(lercBlob)

Here, npArr can be of the same shapes as npmaArr above, but it is a regular numpy array, not a masked array. The mask is passed separately as a regular numpy array of type bool. Note that in contrast to the masked array above, True means now valid and False means invalid. The npValidMask can have the following shapes:

  • None, all pixels are valid or are marked invalid using noData value or NaN.
  • 2D or (nRows, nCols), same mask for all bands.
  • 3D or (nBands, nRows, nCols), one mask per band.

The _4D() functions may work well if all pixels are valid, or nDepth == 1, and the shape of the mask here matches the shape of the data anyway. In such cases the use of a numpy masked array might not be needed or considered an overkill.

Similar for encode:

(result, nBytesWritten, lercBlob) = encode_4D(npArr, nDepth, npValidMask, maxZErr, nBytesHint, npmaNoData = None)

General remarks

Note that for all encode functions, you can set values to invalid using a mask, or using a noData value, or using NaN (for data types float or double). Or any combination which is then merged using AND for valid (same as OR for invalid) by the Lerc API.

The decode functions, however, return this info as a mask, wherever possible. Only for nDepth > 1 and the mixed case of valid and invalid values at the same pixel, a noData value is used internally. NaN is never returned by decode.

The existing Lerc 3.0 encode and decode functions can still be used. Only for nDepth > 1 the mixed case cannot be encoded. If the decoder should encounter a Lerc blob with such a mixed case, it will fail with the error code LercNS::ErrCode::HasNoData == 5.

Metadata

Release files for pylerc 4.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pylerc 4.3.0
File Interpreter ABI Platform Actions
pylerc-4.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pylerc-4.3.0-py3-none-win_amd64.whl
pylerc-4.3.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for pylerc-4.3.0-py3-none-manylinux_2_28_x86_64.whl
pylerc-4.3.0-py3-none-macosx_11_0_universal2.whl Python 3 none macOS 11.0+ universal2 (ARM64, x86-64) Details for pylerc-4.3.0-py3-none-macosx_11_0_universal2.whl

Total release size: 919.8 kB

Release files / pylerc-4.3.0-py3-none-win_amd64.whl

Download URL pylerc-4.3.0-py3-none-win_amd64.whl
Size 181.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
705fa3bd108d8dc6d8d1e3aa88eb654937620499b0e60104d2798b49213a8eb4
BLAKE2b-256 checksum
How to use checksums
00db37673ee41d9d3cca5a791f274308e4e093619184836baae5e53654a7eed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pylerc-4.3.0-py3-none-manylinux_2_28_x86_64.whl

Download URL pylerc-4.3.0-py3-none-manylinux_2_28_x86_64.whl
Size 267.4 kB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
860f0c162f52c0da2b8da83f3dc6ca88308db4a0eb2085073b486d58721eb73e
BLAKE2b-256 checksum
How to use checksums
957bc12c8237159ff17ad5d9d14ef36ea93e10c1cdfef1af38796ef1ab2af16d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / pylerc-4.3.0-py3-none-macosx_11_0_universal2.whl

Download URL pylerc-4.3.0-py3-none-macosx_11_0_universal2.whl
Size 471.3 kB
Tags Python 3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
9f297c60739418a65acd37967cee0540a43bd46e3150c0af6be8ef93feecf0f5
BLAKE2b-256 checksum
How to use checksums
183ae8e91da16ce01fd9987e6e902d259846908d6f3769c02345aa98d61daaec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for pylerc 4.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page