Answers:
在模型构建器中有几种处理命名的方法。ArcGIS对此有一个帮助部分:使用内联变量替换快速浏览。
一个光滑的方式,迅速从一个迭代器创建唯一的名称是通过调用%i%
或%n%
系统变量,在下面的形式输出文件:文件1,文件2,文件3,文件4 ...的%i%
系统变量引用当前列表中的位置,而%n%
系统变量引用当前模型迭代。您可以在所使用工具的输出参数中将其付诸实践。例如:
输出要素类
C:\temp\out%i%.shp
听起来好像您想做几个嵌套循环,一个嵌套循环用于工作空间中的要素类,另一个用于每个要素类中的要素。使用ModelBuilder很难(但可能)。
如果您想动手使用Python(我绝对推荐使用Python),请参考以下示例:
import arcpy, os
# Your source file geodatabase
input_workspace = r"c:\GISData\input.gdb"
# Your output raster folder
output_workspace = r"c:\GISData\rasters"
# The file extension for the output rasters -- when not saving to a geodatabase, specify .tif for a TIFF file format, .img for an ERDAS IMAGINE file format, or no extension for a GRID raster format.
output_ext = ".img"
# The field used to assign values to the output raster -- hopefully this is the same for all of your feature classes
value_field = "VALUE"
# Note: Instead of hardcoding the above values, you could also use arcpy.GetParameterAsText to allow the user to specify them via script tool parameters
# Set current workspace to the source file geodatabase
arcpy.env.workspace = input_workspace
# Loop over the feature classes
for fc in arcpy.ListFeatureClasses():
# Get the name of the ObjectID field so we can use it to name the output rasters
oid_field = arcpy.Describe(fc).OIDFieldName
# Loop over the features in the current feature class
for row in arcpy.SearchCursor(fc):
# Figure out what to name the output raster. In this case we should get something like "c:\GISData\rasters\myFeatureClass_1.img"
out_raster = os.path.join(output_workspace, "{0}_{1}{2}".format(os.path.basename(fc), row.getValue(oid_field), output_ext))
# Convert to raster
arcpy.PolygonToRaster_conversion(row, value_field, out_raster)
未经测试,但希望您能理解。IMO,对于大多数琐碎的任务,Python脚本比ModelBuilder模型更易于使用。
对于Python / ArcPy学习资源,没有比这个问题更进一步的东西了:有什么学习ArcPy的资源?