Skip to main content

Readers & Writers

GeoBrix provides Spark DataSource V2 readers and writers for geospatial file formats. They are pure Python and need no JAR, so one set serves every compute. They scale by partitioning work across the cluster rather than reading or writing on a single node.

Which formats can this runtime read and write?

Call gbx_drivers() in SQL, or drivers() in Python, to list the drivers of the current environment. Each row says whether the driver reads, writes and is allowed by GeoBrix. It also says if the driver works as shipped, and what it still needs. Pass 'raster' or 'vector' to keep one kind. The tested column marks the drivers that GeoBrix's driver tests cover, and guidance points to a built-in reader where one exists. The result reflects the environment as it runs now, so adding or removing packages changes it. See the drivers in the env wheel for the shipped list.

SELECT driver, description, requires FROM gbx_drivers() WHERE write AND allowed

Readers​

Load geospatial files into a distributed DataFrame. The raster readers (raster_gbx, gtiff_gbx, cog_gbx) return virtual tiles by default — bytes-free (path, window) references; pass .option("virtualTiles", "false") to get materialized bytes instead. See the Readers Overview for the full list, output schemas, and options.

Parenthetical (x.y.z) is the GeoBrix release each reader/writer first shipped (its "since" version).

FormatReader
Raster (generic)raster_gbx (0.4.0)
GeoTIFFgtiff_gbx (0.4.0)
COGcog_gbx (0.5.0)
NetCDFnetcdf_gbx (0.4.1)
Zarrzarr_gbx (0.6.0)
PMTilespmtiles_gbx (0.4.0)
File listerfile_gbx (0.5.0)
LiDAR (LAS/LAZ)lidar_gbx (0.5.2)
EXIF/GPS (images)exif_gbx (0.5.2)
Vector (generic)vector_gbx (0.4.0)
Shapefileshapefile_gbx (0.4.0)
GeoJSONgeojson_gbx (0.4.0)
GeoJSONLgeojsonl_gbx (0.4.0)
GeoPackagegpkg_gbx (0.4.0)
File Geodatabasefile_gdb_gbx (0.4.0)

Writers​

Write DataFrames back out to geospatial files. See the Writers Overview for the column contract, single-file vs sharded trade-offs, and per-format details.

FormatWriter
Raster (generic)raster_gbx (0.4.0)
GeoTIFFgtiff_gbx (0.4.0)
COGcog_gbx (0.5.0)
Zarrgbx_zarr_write (0.6.0)
PMTilespmtiles_gbx (0.4.0)
NetCDFnetcdf_gbx (0.4.1)
LiDAR (LAS/LAZ)lidar_gbx (0.5.2)
Vector (generic)vector_gbx (0.4.0)
Shapefileshapefile_gbx (0.4.0)
GeoJSONgeojson_gbx (0.4.0)
GeoJSONLgeojsonl_gbx (0.4.0)
GeoPackagegpkg_gbx (0.4.0)
File Geodatabasefile_gdb_gbx (0.4.0)

Registering the readers and writers​

The Python DataSources are not auto-registered. Call register(spark) once per session before using any *_gbx format. The same call registers the gbx_* functions:

from databricks.labs.gbx import register
register(spark)

Shared file-access base​

All *_gbx readers and writers share a common file-access base — the file_gbx module — that centralises FILE and FUSE routing, directory enumeration, and write-mode selection.

Capability tiers​

file_gbx probes the runtime once per session and picks the best available tier:

TierAvailable onCapabilities
read_filesDBR 13.3 LTS +read_files(format=>'file') — native FILE refs, file metadata, recursive listing
list_filesDBR 18 LTS +list_files(…) — metadata + FILE refs, directory listing only
fuseAll runtimes (OSS / DBR < 13)os.walk + FUSE mount — always available; no FILE column

Read-options matrix​

