跳转至
🎉 Apache Sedona 1.9.1 已正式发布!🗺️ 新增 Geography SQL 函数、Box2D 与 Box3D 类型、栅格 Python UDF 等。查看发布说明 →

RS_FromGeoTiff

Introduction: Returns a raster geometry from a GeoTiff file.

Format: RS_FromGeoTiff(asc: ARRAY[Byte])

Return type: Raster

Since: v1.4.0

Python example

from pyspark.sql import functions as f

df = sedona.read.format("binaryFile").load("/some/path/*.tiff")
df = df.withColumn("raster", f.expr("RS_FromGeoTiff(content)"))

A single serialized Raster value must fit in a Java byte array, which limits its size to roughly 2 GiB, including pixel data and metadata. A compressed GeoTIFF can be much smaller than its decoded raster. The number of pixels that fits depends on the band count, data types, and metadata.

For large GeoTIFFs, use the raster reader with explicit tile dimensions:

df = (
    sedona.read.format("raster")
    .option("retile", "true")
    .option("tileWidth", "256")
    .option("tileHeight", "256")
    .load("/some/path/*.tiff")
)

If the file bytes are already in a binaryFile DataFrame, nest RS_FromGeoTiff directly inside RS_TileExplode to avoid serializing the whole raster as one value.