Command Line Execution


FRAGSTATS can now be executed via a command line to allow you to run FRAGSTATS from within another user program. The command line control is limited to specifying a FRAGSTATS parameterization file (.frg). In essence, you can call up FRAGSTATS, specify an existing parameterization file, and execute FRAGSTATS from a single command line. However, the FRAGSTATS parameterization file must be created 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. The syntax for this command line call is as follows:

 

Fragstats ParameterizationFile.frg /c

 

                Fragstats argument simply calls and executes the program. The .exe extension is optional (i.e., either Fragstats or Fragstats.exe will work) and it is NOT case sensitive. If the Fragstats executable 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 follows: Drive:\path_to_Fragstats\Fragstats ParameterizationFile.frg /c

                ParameterizationFile is the name of the FRAGSTATS parameterization file created using the standard FRAGSTATS 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 .frg extension and this should be included in the argument.

                /c is a switch that closes FRAGSTATS after the execution is completed; it is NOT case sensitive. If this argument is omitted, then the FRAGSTATS GUI will remain open after each call until the user executes FRAGSTATS from the GUI and closes the window. Thus, omitting this switch simply opens the FRAGSTATS GUI, but nothing more. Thus, if you are going to call FRAGSTATS many times in a program, I strongly suggest using this switch.


There are several considerations when using the command line:

 

1.   When executed from a command line, FRAGSTATS output will automatically be saved to file. If an output file is not named in the specified parameterization file, FRAGSTATS will use the name of the input image as the basename for the output files, and the extensions .patch, .class, .land, and .adj will be extended to the basename for the corresponding output files. In addition, since the output to file is automatic, it is not necessary to check the Automatically Save Results check box.

 

2.   If the same output file basename is specified in multiple parameterization files, the results of each run will be appended to the same output file. Each run will have a header line, consisting of the metric acronyms in one row, followed by one or more rows containing the metric values associated with each patch, class, or landscape output. Note, if the parameterization files differ with respect to the selection of metrics, then the output formats will vary (i.e., each output will contain a different number and/or set of metrics). In this case, the columns associated with each metric will not necessarily line up across runs. If, on the other hand, the parameterization file is identical with respect to the choice of metrics, then the output formats will be constant and the columns will align properly.

 

3.   If the parameterization file cannot be loaded (because it is not the right format or cannot be found) an error message will pop up and the application will close as soon as the message is acknowledged by the user. Meanwhile the batch file is blocked, although it may continue after the application closes. There is probably no point into continuing the batch file after such a problem; it should be fixed, then the whole batch restarted.

 

4.   Note, there may be some confusion over when to use the Batch file option associated with the standard FRAGSTATS GUI run and the command line version of FRAGSTATS. The Batch file option is used when you want to run the same parameterization file on many different input images and save the results to a single file, or files depending on which level of metrics are selected in the parameterization file. The command line version is useful in at least two situations–there may be others. First, you may want to run many different parameterization files on the same input image or on many different input images. The command line allows you to specify a unique parameterization file for each run, unlike the Batch file option which uses a single common parameterization file for each run. Second, you may want to iteratively analyze and process an input image, modifying the image after each run based on the results. For example, you could input a landscape, run FRAGSTATS, modify the landscape by, say, reclassifying all cells belonging to patches meeting certain criteria based on certain patch metrics, and then run FRAGSTATS again on the modified landscape, and then repeat the process many times.