NumPyArrayToFeatureClass

Zusammenfassung

Konvertiert ein strukturiertes NumPy-Array in eine Point-Feature-Class.

Diskussion

If a field name from the input array is invalid for the output format, it will be validated. All invalid characters in the input field name are replaced with an underscore (_) in the output field name. Field name restrictions depend on the specific database used.

NumPyArrayToFeatureClass überschreibt eine vorhandene Feature-Class nicht, auch wenn der Umgebungsparameter overwriteOutput auf "true" festgelegt ist.

NumPy is a fundamental package for scientific computing in Python, including support for a powerful N-dimensional array object. For more information, see Working with NumPy in ArcGIS.

Syntax

NumPyArrayToFeatureClass (in_array, out_table, shape_fields, {spatial_reference})
ParameterErläuterungDatentyp
in_array

Ein strukturiertes NumPy-Array.

Das Array muss Feldnamen und NumPy-dtypes enthalten.

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' 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

Der Raumbezug der Feature-Class. Wird dieses Argument angegeben, erfolgt für das Feature eine Projektion (Transformation) aus dem Raumbezug der Eingabe. Bei keiner Angabe wird der Raumbezug der Eingabe-Feature-Class verwendet. Gültige Werte für dieses Argument sind SpatialReference-Objekte oder Zeichenfolgenentsprechungen.

(Der Standardwert ist None)

SpatialReference

Codebeispiel

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
#
SR = 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'], SR)

Verwandte Themen