I have a set of 50 raster and and a polygon. I am trying to build a model which will input each raster and calculate raster statistics such as mean, max, min as per the polygon zone and create output in a table. So the output table will have 50 rows (each row for each raster) and 3 columns (mean, max, min). Any guidelines are welcome. I am new to model builder and only able to iterate raster as input and calculate the statistics but unable to save it in table. Thanks.
Solved! Go to Solution.
First, you need to create the desired schema for the target table. To do this, run the Zonal Statistics as Table tool, using one raster and a zonal feature class. Keep Statistics Type as "ALL". From the output table delete the undesired fields, and add any desired field (e.g. RASTER Name).
You can truncate the table, if required. It will remove the row, as the row will be added again when you run the model.
Here is how my example table schema looks like.
RASTER is a text field which will be filled with the name of corresponding Raster file.
__________________________________________________________________________________________________
My Model looks like this
In Model Builder,
1. Used Iterate Rasters to go through all raster files within a workspace (Filtered with Raster Format).
2. Zonal Statistics as Table. Added the Zone Feature Class, and linked the above raster(s) as Input Value Raster.
3. (Optional) I have added a field for Raster Name. You may use this step, if you want to add the Raster names to their corresponding rows. Else skip the step.
Use Add field to add an additional field for the Raster Name. The Field Name and Field Type should be same as your corresponding Field Name in Target Table. In my example, the Field Name is RASTER and Field Type is TEXT.
Use Calculate Field to add the value (Raster Name) to the field.
Field Name: RASTER
Expression Type: PYTHON 3
Expression: "%Name%"
4. Use Append. The previously created table would be your target dataset. And link the output table of Calculate Field, as your input datasets.
Change Field Matching Type to "Use the Field Map to reconcile schema differences"
Validate and Run the model.
You may truncate the target table before rerunning the model.
Here is how my target table looks like, after running the model.
First, you need to create the desired schema for the target table. To do this, run the Zonal Statistics as Table tool, using one raster and a zonal feature class. Keep Statistics Type as "ALL". From the output table delete the undesired fields, and add any desired field (e.g. RASTER Name).
You can truncate the table, if required. It will remove the row, as the row will be added again when you run the model.
Here is how my example table schema looks like.
RASTER is a text field which will be filled with the name of corresponding Raster file.
__________________________________________________________________________________________________
My Model looks like this
In Model Builder,
1. Used Iterate Rasters to go through all raster files within a workspace (Filtered with Raster Format).
2. Zonal Statistics as Table. Added the Zone Feature Class, and linked the above raster(s) as Input Value Raster.
3. (Optional) I have added a field for Raster Name. You may use this step, if you want to add the Raster names to their corresponding rows. Else skip the step.
Use Add field to add an additional field for the Raster Name. The Field Name and Field Type should be same as your corresponding Field Name in Target Table. In my example, the Field Name is RASTER and Field Type is TEXT.
Use Calculate Field to add the value (Raster Name) to the field.
Field Name: RASTER
Expression Type: PYTHON 3
Expression: "%Name%"
4. Use Append. The previously created table would be your target dataset. And link the output table of Calculate Field, as your input datasets.
Change Field Matching Type to "Use the Field Map to reconcile schema differences"
Validate and Run the model.
You may truncate the target table before rerunning the model.
Here is how my target table looks like, after running the model.