Skip to main content

ListRasters

汇总

ListRasters 函数用于返回当前工作空间中的栅格列表。

讨论

必须先设置工作空间环境,然后才能使用多个列表函数,包括 ListDatasetsListFeatureClassesListFilesListRastersListTablesListWorkspaces

语法

ListRasters({wild_card}, {raster_type})

参数 说明 数据类型

wild_card

限制返回的结果。如果未指定某一值,则返回所有值。通配符不区分大小写。

符号

说明

示例

*

表示零个或多个字符。

Te* 可找到田纳西州和德克萨斯州。

*

raster_type

Specifies the raster type that will be used to limit the results. The following are valid raster types:

  • BMP—Bitmap graphic raster dataset format will be used.

  • GIF—Graphic Interchange Format for raster datasets will be used.

  • IMG— ERDAS IMAGINE raster data format will be used.

  • JP2—JPEG 2000 raster dataset format will be used.

  • JPG—Joint Photographics Experts Group raster dataset format will be used.

  • PNG— Portable Network Graphics raster dataset format will be used.

  • TIF—Tagged Image File for raster datasets will be used.

  • GRID— Grid data format will be used.

  • All—All supported raster types will be used. This is the default.

(默认值为 All)

String

返回值

数据类型 说明

String

该函数返回的列表包含工作空间中的栅格名称,可以选择使用 wild_cardraster_type 参数进行限制。

代码示例

ListRasters 示例

列出工作空间中的 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)