Create a temporary file name in Windows temp area

Create a temporary file name in Windows temp area 

 

Import arcpy module import arcpy # Get input feature class and output feature class input_fc = arcpy.GetParameterAsText(0) output_fc = arcpy.GetParameterAsText(1) # Get field list of input feature class fields = arcpy.ListFields(input_fc) # Create a list of field names to keep field_names = ["OID@", "SHAPE@", "SHAPE_LENGTH", "SHAPE_AREA"] # Loop through input feature class fields and add field names to field_names list for field in fields: if not (field.name in field_names): # If the field name is not in the field_names list field_names.append(field.name) # Add the field name to the field_names list # Use Make Feature Layer to create a layer from the input feature class arcpy.MakeFeatureLayer_management(input_fc, "temp_layer") # Use Add Field Delimiters to get the correct syntax for field names delimited_fields = arcpy.AddFieldDelimiters("temp_layer", field_names[0]) for i in range(1, len(field_names)): delimited_fields += "," + arcpy.AddFieldDelimiters("temp_layer", field_names[i]) # Use Copy Features to create the output feature class with only the specified fields arcpy.CopyFeatures_management("temp_layer", output_fc, delimited_fields) # Delete the temporary layer arcpy.Delete_management("temp_layer")运行错误:Traceback (most recent call last): File "D:\多对一空间连接\删除所有字段.py", line 28, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 2429, in CopyFeatures raise e ExecuteError: 执行失败。参数无效。 ERROR 000800: 该值不是 | DEFAULTS | TEXT_UTF16 | MAX_FILE_SIZE_4GB | MAX_FILE_SIZE_256TB | GEOMETRY_OUTOFLINE | BLOB_OUTOFLINE | GEOMETRY_AND_BLOB_OUTOFLINE | TERRAIN_DEFAULTS | MOSAICDATASET_DEFAULTS | MOSAICDATASET_INLINE 的成员。 执行(CopyFeatures)失败。 执行(删除所有字段)失败。请改正代码
05-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值