Skip To Content

ListRasters

Summary

Returns a list of the rasters in the workspace, limited by name and raster type.

Discussion

The workspace environment must be set first before using several of the List functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and ListWorkspaces.

Syntax

ListRasters ({wild_card}, {raster_type})
ParameterExplanationData Type
wild_card

The wild_card limits the results returned. If no wild_card is specified, all values are returned.

String
raster_type

The raster type to limit the results returned by the wild card argument. Valid raster types are:

  • BMPBitmap graphic raster dataset format.
  • GIFGraphic Interchange Format for raster datasets.
  • IMG ERDAS IMAGINE raster data format.
  • JP2JPEG 2000 raster dataset format.
  • JPGJoint Photographics Experts Group raster dataset format.
  • PNG Portable Network Graphics raster dataset format.
  • TIFTagged Image File for raster datasets.
  • GRID Grid data format.
  • AllAll supported raster types are returned. This is the default.

(The default value is All)

String
Return Value
Data TypeExplanation
String

The list returned from the function containing raster names in the workspace, limited by the optional wild card and raster type.

Code sample

ListRasters example

List Grid raster names in workspace.

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)

Related topics