Geospatial Modelling Environment

list.raster (List Raster Datasets)

Creates a list of raster datasets in folders and subfolders matching user-specified search criteria


The command searches a folder (and optionally all subfolders and geodatabases) for raster datasets, storing the results in a variable in GME (a list of strings containing the full path to each raster dataset, with a default name of “rasterlist”). If a ‘match’ string is specified, only raster datasets with names matching this search string are returned (e.g. if match=”b*” only raster datasets beginning with the letter b are returned).

When using the list of datasets in scripting and automation it is often useful to have a corresponding list that contains only the name of the raster dataset. If a value is specified for the namevariable parameter, a second variable in GME is created that contains only the dataset name (with no extension). For instance, if the first dataset in the returned list is “C:datalandcover.img”, the corresponding value in the namevariable list is “landcover”. This means that the raster dataset name can be easily retrieved and used in naming output files in a script.

This command applies only to Grids, GeoTIFFs (*.tif), Imagine Image (*.img), and geodatabase raster formats. By default, geodatabases are not searched (as this takes much more time, and storing raster datasets in geodatabases is both rare and undesirable).

The command will print the resulting list to the output window. For very large lists this may be unwanted, and it can be switched off by setting print=FALSE.


list.raster(in, [match], [subfolders], [geodatabases], [variable], [namevariable], [print]);

inthe folder to search
[match]only include datasets that match this text (wildcards allowed)
[subfolders](TRUE/FALSE) If TRUE, also searches all subfolders (default=FALSE)
[geodatabases](TRUE/FALSE) If TRUE, also searches all geodatabases (default=FALSE)
[variable]the full path of returned raster datasets are stored in a variable of this name (default=rasterlist)
[namevariable]if specified, an additional variable containing only the names of the raster datasets (without file extensions) is created
[print](TRUE/FALSE) If TRUE, the list of datasets is printed to the output window (default=TRUE)



list.raster(in=”C:data”, match=”*.img”, subfolder=TRUE, variable=”imglist”);

list.raster(in=”C:data”, match=”NDVI*”, geodatabase=TRUE, subfolder=TRUE, namevariable=”rasternames”, print=FALSE);


Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently 


Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn