ListRasters
汇总
此 ListRasters 函数用于返回当前工作空间中的栅格列表。
讨论
必须先设置工作空间环境,然后才能使用多个列表函数,包括 ListDatasets 、 ListFeatureClasses 、 ListFiles 、 ListRasters 、 ListTables 和 ListWorkspaces 。
语法
ListRasters({wild_card}, {raster_type})
| 参数 | 说明 | 数据类型 | ||||||
|---|---|---|---|---|---|---|---|---|
|
wild_card |
限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。
|
* |
||||||
|
raster_type |
Specifies the raster type that will be used to limit the results. The following are valid raster types:
(默认值为 All) |
String |
返回值
| 数据类型 | 说明 |
|---|---|
|
String |
该函数返回的列表包含工作空间中的栅格名称,可以选择使用 |
代码示例
列出工作空间中的 Grid 栅格名称。
import arcpy
# Set the current workspace
arcpy.env.workspace = "c:/data/DEMS"
# Get and print a list of GRIDs from the workspace
rasters = arcpy.ListRasters("*", "GRID")
for raster in rasters:
print(raster)