sedona.spark.raster package

Submodules

sedona.spark.raster.awt_raster module

class sedona.spark.raster.awt_raster.AWTRaster(min_x, min_y, width, height, sample_model: SampleModel, data_buffer: DataBuffer)[source]

Bases: object

Raster data structure of Java AWT Raster used by GeoTools GridCoverage2D.

__init__(min_x, min_y, width, height, sample_model: SampleModel, data_buffer: DataBuffer)[source]
data_buffer: DataBuffer
height: int
min_x: int
min_y: int
sample_model: SampleModel
width: int

sedona.spark.raster.data_buffer module

class sedona.spark.raster.data_buffer.DataBuffer(data_type: int, bank_data: List[ndarray], size: int, offsets: List[int])[source]

Bases: object

TYPE_BYTE = 0
TYPE_DOUBLE = 5
TYPE_FLOAT = 4
TYPE_INT = 3
TYPE_SHORT = 2
TYPE_USHORT = 1
__init__(data_type: int, bank_data: List[ndarray], size: int, offsets: List[int])[source]
bank_data: List[ndarray]
bank_samples(bank_index: int = 0) → ndarray[source]

Return the samples of a bank as an array indexed by sample index.

The offset of the bank is applied, so index i of the returned array holds the same sample as DataBuffer.getElem(bank_index, i) does in Java AWT. Sample models must go through this method instead of indexing bank_data directly, otherwise samples of banks with a non-zero offset are read from the wrong positions.

data_type: int
offsets: List[int]
size: int

sedona.spark.raster.meta module

class sedona.spark.raster.meta.AffineTransform(scale_x, skew_y, skew_x, scale_y, ip_x, ip_y, pixel_anchor: PixelAnchor)[source]

Bases: object

Affine transform from pixel coordinates to world coordinates.

The pixel at column 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:
  • scale_x (float) – Pixel width in world units.

  • skew_y (float) – Change in y per column; 0 for a raster without rotation.

  • skew_x (float) – Change in x per row; 0 for a raster without rotation.

  • scale_y (float) – Pixel height in world units, negative for a north-up raster.

  • ip_x (float) – X coordinate of the upper-left pixel.

  • ip_y (float) – Y coordinate of the upper-left pixel.

  • pixel_anchor (PixelAnchor) – Whether ip_x and ip_y refer to the center or the upper-left corner of that pixel.

__init__(scale_x, skew_y, skew_x, scale_y, ip_x, ip_y, pixel_anchor: PixelAnchor)[source]
ip_x: float
ip_y: float
pixel_anchor: PixelAnchor
scale_x: float
scale_y: float
skew_x: float
skew_y: float
translate(offset_x: float, offset_y: float)[source]

Return the transform of a raster whose origin is offset by whole pixels.

Parameters:
  • offset_x (float) – Offset in pixel columns.

  • offset_y (float) – Offset in pixel rows.

Returns:

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.

Return type:

AffineTransform

with_anchor(pixel_anchor: PixelAnchor)[source]

Return the same transform expressed for another pixel anchor.

Parameters:

pixel_anchor (PixelAnchor) – The pixel anchor of the returned transform.

Returns:

This transform if it already uses pixel_anchor; otherwise a new transform whose origin is shifted by half a pixel.

Return type:

AffineTransform

class sedona.spark.raster.meta.PixelAnchor(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

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.

CENTER = 1
UPPER_LEFT = 2
class sedona.spark.raster.meta.SampleDimension(description, offset, scale, nodata)[source]

Bases: object

Raster band metadata.

Parameters:
  • description (str) – Description of the band.

  • offset (float) – Offset of the band: a stored pixel value means value * scale + offset.

  • scale (float) – Scale of the band.

  • nodata (float) – NODATA value of the band, or NaN if the band has none.

__init__(description, offset, scale, nodata)[source]
description: str
nodata: float
offset: float
scale: float

sedona.spark.raster.raster_serde module

sedona.spark.raster.sample_model module

class sedona.spark.raster.sample_model.ComponentSampleModel(data_type, width, height, pixel_stride, scanline_stride, bank_indices, band_offsets)[source]

Bases: SampleModel

__init__(data_type, width, height, pixel_stride, scanline_stride, bank_indices, band_offsets)[source]
as_numpy(data_buffer: DataBuffer) → ndarray[source]
band_offsets: List[int]
bank_indices: List[int]
pixel_stride: int
scanline_stride: int
class sedona.spark.raster.sample_model.MultiPixelPackedSampleModel(data_type, width, height, num_bits, scanline_stride, data_bit_offset)[source]

Bases: SampleModel

__init__(data_type, width, height, num_bits, scanline_stride, data_bit_offset)[source]
as_numpy(data_buffer: DataBuffer) → ndarray[source]
data_bit_offset: int
num_bits: int
scanline_stride: int
class sedona.spark.raster.sample_model.PixelInterleavedSampleModel(data_type, width, height, pixel_stride, scanline_stride, band_offsets)[source]

Bases: SampleModel

__init__(data_type, width, height, pixel_stride, scanline_stride, band_offsets)[source]
as_numpy(data_buffer: DataBuffer) → ndarray[source]
band_offsets: List[int]
pixel_stride: int
scanline_stride: int
class sedona.spark.raster.sample_model.SampleModel(sample_model_type, data_type, width, height)[source]

Bases: ABC

The SampleModel class and its subclasses are defined according to the data structure of SampleModel class in Java AWT.

TYPE_BANDED = 1
TYPE_COMPONENT = 6
TYPE_COMPONENT_JAI = 5
TYPE_MULTI_PIXEL_PACKED = 4
TYPE_PIXEL_INTERLEAVED = 2
TYPE_SINGLE_PIXEL_PACKED = 3
__init__(sample_model_type, data_type, width, height)[source]
abstract as_numpy(data_buffer: DataBuffer) → ndarray[source]
data_type: int
height: int
sample_model_type: int
scanline_stride: int
width: int
class sedona.spark.raster.sample_model.SinglePixelPackedSampleModel(data_type, width, height, scanline_stride, bit_masks)[source]

Bases: SampleModel

__init__(data_type, width, height, scanline_stride, bit_masks)[source]
as_numpy(data_buffer: DataBuffer) → ndarray[source]
bit_masks: List[int]
bit_offsets: List[int]
scanline_stride: int

sedona.spark.raster.sedona_raster module

Module contents