# NumPyArrayToFeatureClass

## 说明

NumPy 是 Python 中用于进行科学计算的基础包，其包括支持功能强大的 N 维数组对象。有关详细信息，请参阅在 ArcGIS 中使用 NumPy

## 语法

`NumPyArrayToFeatureClass (in_array, out_table, shape_fields, {spatial_reference})`
 参数 说明 数据类型 in_array NumPy 结构化数组。数组必须包含字段名称和 NumPy dtype。 NumPyArray out_table The output point feature class to which the records from the NumPy array will be written. String shape_fields[shape_fields,...] A list (or tuple) of field names used to create the feature class's geometry. Coordinates are specified in the order of x, y, z, and m; z-coordinate and m-value fields are optional. Assuming field names of x, y, z, and m in a numpy array, feature classes could be constructed as below. ``````import arcpy # Create a feature class with x,y fields arcpy.da.NumPyArrayToFeatureClass(array, fc, ("x", "y")) # Create a feature class with x,y,z fields arcpy.da.NumPyArrayToFeatureClass(array, fc, ("x", "y", "z")) # Create a feature class with x,y,m fields arcpy.da.NumPyArrayToFeatureClass(array, fc, ("x", "y", "", "m")) # Create a feature class with x,y,z,m fields arcpy.da.NumPyArrayToFeatureClass(array, fc, ("x", "y", "z", "m"))`````` String spatial_reference 要素类的空间参考。 指定此参数后，将根据输入的空间参考对要素进行投影（或变换）。 如果未指定，则将使用输入要素类的空间参考。 此参数的有效值为 SpatialReference 对象或等效字符串。(默认值为 None) SpatialReference

## 代码示例

NumPyArrayToFeatureClass 示例
``````import arcpy
import numpy

outFC = "C:/data/texas.gdb/fd/pointlocations"

# Create a numpy array with an id field, and a field with a tuple
#  of x,y coordinates
array = numpy.array(
[
(1, (471316.3835861763, 5000448.782036674)),
(2, (470402.49348005146, 5000049.216449278)),
],
numpy.dtype([("idfield", numpy.int32), ("XY", "<f8", 2)]),
)

# Define a spatial reference for the output feature class
spatial_ref = arcpy.Describe("C:/data/texas.gdb/fd").spatialReference

# Export the numpy array to a feature class using the XY field to
# represent the output point feature
arcpy.da.NumPyArrayToFeatureClass(array, outFC, ["XY"], spatial_ref)``````