GeoZL

API

  • One C core with bindings for Python, R, Julia and JavaScript, all writing the same frames.

Four calls cover most use. profile measures candidate recipes on a tile, graph builds one, compress runs tiles through it and decompress reads a frame back. The notebook runs them on a DEM tile.

The four calls

import numpy as np
import geozl

y, x = np.mgrid[0:256, 0:256]
tile = (1000 + 3 * x + 2 * y).astype(np.int16)

rows = geozl.profile(tile)                  # candidates, best ratio first
g = geozl.graph(tile, rows[0]["graph"])     # build the chosen recipe once
frame = geozl.compress(tile, graph=g)       # bytes
back = geozl.decompress(frame).view(tile.dtype).reshape(tile.shape)
assert np.array_equal(back, tile)
library(geozl)

tile <- outer(0:255, 0:255, function(x, y) 1000 + 3 * x + 2 * y)

rows <- geozl_profile(tile, dtype = "int16")              # best ratio first
g <- geozl_graph(tile, rows$graph[[1]], dtype = "int16")  # build it once
frame <- geozl_compress(tile, g)                          # a raw vector
back <- geozl_decompress(frame, "int16", dim = dim(tile))
stopifnot(all(back == tile))
using GeoZL

tile = [Int16(1000 + 3x + 2y) for x in 0:255, y in 0:255]

rows = GeoZL.profile(tile)                  # candidates, best ratio first
g = GeoZL.graph(tile, rows[1].graph)        # build the chosen recipe once
frame = GeoZL.compress(tile, g)             # a Vector{UInt8}
back = GeoZL.decompress(Int16, frame, size(tile))
@assert back == tile

A frame stores no dtype or shape. The same tile gives the same frame in all three languages. Keep the dtype and shape beside it, as Rumi does.

Frames can also decode straight into device memory on a GPU. That call is in C, and GPU decoding walks through it. The language bindings decode on the CPU only.

Languages

PythonThe full API, with the OpenZL nodes in geozl.lossless and geozl.lossy. pip install geozl
CThe library every binding calls, with graphs, nodes, coefficients and GPU decode. Built from the repository with make lib.
RThe four calls and geozl_coeffs, on double, integer and raw vectors. From the asterisk-labs r-universe.
JuliaThe four calls and coeffs, on native Julia arrays. Pkg.add("GeoZL") from the Asterisk registry.
JavaScriptOne-shot compress and decompress on raw bytes, in WebAssembly. npm install @asterisk-labs/geozl