27.2.6. Vector conversion

27.2.6.1. Convert format

Converts any OGR-supported vector layer into another OGR-supported format.

This algorithm is derived from the ogr2ogr utility.

参数

Basic parameters

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

Input vector layer

Convert all layers from dataset

NEW in 3.24

CONVERT_ALL_LAYERS

[boolean]

Default: False

Converts the whole dataset. Supported output formats for this option are GPKG and GML.

Converted

OUTPUT

[same as input]

Specification of the output vector layer. One of:

  • 保存到临时文件

  • 保存到文件…

For Save to File, the output format has to be specified. All GDAL vector formats are supported. For Save to a Temporary File the QGIS default vector format will be used.

Advanced parameters

标注

名称

类型

描述

Additional creation options

可选

OPTIONS

[string]

Default: '' (no additional options)

Additional GDAL creation options.

输出

标注

名称

类型

描述

Converted

OUTPUT

[same as input]

The output vector layer

Python代码

Algorithm ID: gdal:convertformat

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

27.2.6.2. Rasterize (overwrite with attribute)

Overwrites a raster layer with values from a vector layer. New values are assigned based on the attribute value of the overlapping vector feature.

This algorithm is derived from the GDAL rasterize utility.

参数

Basic parameters

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

Input vector layer

Input raster layer

INPUT_RASTER

[栅格]

Input raster layer

Field to use for a burn-in value

可选

FIELD

[tablefield: numeric]

Defines the attribute field to use to set the pixels values

Advanced parameters

标注

名称

类型

描述

Add burn in values to existing raster values

ADD

[boolean]

Default: False

If False, pixels are assigned the selected field's value. If True, the selected field's value is added to the value of the input raster layer.

Additional command-line parameters

可选

EXTRA

[string]

Default: ''

Add extra GDAL command line options

输出

标注

名称

类型

描述

Rasterized

OUTPUT

[栅格]

The overwritten input raster layer

Python代码

Algorithm ID: gdal:rasterize_over

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

27.2.6.3. Rasterize (overwrite with fixed value)

Overwrites parts of a raster layer with a fixed value. The pixels to overwrite are chosen based on the supplied (overlapping) vector layer.

This algorithm is derived from the GDAL rasterize utility.

参数

Basic parameters

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

Input vector layer

Input raster layer

INPUT_RASTER

[栅格]

Input raster layer

A fixed value to burn

BURN

[数字]

Default: 0.0

The value to burn

Advanced parameters

标注

名称

类型

描述

Add burn in values to existing raster values

ADD

[boolean]

Default: False

If False, pixels are assigned the fixed value. If True, the fixed value is added to the value of the input raster layer.

Additional command-line parameters

可选

EXTRA

[string]

Default: ''

Add extra GDAL command line options

输出

标注

名称

类型

描述

Rasterized

OUTPUT

[栅格]

The overwritten input raster layer

Python代码

Algorithm ID: gdal:rasterize_over_fixed_value

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

27.2.6.4. Rasterize (vector to raster)

Converts vector geometries (points, lines and polygons) into a raster image.

This algorithm is derived from the GDAL rasterize utility.

Default menu: Raster ► Conversion

参数

Basic parameters

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

Input vector layer

Field to use for a burn-in value

可选

FIELD

[tablefield: numeric]

Defines the attribute field from which the attributes for the pixels should be chosen

A fixed value to burn

可选

BURN

[数字]

Default: 0.0

A fixed value to burn into a band for all features.

Burn value extracted from the "Z" values of the feature

可选

USE_Z

[boolean]

Default: False

Indicates that a burn value should be extracted from the "Z" values of the feature. Works with points and lines (linear interpolation along each segment). For polygons, works properly only if they are flat (same Z value for all vertices)

Output raster size units

UNITS

[enumeration]

Default: 0

Units to use when defining the output raster size/resolution. One of:

  • 0 --- Pixels

  • 1 --- Georeferenced units

Width/Horizontal resolution

WIDTH

[数字]

Default: 0.0

Sets the width (if size units is "Pixels") or horizontal resolution (if size units is "Georeferenced units") of the output raster. Minimum value: 0.0.

Height/Vertical resolution

HEIGHT

[数字]

Default: 0.0

Sets the height (if size units is "Pixels") or vertical resolution (if size units is "Georeferenced units") of the output raster.

Output extent

可选

EXTENT

[范围]

Extent of the output raster layer. If the extent is not specified, the minimum extent that covers the selected reference layer(s) will be used.

Available methods are:

  • Calculate from layer…: uses extent of a layer loaded in the current project

  • Calculate from layout map…: uses extent of a layout map item in the active project

  • Calculate from bookmark…: uses extent of a saved bookmark

  • Use map canvas extent

  • Draw on canvas: click and drag a rectangle delimiting the area to take into account

  • Enter the coordinates as xmin, xmax, ymin, ymax

Assign a specified nodata value to output bands

可选

NODATA

[数字]

Default: 0.0

Assigns a specified nodata value to output bands

Rasterized

OUTPUT

[栅格]

默认: [保存到临时文件]

Specification of the output raster layer. One of:

  • 保存到临时文件

  • 保存到文件…

For Save to File, the output format has to be specified. All GDAL raster formats are supported. For Save to a Temporary File the QGIS default raster format will be used.

Advanced parameters

标注

名称

类型

描述

Additional creation options

可选

OPTIONS

[string]

Default: ''

For adding one or more creation options that control the raster to be created (colors, block size, file compression...). For convenience, you can rely on predefined profiles (see GDAL driver options section).

Batch Process and Model Designer: separate multiple options with a pipe character (|).

Output data type

DATA_TYPE

[enumeration]

Default: 5

Defines the format of the output raster file.

Options:

  • 0 --- Byte (Eight bit unsigned integer (quint8))

  • 1 --- Int16 (Sixteen bit signed integer (qint16))

  • 2 --- UInt16 (Sixteen bit unsigned integer (quint16))

  • 3 --- UInt32 (Thirty two bit unsigned integer (quint32))

  • 4 --- Int32 (Thirty two bit signed integer (qint32))

  • 5 --- Float32 (Thirty two bit floating point (float))

  • 6 --- Float64 (Sixty four bit floating point (double))

  • 7 --- CInt16 (Complex Int16)

  • 8 --- CInt32 (Complex Int32)

  • 9 --- CFloat32 (Complex Float32)

  • 10 --- CFloat64 (Complex Float64)

Available options depend on the GDAL version built with QGIS (see Help ► About menu)

Pre-initialize the output image with value

可选

INIT

[数字]

Pre-initializes the output image bands with this value. Not marked as the nodata value in the output file. The same value is used in all the bands.

Invert rasterization

INVERT

[boolean]

Default: False

Burns the fixed burn value, or the burn value associated with the first feature into all parts of the image not inside the provided polygon.

Additional command-line parameters

可选

EXTRA

[string]

Default: ''

Add extra GDAL command line options

输出

标注

名称

类型

描述

Rasterized

OUTPUT

[栅格]

Output raster layer

Python代码

Algorithm ID: gdal:rasterize

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。