CreateScratchName (arcpy)

摘要

为指定的数据类型创建唯一的临时路径名称。如果未给定工作空间,则使用当前工作空间。

语法

CreateScratchName ({prefix}, {suffix}, {data_type}, {workspace})
参数说明数据类型
prefix

The prefix that is added to the scratchname. By default, a prefix of xx is used.

(默认值为 xx)

String
suffix

The suffix added to the scratchname. This can be an empty double-quoted string.

String
data_type

The data type which will be used to create the scratchname. Valid datatypes are:

  • CoverageOnly valid Coverage names are returned.
  • DatasetOnly valid Dataset names are returned.
  • FeatureClassOnly valid FeatureClass names are returned.
  • FeatureDatasetOnly valid FeatureDataset names are returned.
  • FolderOnly valid Folder names are returned.
  • GeodatasetOnly valid Geodataset names are returned.
  • GeometricNetworkOnly valid Geometric Network names are returned.
  • ArcInfoTableOnly valid ArcInfo Table names are returned.
  • NetworkDatasetOnly valid Network Dataset names are returned.
  • RasterBandOnly valid Raster Band names are returned.
  • RasterCatalogOnly valid Raster Catalog names are returned.
  • RasterDatasetOnly valid Raster Dataset names are returned.
  • ShapefileOnly valid Shapefile names are returned.
  • TerrainOnly valid Terrain names are returned.
  • WorkspaceOnly valid Workspace scratchnames are returned.
String
workspace

The workspace used to determine the scratch name to be created. If not specified, the current workspace is used.

String
返回值
数据类型说明
String

唯一的临时路径名称。

代码实例

CreateScratchName 示例

为“缓冲区”工具的派生输出创建唯一的临时路径。此路径名称将用作“裁剪”工具的输入。

import arcpy

# Set workspace
#
arcpy.env.workspace = "C:/Data/Municipal.gdb"

# Create a scratch name for the Buffer tool output.
#   The scratch name created will be include 'temp0.shp',
#   If temp0.shp already exists, the number will be incremented
#   until the name is unique in the workspace.
#
scratch_name = arcpy.CreateScratchName("temp",
                                       data_type="Shapefile",
                                       workspace=arcpy.env.scratchFolder)

# Execute Buffer tool, using scratch name for output
#
arcpy.Buffer_analysis("Roads", scratch_name, "1000 feet")

# Execute Clip tool, using scratch name for input
#
arcpy.Clip_analysis(scratch_name, "CityBoundary", "CityRoads")

# Delete scratch dataset
arcpy.Delete_management(scratch_name)

相关主题

5/10/2014