NumPyArrayToRaster (arcpy)

摘要

将 NumPy 数组转换为栅格。

讨论

所生成的栅格数据集的大小和数据类型取决于输入数组。

拥有 x_cell_sizey_cell_size 参数可支持矩形像元。

语法

NumPyArrayToRaster (in_array, {lower_left_corner}, {x_cell_size}, {y_cell_size}, {value_to_nodata})
参数说明数据类型
in_array

The NumPy array to convert to a raster.

NumPyArray
lower_left_corner

The lower left corner of the output raster to position the NumPy array. The X and Y values are in map units.

(默认值为 0.0)

Point
x_cell_size

The cell size in the x direction specified in map units. The input can be a specified cell size (type: double) or an input raster.

When a dataset is input for the x_cell_size, the x cell size of the dataset is used for the x cell size for the output raster.

If only the x_cell_size is identified and not the y_cell_size, a square cell will result with the specified size.

If neither x_cell_size or y_cell_size are specified, a default of 1.0 will be used for both the x and y cell size.

(默认值为 1.0)

Double
y_cell_size

The cell size in y direction specified in map units. The input can be a specified cell size (type: double) or an input raster.

When a dataset is input for the y_cell_size the y cell size of the dataset is used for the y cell size for the output raster.

If only the y_cell_size is identified and not the x_cell_size a square cell will result with the specified size.

If neither x_cell_size or y_cell_size are specified, a default of 1.0 will be used for both the x and y cell size.

(默认值为 1.0)

Double
value_to_nodata

The value in the NumPy array to assign to NoData in the output raster.

If no value is specified for value_to_nodata, there will not be any NoData values in the resulting raster.

Double
返回值
数据类型说明
Raster

输出栅格。

代码实例

NumPyToRaster 示例

从随机生成的 NumPy 数组创建一个新栅格。

import numpy
import arcpy

my_array = numpy.random.random_integers(0, 100, 2500)
my_array.shape = (50, 50)
my_raster = arcpy.NumPyArrayToRaster(my_array)
my_raster.save("c:/output/fgdb.gdb/myRandomRaster")

相关主题

9/15/2013