Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否使用python(ArcMap 10.5.1)将ArcGIS中的选定属性导出到新图层?_Python_Arcgis - Fatal编程技术网

是否使用python(ArcMap 10.5.1)将ArcGIS中的选定属性导出到新图层?

是否使用python(ArcMap 10.5.1)将ArcGIS中的选定属性导出到新图层?,python,arcgis,Python,Arcgis,我有一个包含25个不同年份数据的文件,我需要将每个年份的数据导出到一个新的shapefile中。我已经编写了一种选择文件的方法,但是现在我需要帮助将我选择的年份的数据导出到新的shapefile中。年度选择涉及SelectLayerByAttribute_管理功能,如果这有助于让您了解我是如何为选择编码的。出于实际目的,只需说我从中提取数据的主文件名为“Customers”,我想将各个年份导出到名为“Customers_20xx”的新形状文件中 导入arcpy >>>arcpy.SelectLa

我有一个包含25个不同年份数据的文件,我需要将每个年份的数据导出到一个新的shapefile中。我已经编写了一种选择文件的方法,但是现在我需要帮助将我选择的年份的数据导出到新的shapefile中。年度选择涉及SelectLayerByAttribute_管理功能,如果这有助于让您了解我是如何为选择编码的。出于实际目的,只需说我从中提取数据的主文件名为“Customers”,我想将各个年份导出到名为“Customers_20xx”的新形状文件中

导入arcpy >>>arcpy.SelectLayerByAttribute\u管理(“客户”、“新选择”、“年份=1989”) 那部分有效。当我输入该代码时,文件“Customers”中1989年的所有数据集都被选中。现在,只需将选定的数据导出到一个名为“Customers_1989”的新文件中即可。2小时前,PythonPerson直接从

最后一行可能就是你要找的那一行。如果在具有选择的图层上运行,则仅导出选定的要素。但是,如果在要素类或形状文件上执行此操作,将复制所有要素


如果您还没有从要素类或shapefile创建图层文件,那么我建议您使用
arcpy.MakeFeatureLayer\u management(“cities”、“lyr”)
命令来创建图层文件。

如果您共享已创建的代码,将更容易提供帮助。>>>>导入arcpy>>>arcpy.SelectionLayerByAttribute\u management(“Customers”,“NEW\u SELECTION”,“Year=1989”)>>>>当我按下enter键时>>>是自动的。我唯一做的部分就是之前的一切。那部分工作正常。当我输入代码时,文件“Customers”中1989年的所有数据集都被选中。现在只需将选中的数据导出到名为“Customers\u 1989”的新文件中即可
>>> import arcpy
>>> arcpy.SelectLayerByAttribute_management("Customers", "NEW_SELECTION", "Year=1989")
<Result 'Customers'>
# Import system modules
import arcpy

# Set the workspace
arcpy.env.workspace = "c:/data/mexico.gdb"

# Make a layer from the feature class
arcpy.MakeFeatureLayer_management("cities", "lyr") 

# Select all cities which overlap the chihuahua polygon
arcpy.SelectLayerByLocation_management("lyr", "intersect", "chihuahua", 0, "new_selection")

# Within selected features, further select only those cities which have a population > 10,000   
arcpy.SelectLayerByAttribute_management("lyr", "SUBSET_SELECTION", '"population" > 10000')

# Write the selected features to a new featureclass
arcpy.CopyFeatures_management("lyr", "chihuahua_10000plus")