SedonaRaster
DataFrame.collect() and Python UDFs receive raster column values as
SedonaRaster objects. Read the pixels with as_numpy or
as_rasterio, and the georeferencing with affine_trans and
crs_wkt. Call close, or use the raster as a context manager,
to release the resources it holds.
Sedona creates these objects when it reads a raster value; you do not
construct them yourself.
Parameters
int
required
Width of the raster in pixels.
int
required
Height of the raster in pixels.
List[SampleDimension]
required
Metadata of each band.
AffineTransform
required
Transform from pixel coordinates to world coordinates.
str
required
CRS of the raster as a WKT string.
affine_trans
bands_meta
crs_wkt
height
width
as_numpy()
as_numpy_masked()
as_rasterio()
close()
with_bands()
InDbSedonaRaster); other rasters
raise TypeError.
Parameters
np.ndarray
required
New pixel data, of shape (height, width) for a single band or
(bands, height, width). Height and width must match this raster;
the band count and dtype may differ.
Optional[Union[float, Sequence[float]]]
default:"None"
NODATA value of the output bands: a scalar for every band, or one
value per band. Use
float('nan') for a band without NODATA. When
omitted, the output bands inherit NODATA from the source bands.Returns
SedonaRaster
A new raster with the given pixel data and the same spatial metadata.
AffineTransform
Import fromsedona.spark.raster.meta.
col and row row maps to
x = ip_x + col * scale_x + row * skew_x and
y = ip_y + col * skew_y + row * scale_y. repr() shows the transform
as a 3x3 matrix.
Parameters
float
required
Pixel width in world units.
float
required
Change in y per column; 0 for a raster without rotation.
float
required
Change in x per row; 0 for a raster without rotation.
float
required
Pixel height in world units, negative for a north-up raster.
float
required
X coordinate of the upper-left pixel.
float
required
Y coordinate of the upper-left pixel.
PixelAnchor
required
Whether
ip_x and ip_y refer to the center or the upper-left
corner of that pixel.translate()
Parameters
float
required
Offset in pixel columns.
float
required
Offset in pixel rows.
Returns
AffineTransform
A new transform whose origin is pixel (
offset_x, offset_y)
of this one, for example the transform of a tile cut from the raster.with_anchor()
Parameters
PixelAnchor
required
The pixel anchor of the returned transform.
Returns
AffineTransform
This transform if it already uses
pixel_anchor; otherwise a new
transform whose origin is shifted by half a pixel.PixelAnchor
Import fromsedona.spark.raster.meta.
Anchor of the pixel cell. GeoTools anchors the coordinates at the center
of pixels, while GDAL anchors the coordinates at the upper-left corner of
the pixels. This difference requires us to convert the affine
transformation between these conventions.
Values
PixelAnchor
1PixelAnchor
2SampleDimension
Import fromsedona.spark.raster.meta.
Parameters
str
required
Description of the band.
float
required
Offset of the band: a stored pixel value means
value * scale + offset.float
required
Scale of the band.
float
required
NODATA value of the band, or NaN if the band has none.
SedonaUtils
Import fromsedona.spark.raster_utils.SedonaUtils.
display_image()
- A raster column (GridCoverage2D) — auto-applies RS_AsImage
- An HTML image column from RS_AsImage() — renders directly
Parameters
pyspark.sql.DataFrame
required
The DataFrame to display. All of its rows are collected to the
driver, so limit large DataFrames first.