SourceRead mechanismRuntimePer-tile costDefault / when
FILE-column table (recommended on Serverless)Delta scan of path (EXTERNAL)anyNone. The scan resolves the reference.default for a table source (vector_file_read(table), raster read_tiles_table)
FILE-column tableDelta scan of FILE .uri (MANAGED)DBR 13.3+None. The scan resolves the reference.auto when the table is MANAGED
Directoryread_files(format=>'file') — enumerate + FILE refs + sizeDBR 13.3+Listing only (metadata).auto dir default on 13.3+
Directorylist_files — enumerate (metadata only)DBR 18+Listing only (metadata).used when read_files is unavailable
DirectoryFUSE walk + per-tile open (raster_gbx DataSource)allOne file open per tile, on the worker.fallback tile read (no FILE tier)

The read_files and list_files rows list files. They do not open them. The DataSource row opens each tile on the worker, which costs a Volume round trip on Serverless. The FILE-column table path opens no tile in the scan. On Serverless, prefer reading from a FILE-column table (Delta scan). See Serverless & Memory for the connect-aware stream caps and a full guide to memory-safe pipelines. The cap is 64 MiB on Serverless and 256 MiB on classic compute, standard access mode included.

The no-gating rule: access="auto" on readers and file_mode="auto" on writers silently downgrade to the best available tier and never error. Explicitly requesting "managed" or "external" on a FUSE-only runtime raises a clear, actionable error describing the upgrade path. Readers default to access="auto"; writers default to file_mode="fuse", a plain Delta table that reads on every compute. Your pipelines run on any runtime without code changes; you only need to opt in to FILE (file_mode="auto") when you want the governance and lifecycle benefits.

Read resolver​

When a *_gbx reader opens a source file it calls open_for_read(source, access="auto"). The resolver checks the tier and picks a strategy:

  • FILE-capable runtime (DBR 13.3+): routes to the FILE API. Files at or under GBX_STREAM_MAX_BYTES (default 64 MiB on Serverless, 256 MiB on classic compute, standard access mode included) open a byte-range stream. The stream is one round-trip, no FUSE, no local copy, and the fastest path for typical tile sizes. Files over the cap fall through to as_local_file(), a lazy local-file reference backed by the FILE handle. It pages bytes from the Volume on demand and is a memory-safety mechanism, not a performance optimization. A blanket FUSE-direct path for small files is slower, not faster; the streaming path is preferred whenever the file fits in the cap. Open dataset handles are held in a per-partition LRU cache keyed by source path, amortising the open cost across all windows of the same source.
  • FUSE fallback (OSS / DBR < 13): resolves to the bare /Volumes/… path and uses a probe-then-stage strategy. It tries random-access directly and falls back to a sequential copy only if the probe fails.

Write committer​

Writers call open_for_write(spark, df, target, file_mode="fuse", filespace=…, layout=…). The default, file_mode="fuse", is a plain Delta write. file_mode="auto" opts in to FILE and resolves as follows:

ConditionEffective modeMechanism
FILE available + filespace given"managed"create_file — MANAGED FILE column
FILE available, no filespace"external"try_to_file — EXTERNAL FILE column
No FILE (fuse tier)"fuse"Plain Delta write, path STRING / raster BINARY

Explicit modes ("managed", "external") override auto-selection. Requesting "managed" or "external" on a fuse-only runtime raises a clear error.

Layout options​

The layout parameter controls row ordering in the output Delta table:

ValueBehaviour
"order"ORDER BY path at write time (default — scan-friendly)
"cluster"CLUSTER BY path in the DDL (FILE-mode tables only); run OPTIMIZE <table> afterward for durable clustering
"plain"No ordering — fastest write, scan order determined by the cluster

partitionBy is not supported; use layout="order" unless you have a specific clustering need.

File enumeration​

enumerate_files(path, *, recursive=True, include_hidden=False, extensions=None, path_glob_filter=None) lists files in a directory and returns a Spark DataFrame (FILE-capable tiers) or a Python list (FUSE tier). The result has columns path, size, and file (a FILE reference when available, None on FUSE).

By default, files whose names start with _ or . (Spark/Hadoop metadata files such as _SUCCESS, _committed_*, .crc) are skipped. Pass include_hidden=True to include them.

A positive selection filter — either extensions (a tuple of suffixes, e.g. (".tif", ".nc")) or path_glob_filter (an fnmatch-style glob, e.g. "*.tif") — narrows which files are returned. The two filters are mutually exclusive and are ANDed with include_hidden: for example, include_hidden=True + path_glob_filter="[!.]*" returns underscore-named files such as _data.tif but still excludes dot-named files such as .crc.

