Step 4. Working with Batch Files (optional)
If you wish to analyze a single landscape, then simply select Landscape mode as the Input File Type in the Run Parameters dialog box (see Step 2) and skip this step. However, if you have many landscapes to analyze, you may want to run FRAGSTATS in batch mode by selecting Batch mode as the Input File Type option in the Run Parameters dialog box (Step 2). If you select Batch mode, you must also specify a properly formatted batch file by clicking on the Batch File Name button and navigating to the appropriate file. Note, FRAGSTATS uses the file extension .fbt for batch files and will look for files with this extension by default when navigating. The .fbt extension is not mandatory, but using it can help keep files organized. The batch file must be a comma-delimited ASCII file. Each line should specify the input landscape file name, cell size, background value, number of rows, number of columns, and input data type, in that order. The syntax for this file is as follows:
InputFileName, CellSize, Background, Rows, Columns, InputDataType
□ InputFileName is the full path and file name of the input landscape.
□ CellSize is an integer value corresponding to the cell size (in meters).
□ Background is an integer value corresponding to the designated background value. Note, any class designated as background in the Class Properties dialog box (see Step 5 on Modifying Class Properties) will be reclassified to this class value.
□ Rows is an integer value corresponding to the number of rows in the input image.
□ Columns is an integer value corresponding to the number of columns in the input image.
□ InputDataType is a character string identifying the input data format, with the following options corresponding to the various input data format types:
■ IDF_ARCGRID
■ IDF_ASCII
■ IDF_8BIT
■ IDF_16BIT
■ IDF_32BIT
■ IDF_ERDAS
■ IDF_IDRISI
The batch file should contain a record for each input landscape, and all arguments should be separated by a comma. The parameter values should reflect the Input Data Type for each input landscape. In other words, if the Input Data Type is ASCII or BINARY, then the record must contain all of the parameters specified above. However, if the Input Data Type is ARCGRID, ERDAS, or IDRISI, then the record need only contain the input landscape file name and the background value; the remaining parameters should be assigned “x”, as illustrated in the following example:
D:\Foo\Bar\ASCIIfilename,25,999,250,300,IDF_ASCII
D:\Foo\Bar\8BITfilename2,25,999,250,300,IDF_8BIT
D:\Foo\Bar\16BITfilename2,25,999,250,300,IDF_16BIT
D:\Foo\Bar\32BITfilename2,25,999,250,300,IDF_32BIT
D:\Foo\Bar\ARCGRIDfilename,x,999,x,x,IDF_ARCGRID
D:\Foo\Bar\ERDASfilename,x,999,x,x,IDF_ERDAS
D:\Foo\Bar\IDRISIfilename,x,999,x,x,IDF_IDRISI
etc.
NOTE, since Arc Grid files are actually folders containing multiple files, not single image files, the file naming convention is a bit different. In this case, the input file name should be given as the path to the Arc Grid folder. In addition, regardless of input data type, the cell size, background value, rows and columns can be different for each input landscape.
NOTE, running from a batch file does not eliminate the necessity of completing the parameterization of FRAGSTATS; it only provides a mechanism for running FRAGSTATS on more than one landscape without having to parameterize and run each landscape separately. Specifically, you still must set the remaining run parameters (Step 2) and select and parameterize the individual metrics (Step 3). The batch file only specifies the file name, input data type, and grid attributes for each input landscape; all other run parameters must be specified according to the directions in Steps 2 and 3.
Using the Batch File Editor
FRAGSTATS includes a Batch File Editor that allows you to build and edit batch files via a dialog box (Fig. 7) accessible via the Tools menu in the opening window:
Figure 7. Batch file editor dialog box.
• Using the Batch File Editor to Create a Batch File.–Although in most cases it will be more efficient to create a batch file using a text editor (because you can copy and paste lines easily), you can build one using the Batch File Editor by following these steps:
1. Add a Record.--When you first open the Batch File Editor, the main text window (Fig. 7) will be empty. You must first add a record to the empty batch file by selecting the Add Record option from the Edit drop-down menu or by simply clicking on the “+” button to the right of the main text window. When you do so, the text window will display “(invalid entry)” because the rest of the required information has not been entered yet.
2. Select File Type.–Next, select the appropriate input data type from the list of options available by pressing the down arrow button under File Type. For example, if the first input landscape is an Arc Grid, then select the Arc Grid file type.
3. Select Input File.–Next, select an input file by typing in the full path and file name or clicking on the navigation button to navigate to the file. Note, by selecting the File Type first (step 2 above), the navigation will be restricted by default to only files of the specified type.
4. Enter Relevant Grid Attributes.–Next, enter the relevant grid attributes given the selected file type. If the File Type is ArcGRID, ERDAS, or IDRISI, then you only need to enter a background value. If the File Type is ASCII or BINARY, then you need to enter the cell size, background value, and number of rows and columns.
5. Apply the Specified Parameters.–Click on the Apply button to the right of the main text window to apply the specified parameters. The record in the text window should change to reflect the specified parameters. Note, if you enter inappropriate values in the text window, the record will be marked as “(invalid entry)” and you will need to make the necessary changes.
6. Repeat the Process for each Input Landscape.–Repeat steps 1-5 for each input landscape that you want to include in the batch file. Note, you can specify different input file types and grid attributes for each record.
7. Save and Close Batch File.–When you are finished adding records to the batch file, and you are certain that all entries are valid, then you can save the batch file. You can save this file and remain in the Batch File Editor via the File-Save or File-Save As options, or you can save this file and close the Editor in several ways: (1) by clicking on the Close button to the right of the main text window, (2) by clicking on the “X” in upper right corner of the Editor window, or (3) by selecting the File-Close option. In all cases, you will be prompted to enter a file name if it is a new batch file, or you will be queried to save the changes if the file name already exists.
• Using the Batch File Editor to Edit Batch Files.–In some cases you may need to edit an existing batch file. You can use the Batch File Editor to edit an existing file by following these steps:
1. Open Existing Batch File.–Open an existing batch file using the File-Open menu item. Note, you can edit a newly created batch file using these same procedures. The main text window (Fig. 7) should display the contents of the batch file. Any invalid records will be labeled as such.
2. Modify the Arguments of Existing Records.–You can modify the arguments associated with each record by changing the relevant parameter and applying the changes. For example, if the selected record does not contain a valid file type argument, select the appropriate file type from the available options by clicking on the down arrow button under File Type, and then click on the Apply button located to the right of the main text window. The file type argument should get updated in the selected record. Any or all of the arguments can be changed before applying the changes.
3. Add and Delete Records.–You can easily add and delete records from the batch file. To add a record simply follow Steps 1-5 described above under ‘Using the Batch File Editor to Create a Batch File’. To delete a record, simply select the record and delete it via the Edit-Delete menu option or by depressing the “-” button located to the right of the main text window.
4. Promote and Demote Records.–You can change the order of records by promoting or demoting their position in the batch file. Simply select the record by clicking on the record in the main text window and then use the Edit-Promote/Demote menu options or depress the up or down arrows located to the right of the main text window.
5. Save and Close Batch File.–When you are finished editing the batch file, and you are certain that all entries are valid, you can save the file as before via the File-Save or File-Save As options. Alternatively, you can save this file and close the Editor in several ways: (1) by clicking on the Close button to the right of the main text window, (2) by clicking on the “X” in upper right corner of the Editor window, or (3) by selecting the File-Close option. In all cases, you will be prompted as to whether to save the changes to the existing file.