Dataset

Luo_Suppe2026-08-15

gma.gio.Dataset

class Dataset(data = None, shape = None, crs = None, geo_transform = None, dtype = None, nodata = None, metadata = {}, **kwargs):

A gma Dataset object. Create a Dataset object!

Optional:

data = Dataset||ndarray||list||tuple||None. Default None.

Input data source. Can be a Dataset object, or a NumPy ndarray, list, tuple.

If data is None, a new Dataset will be created according to the shape parameter.

shape = tuple||None. Default None.

Shape of the new Dataset. If shape is a 2-tuple, it represents (rows, columns), and the number of bands is 1. If shape is a 3-tuple, it represents (bands, rows, columns).

If shape is None, data must be set.

crs = str||int||None. Default None.

The output coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters. Default(None) no coordinate system!

geo_transform = tuple||None. Default None.

Geo transformation of the output raster. The affine transformation is not specified by default (None).

dtype = str||None. Default None.

A code or string tag for the output raster data type.

Supported data types include: 'Unknown', 'Byte', 'UInt16', 'Int16', 'UInt32', 'Int32','Float32', 'Float64', 'CInt16', 'CInt32', 'CFloat32', 'CFloat64', ...

for more, see const.RaDT_*.

If dtype is None, the data type is determined by the data parameter.

nodata = float||None. Default None.

Invalid value for output raster. The default is not specified (None).

metadata = dict. Default {}.

Metadata to be added.

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate.


Methods

algebraic

[method] .algebraic(agg_fun, block = (None, 2048, 2048), sel_bands = None, scr_nodata = None, dst_nodata = None, **kwargs):

Perform algebraic operations on Dataset.

Parameters:

agg_fun: def.