The FILE flow​

file_gbx access flow — the READ lane resolves a source (path, directory, or FILE ref) through open_for_read. A once-per-session capability-tier probe (read_files on DBR 13.3+, list_files on DBR 18+, FUSE floor) picks the access. Size-adaptive routing (FILE byte-range stream, FUSE-of-FILE for large or striped files, or a probe-then-stage copy) feeds the rasterio / pyogrio reader. There, a per-partition open-LRU amortizes the open cost across a source’s windows. The WRITE lane resolves writer output through open_for_write into FUSE (plain Delta, the default). With file_mode=&quot;auto&quot; or an explicit choice, it writes in MANAGED (create_file) or EXTERNAL (try_to_file) mode instead. The targets are a FILE-column Delta table or a Volume path. The default order is ORDER BY path, with opt-in CLUSTER BY plus OPTIMIZE. access=&quot;auto&quot; downgrades to FUSE gracefully. An explicit FILE mode on a FUSE-only runtime raises a clear error

See file_gbx Reader for enumeration and read-mode details, and file_gbx Writer for write-mode and ingest options.

Delta-indexed collections​

Two parts of GeoBrix keep a Delta table as the index of a collection of files and leave the bytes in the files:

  • a FILE-column table has one row per raster or vector file on a Volume, with a FILE reference (a path string where FILE is not available). The *_gbx writers make one through file_gbx and readers scan it (see Read-options matrix). A tile index (tilesTable) is the same idea with an optional pixel window on each row, read with read_tiles_table;
  • the manifest table of a Zarr store has one row per chunk or shard, per array and group document, and one commit row for each write. A row records the file, offset and length that hold it.

It is one pattern, and in both the collection is a table. SQL, Unity Catalog grants and Delta's own tools work on it. A reader plans from the table rather than from a directory listing, so it never walks the files to find them. The table has versions that you can read as they were: versionAsOf and timestampAsOf on read_tiles_table, version_as_of and timestamp_as_of on gbx_zarr_read.

What differs is who looks after the files. A Zarr store comes in two kinds: one you create, whose files GeoBrix writes, and one you register in place, whose files other tools own.

FILE-column table or tile indexZarr store you createZarr store you register
Made byThe *_gbx writers; you, for a tile indexgbx_zarr_write with mode="create"gbx_zarr_register
One row isA file, or a window of oneA chunk or shard at an offset in a pack file that GeoBrix wroteA chunk or shard at an offset in the store's own objects; for a writable registration, a pack file in its overlay is the same as in the previous column
FilesReferenced. An earlier version of the table lists the files it listed, but a file replaced since is replaced for every versionWritten only by GeoBrix, each into a new pack file that is never changed. An earlier version reads the bytes it did, while it is within retain or taggedThe store's objects belong to the tools that wrote them. GeoBrix copies nothing and writes nothing in the store (an explicit publish aside), records each object's identity, and a read stops with ZarrStoreDrift if another tool changed one
WritesA Delta transaction on the tableOne Delta transaction for each write, with a compare-and-swap on every key it replaces, so concurrent writers either land or get a clear conflict errorNone through GeoBrix for a read-only registration. A writable one writes new pack files to its overlay, in the same transactions
Cleaning upYoursgbx_zarr_vacuum deletes the files that no readable version needsgbx_zarr_vacuum deletes only the packs GeoBrix wrote to the overlay; it never touches the store's own objects

A FILE-column table suits files that other tools produce and own. A Zarr store suits a cube that jobs also write back to, and that needs all-or-nothing writes and versions. Choosing a Format shows where each format fits.

Next Steps​

  • Readers Overview — every reader, tier differences, output schemas, options.
  • Writers Overview — the column contract, single-file vs sharded writers, per-format details.
  • VRT & Mosaics — tile a large source into bounded mini-COGs + a portable VRT index; read back with raster_gbx or cog_gbx.
  • Serverless & Memory — connect-aware caps, materialize-vs-virtual, memory-safe write patterns, and caveats.
  • Benchmarking — tier-vs-tier timing and parity methodology.