GeoTIFF Writer
Since: gtiff_gbx v0.4.0
Write GeoTIFF tiles with the gtiff_gbx writer (the raster_gbx writer with the
GeoTIFF driver forced).
The *_gbx writers need no JAR and run on every compute, Serverless and standard
(shared) clusters included. See the Benchmarking page for timings and
methodology.
Schema
Input schema — exactly (source, tile):
root
|-- source: string
|-- tile: struct
| |-- cellid: bigint
| |-- raster: binary
| |-- metadata: map<string,string>
This is the exact schema the raster readers emit. The writer requires these two columns and nothing else — extra OR missing columns both raise an error (there is no implicit projection). The on-disk format comes from tile.metadata (the GDAL driver/extension recorded at read time); the ext option controls only the filename suffix.
Typically you write a reader's output unchanged. To control output filenames, use the nameCol option — it overwrites the source value in place; do not add a column (that breaks the exact-schema check):
# (source, tile) straight from a reader -> write as-is
df.write.format("gtiff_gbx").mode("append").save("/Volumes/cat/sch/vol/out")
# name outputs from an existing column (overwrite `source`, don't add a column):
df.withColumn("source", df["scene_id"]) \
.write.format("gtiff_gbx").mode("append").save("/Volumes/cat/sch/vol/out")
Output: one GeoTIFF (.tif) file per input row, written under the target directory.
gtiff_gbx is the raster_gbx catch-all writer with the GeoTIFF
driver forced — output is always GeoTIFF regardless of tile.metadata. Register
the DataSources first (see
Raster Writer).
# Read then write GeoTIFF tiles (lightweight)
from databricks.labs.gbx import register
register(spark)
df = spark.read.format("raster_gbx").load("{SAMPLE_RASTER_PATH}")
df.write.format("gtiff_gbx").mode("overwrite").save(OUT_DIR)
nameCol / ext, the compress / compressLevel / predictor options and the
performance characteristics are the same as the catch-all
raster_gbx writer.
This writer takes an already-loaded tile DataFrame ((source, tile) schema).
Use cog_gbx instead if you have source files on disk to split into a grid of
mini-COGs. The grid can be native pixel tiling or quadbin cell-aligned.
The writer reads raw files, tiles them, and optionally emits a mosaic.vrt index.
See the COG Writer and VRT & Mosaics.
Common functions: used vs excluded
See GBX Common Functions for the full catalog of shared file-access primitives. The table below shows which are active in this writer and which are not, and why.
| Common capability | Used here? | How / why |
|---|---|---|
list_local_files (session-free enumeration) | Not used by the writer | Writers do not enumerate source files; they write a DataFrame's output partitions. |
gbx_file_write / FILE-tier write | Not in the DataSource | The DataSource writer (df.write.format(...)) is session-less on Connect and commits via FUSE. FILE-tier writes use gbx_file_write at the function layer instead. |
gbx_file_read (FILE-tier read) | Not in the DataSource | FILE-tier reads for raster data go through gbx_file_read at the function layer. |
The *_gbx writers commit via the shared file_gbx file-access base — file_mode, layout, and the no-gating rule are described there. See also file_gbx Writer for the write API.