Calculate functions. For Example: def calFun(in_ar): return in_ar[0] * 2.1 agg_fun = calFun in_ar: Input NumPy arrays with block`s shape.

Optional:

block = tuple. Default (None, 2048, 2048).

Block sizes for bands, rows, and columns. Use None to represent all.

sel_bands = list||None. Default None.

Extract band numbers. Selecting a subset of bands can reduce memory usage.

The default (None) is all bands.

scr_nodata = float. Default None.

Input nodata value. The default is not specified (None).

dst_nodata = float. Default None.

Output nodata value. The default is scr_nodata (None).

**kwargs:

Other parameters passed to driver.RasterDriver.create.

Returns:

Type: Dataset.


clip

[method] .clip(layer, **kwargs):

Clip off areas that are not covered by the method layer.

Parameters:

layer: Layer||Feature||Geometry||str.

A GMA item use for cliping!

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate

Returns:

Type: Dataset.


extent

[method] .extent(**kwargs):

The extent of a geometry is the bounding rectangle.

Optional:

**kwargs:

Other parameters passed to _aio.Layer.Layer.

Returns:

Type: Layer.


gen_lonlat

[method] .gen_lonlat(**kwargs):

Generate latitude and longitude raster.

Returns:

Type: Dataset.

Band 1 is longitude, Band 2 is latitude.


get_palette

[method] .get_palette(bid = 1):

Get palette of the band.

Optional:

bid = int. Default 1.

Number of the element calculation band. Start with 1.

Returns:

Type: matplotlib.colors.ListedColormap||None.


isopleth

[method] .isopleth(interval = 50, base = 0, band = 1, **kwargs):

Generate a smooth curve formed by connecting points with equal quantity index values.

Optional:

interval = float. Default 50.0.

Isopleth interval.

base = float. Default 0.0.

The offset from the zero point of the start of the interval.

band = int. Default 1.

The number of the band to be calculated starts from 1.

**kwargs:

Other parameters passed to _aio.layer.Layer.

Returns:

Type: Layer.


plot

[method] .plot(ax = None, bands = None, **kwargs):

Make plots of Dataset.

Optional:

ax = None||matplotlib.~.AxesSubplot. Default None.

A matplotlib subplot. If None, a default axes will be created.

bands = int||list||None. Default None.

The band ID to be plotted. For multi-band data, only 1, 3 (RGB), and 4 (RGBA) bands are supported for selection. Duplicate bands will only keep one. Default is the first four bands.

**kwargs:

Other parameters passed to matplotlib.image.AxesImage.

Returns:

matplotlib.~.AxesSubplot.


reclassify

[method] .reclassify(remap, method = "Range", **kwargs):

Reclassifies (or changes) the values in a raster.

Parameters:

remap: dict.

Remap object. Used to remap an input value or range definition to a new value.

The format is {mapping1: value1, mapping2: value2, ...}.

Note: Items containing NAN will be rejected directly.

Optional:

method = str. Default 'Range'.

Specifies how to reclassify the values of the input raster. May be: 'Range' or 'Unique'.

'Range': The data in the range will be mapped.

'Unique': Mapped strictly on a one-to-one basis.

For example: Remap = {1000: 1, 2000: 2, 3000: 3} 1. ReClaMethod = 'Range'.

Data <= 1000: --> 1 1000 < Data <= 1000: --> 2 2000 < Data <= 3000: --> 3 Data > 3000: --> NoData 2. ReClaMethod = 'Unique'.

Data == 1000: --> 1 Data == 2000: --> 2 Data == 3000: --> 3 Other values: --> NoData

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate

Returns:

Type: Dataset.


resample

[method] .resample(resolution, method = "Nearest", **kwargs):

Change the spatial resolution of the Dataset.

Parameters:

resolution: float||list.

Resampling resolution(X, Y).

Optional:

method = str. Default 'Nearest'.

Resampling method. Supported resampling methods include: 'Nearest', 'Bilinear', 'Cubic', 'CubicSpline', 'Lanczos', 'Average', 'RMS', 'Mode'.

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate

Returns:

Type: Dataset.


set_crs

[method] .set_crs(crs):

Set dataset's crs!

Parameters:

crs: str||int||None.

The output coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters. Default(None) no coordinate system!


set_gcps

[method] .set_gcps(gcps = [(0, 0, 0, 0, 0, '', '')], crs = None):

Set GCPs.

Optional:

gcps = list[tuple]. Default [(0, 0, 0, 0, 0, '', '')].

list(4 foloat + 2str) of gcps values.

format: [(x(float), y(float), z(float), pixel(float), line(float), info(str, opt), id(str, opt)), ...]

crs = str||int||None. Default None.

The gcps' coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters. Default(None) no coordinate system!


set_geo_transform

[method] .set_geo_transform(geo_transform):

Set dataset's geo transform!

Parameters:

geo_transform: tuple.

Geo transformation of the output raster(6 float of tuple). format: [x min, x resolution, x rotation, y max, y rotation, y resolution]


set_metadata

[method] .set_metadata(metadata):

Set dataset's metadata!

Parameters:

metadata: dict.

Metadata to be added.


set_nodata

[method] .set_nodata(nodata, bids = None):

Set dataset's nodata value of band!

Parameters:

nodata: float.

Invalid value for output raster.

Optional:

bids = int||lintofint||None. Default None.

Number of the element calculation band. Start with 1. None for all bands.


set_palette

[method] .set_palette(palette):

Set dataset's palette of band!

Parameters:

palette: dict||matplotlib.~.cmap||alistofthem.

Palette(color table) of raster bands.

For example: 1.dict({value: (R,G,B,A)}): palette = {10:(200,50,100,255), 20:(200,50,100,255)}.

2.camp: import matplotlib.colors as cor palette = cor.ListedColormap(['r', 'g', 'b'], N = 256)


set_statistics

[method] .set_statistics(statistics, bids = None):

Set dataset's statistics of band!

Parameters:

statistics: None||listoftuple(vmin||vmax||vmean||vstddev).

Statistics values. None for automatically compute statistics.

Optional:

bids = int||lintofint||None. Default None.

Number of the element calculation band. Start with 1. None for all bands.


shift

[method] .shift(distance = 1):

Shift a distance of the dataset. **Warining: This method will modify the original data.

Parameters:

distance = float||list. Default 1.

X, Y shift distance. If a single value is provided, it is assumed that X = Y.

Returns:

Type: Dataset.


to_bytearray

[method] .to_bytearray(row_off = 0, column_off = 0, row_size = None, column_size = None, sel_bands = None):

Reads the raster dataset as a bytearray.

Optional:

row_off = int. Default 0.

The starting row of the data to be read.

column_off = int. Default 0.

The starting column of the data to be read.

row_size = int. Default None.

The number of rows to read from the start row (the row width of the data window). The default (None) is all rows from the start row.

column_size = int. Default None.

The number of columns to read from the start column (the column width of the data window). Default (None) All columns from the start column.

sel_bands = int||list. Default None.

The band number or list of band numbers to be read. Default (None) All bands (numbering starts from 1).

Returns:

Type: bytearray.


to_crs

[method] .to_crs(crs, **kwargs):

Reproject to another coordinate system.

Parameters:

crs: str||int.

The output coordinate system. Can be EPSG, WKT, Proj4, and other types of coordinate characters.

Optional:

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate

Returns:

Type: Dataset.


to_dtype

[method] .to_dtype(dtype, **kwargs):

Convert the data type of raster.

Parameters:

dtype: str.

A code or string tag for the output raster data type.

Supported data types include: 'Unknown', 'Byte', 'UInt16', 'Int16', 'UInt32', 'Int32','Float32', 'Float64', 'CInt16', 'CInt32', 'CFloat32', 'CFloat64', ...

for more, see const.RaDT_*.

Optional:

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate

Returns:

Type: Dataset.


to_file

[method] .to_file(out_dst, driver = "GTiff", **kwargs):

Save Dataset as a raster file.

Parameters:

out_dst: str.

The output raster file path.

Optional:

driver = str. Default 'GTiff'.

Output file driver. For other drivers, see gft.RasterSummary().CreatableFormats.

**kwargs:

Other parameters passed to _algos.geo.dataset.raster_translate.


to_layer

[method] .to_layer(field = None, band = 1, gtype = "Polygon", mask = False, **kwargs):

Translate Dataset to Layer!

Optional:

field = str. Default None.

The name of the output vector field. None for band.

band = int. Default 1.

Number of the element calculation band. Start with 1.

gtype = str. Default 'Polygon'.

Geometry type! Can be 'Point', 'MultiPoint', 'Line', 'MultiLine', 'MultiPolygon' or 'Polygon'. The default (None) is the automatic geometry type.

mask = bool. Default False.

Whether to build mask layer(nodata:0, other:1).

**kwargs:

Other parameters passed to _algos.geo.layer.Layer.

Returns:

Type: Layer.


to_numpy

[method] .to_numpy(row_off = 0, column_off = 0, row_size = None, column_size = None, sel_bands = None, mask_nodata = False):

Reads the raster dataset as a 3-ndim Numpy array.

Optional:

row_off = int. Default 0.

The starting row of the data to be read.

column_off = int. Default 0.

The starting column of the data to be read.

row_size = int. Default None.

The number of rows to read from the start row (the row width of the data window). The default (None) is all rows from the start row.

column_size = int. Default None.

The number of columns to read from the start column (the column width of the data window). Default (None) All columns from the start column.

sel_bands = int||list. Default None.

The band number or list of band numbers to be read. Default (None) All bands (numbering starts from 1).

mask_nodata = bool. Default False.

Whether to mask array with nodata value.

Returns:

Type: array.


write_array

[method] .write_array(ar, row_off = 0, column_off = 0, sel_bands = None):

Write array to dataset.

Parameters:

ar: np.ndarray.

The NumPy array that needs to be set.

Optional:

row_off = int. Default 0.

The starting row of the data to be read.

column_off = int. Default 0.

The starting column of the data to be read.

sel_bands = int||list. Default None.

The band number or list of band numbers to be read. Default (None) All bands (numbering starts from 1).


Property

blocks

Fetch the natural block size of this band. --> list(x and y dimensions of block)


bounds

Bounds. --> tuple


compression

Raster compression. --> str


crs

Raster coordinate reference system. -> CoordinateReferenceSystem


driver

Raster driver. --> RasterDriver


dtype

Raster data type. --> str


gcps

Raster GCPs. --> tuple


geo_transform

Raster geo transform. --> tuple


Layer path link. --> str


metadata

metadata. --> dict


name

Raster Name. --> str


nodata

Raster nodata values. --> float


resolution

X, Y resolution. --> tuple


shape

Raster shape. --> tuple(band, rows, columns)


stats

Get stats of all bands. --> dict


Last Updated 8/15/2026, 8:42:21 AM