Styles
qgis_project.Style(opacity=1.0)
dataclass
Base class for layer styling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opacity
|
float
|
The layer opacity in the interval [0, 1] |
1.0
|
set_style(layer)
qgis_project.RasterStyle(opacity=1.0, vmin=None, vmax=None)
dataclass
Bases: Style
Base class for raster layer styling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vmin
|
float | list[float] | None
|
The minimum value used for the colorbar/contrast stretch. If None, will be automatically determined from the layer data. For styles with multiple bands (e.g. RasterStyleMultiBandColor), a list applies one value per band; a single value applies to all bands. |
None
|
vmax
|
float | list[float] | None
|
The maximum value used for the colorbar/contrast stretch. If None, will be automatically determined from the layer data. For styles with multiple bands (e.g. RasterStyleMultiBandColor), a list applies one value per band; a single value applies to all bands. |
None
|
qgis_project.RasterStyleBW(opacity=1.0, vmin=None, vmax=None)
dataclass
qgis_project.RasterStyleSinglePseudocolor(opacity=1.0, vmin=None, vmax=None, colormap='viridis')
dataclass
Bases: RasterStyle
A single-band pseudocolor style for raster layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colormap
|
str
|
Name of a QGIS built-in color ramp (case-insensitive), e.g. |
'viridis'
|
qgis_project.RasterStyleMultiBandColor(opacity=1.0, vmin=None, vmax=None)
dataclass
Bases: RasterStyle
A multi-band color (RGB) style for raster layers.
Maps three raster bands to the red, green, and blue channels, each with
an independent contrast stretch — e.g. true-color or false-color
composites. Requires layer.band_idx to be a list of three band
numbers, e.g. [1, 2, 3] for (R, G, B).
qgis_project.RasterStylePaletted(opacity=1.0, vmin=None, vmax=None, colors=None, labels=None, colormap='Spectral')
dataclass
Bases: RasterStyle
A paletted / unique-value style for single-band rasters — one fixed color per discrete band value.
Suited to categorical rasters (land cover, classification masks, segmentation
output) where each pixel value is a class label rather than a continuous
measurement. Unlike RasterStyleSinglePseudocolor, no interpolation is
applied between values; vmin/vmax are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
dict[int, str] | None
|
Explicit mapping of band value to color, e.g.
|
None
|
labels
|
dict[int, str] | None
|
Optional mapping of band value to legend label. Values without an entry fall back to the numeric value as their label. |
None
|
colormap
|
str
|
Name of a QGIS built-in color ramp (case-insensitive) used to assign
colors when |
'Spectral'
|
qgis_project.VectorStyle(opacity=1.0)
dataclass
qgis_project.VectorStyleSingleSymbol(opacity=1.0, color=None, outline_color=None, outline_width=None, size=None, marker_shape=None)
dataclass
Bases: VectorStyle
A single-symbol style for vector layers — every feature rendered identically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
str | None
|
Fill (polygon), line, or marker color, e.g. |
None
|
outline_color
|
str | None
|
Outline/stroke color for polygon and marker symbols. |
None
|
outline_width
|
float | None
|
Outline/stroke width in millimeters for polygon, line, and marker symbols. |
None
|
size
|
float | None
|
Marker size in millimeters. Only applies to point layers. |
None
|
marker_shape
|
str | None
|
Marker shape for point layers, e.g. |
None
|
qgis_project.VectorStyleCategorized(opacity=1.0, field='', colormap='Spectral')
dataclass
Bases: VectorStyle
A categorized style for vector layers — one color per unique attribute value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Name of the attribute field to categorize by. |
''
|
colormap
|
str
|
Name of a QGIS built-in color ramp (case-insensitive), e.g. |
'Spectral'
|
qgis_project.VectorStyleGraduated(opacity=1.0, field='', num_classes=5, vmin=None, vmax=None, colormap='Viridis')
dataclass
Bases: VectorStyle
A graduated (choropleth) style for vector layers — equal-interval color classes based on a numeric attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Name of the numeric attribute field to classify. |
''
|
num_classes
|
int
|
Number of equal-width classes. |
5
|
vmin
|
float | None
|
Lower bound of the classification range. If |
None
|
vmax
|
float | None
|
Upper bound of the classification range. If |
None
|
colormap
|
str
|
Name of a QGIS built-in color ramp (case-insensitive), e.g. |
'Viridis'
|
qgis_project.VectorLabels(field='', size=10.0, color='black', is_expression=False)
dataclass
Attribute-based labels for vector layers.
Labeling is independent of the layer's renderer/style and can be combined
with any VectorStyle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Name of the attribute field to use as label text, or a QGIS
expression if |
''
|
size
|
float
|
Font size in points. |
10.0
|
color
|
str
|
Text color, e.g. |
'black'
|
is_expression
|
bool
|
If |
False
|