FRAGSTATS can be executed via a command line to allow you to run FRAGSTATS from within another program (e.g., R). The command line control is limited to specifying a FRAGSTATS model file (.fca). In essence, you can call FRAGSTATS, specify an existing model, and execute the model from a single command line. However, the model file must be created first via the Graphical User Interface in the usual way - there are simply too many parameters to make full specification via the command line a practical alternative at this time. The syntax for this command line call is as follows (note, there is a required space before and after -m, -b and -o in the command line below):

frg -m model_name_here -b batch_file_name_here -o output_file_name_here


Here are some example valid command line calls:

frg -m test.fca
frg.exe -m test.fca
c:\foobar\frg -m test.fca
frg -m test.fca -b c:\foobar\batch_file.fbt
frg -m test.fca -o c:\foobar\basename
frg -m test.fca -b c:\foobar\batch_file.fbt -o c:\foobar\basename


There are several important considerations regarding the arguments in the command line:

  • frg [required] -- frg simply calls and executes the program. The .exe extension is optional (i.e., either frg or frg.exe will work) and it is NOT case sensitive. If the FRAGSTATS executable (frg.exe) is NOT in the current folder OR is NOT specified in the system's Path variable, then the full path to the executable is required, as in the third example given.

  • -m [required] -- This is a required switch to name a FRAGSTATS model file (.fca). The model file is a fully parameterized model created via the graphical user interface. This file specifies all required and user-selected parameters of the analysis. It should be parameterized completely according to the instructions given elsewhere for Running FRAGSTATS via the Graphical User Interface. Note, FRAGSTATS parameterization files are assigned the .fca extension and this should be included in the argument. If the model file does not exist or is improperly formatted, the execution will fail.

  • -b [optional] -- This is an optional switch to name a FRAGSTATS batch file (.fbt). The batch file lists the input layers and the corresponding grid attributes of each layer (see previous discussion). If you specify the -b switch, then you must provide a batch file. The batch file specified here will override whatever is specified in the model file. Thus, the model file can be created without specifying any input layers, if you intend on specifying a batch file here. Note, specifying a batch file here is identical to loading the same batch file in the model via the graphical user interface and not specifying the -b switch here. Importantly, if you do NOT specify the -b switch, then the input layers must be specified in the model file, or the execution will fail.

  • -o [optional] -- This is an optional switch to name an output file name (i.e., basename). The output file name is the basename for the output files corresponding to each level of metrics selected (basename.patch, basename.class, basename.land, and basename.adj). If you specify the -o switch, then you must provide an output file name with a complete path. Note, if you specify the basename of a file that already exists, FRAGSTATS will automatically rename the extension of the existing files to *.bk1. The next time there is a conflict, the files will be renamed *.bk2, and so on. Appending the results to an existing file is not an option because there is no guarantee that the output file structure will be the same. Importantly, if you do NOT specify the -o switch, then the output file (basename) must be specified and the Automatically save results... button checked in the model file, or the execution will fail.