com.esri.arcgis.geoprocessing.tools.spatialanalysttools
Class ZonalStatisticsAsTable
java.lang.Object
com.esri.arcgis.geoprocessing.AbstractGPTool
com.esri.arcgis.geoprocessing.tools.spatialanalysttools.ZonalStatisticsAsTable
- All Implemented Interfaces:
- GPTool
public class ZonalStatisticsAsTable
- extends AbstractGPTool
Summarizes the values of a raster within the zones of another dataset and reports the results to a table.
The Zonal Statistics as Table tool is contained in the Spatial Analyst Tools tool box.
Learn more about how Zonal Statistics works
Software restrictions: none
Usage tips:
- Zones are defined as areas that have identical values. If the zone input is a raster, it must be integer. If the zone input is a feature class, the zone field must be integer. A character field is also acceptable.
- When the zone and value inputs are both rasters of the same resolution, they will be used directly. If the resolutions are different, an internal resampling is applied to make them match before the zonal operation is performed. Should there be any NoData cells in the inputs, the resampling may cause there to be larger areas of NoData in your output than you might have expected. To avoid this situation, either Resample; the coarser of the input rasters to the resolution of the finer input raster, or set the Cell Size of the Raster Analysis Environment; to Minimum Of Inputs.
- If the zone input is a raster dataset, it must have an attribute table. The attribute table is usually created automatically for integer rasters, but may not be under certain circumstances. You can use Build Raster Attribute Table; (BuildRAT) to create one.
- If the zone input is feature dataset, a vector-to-raster conversion will be internally applied to it. To ensure that the results of the conversion will align properly with the value raster, it is recommended that you check that the extent and snap raster are set appropriately in the environment settings and the raster settings. Since the internal raster must have an attribute table, an error will occur if one was not created in the conversion. If this happens, convert your feature dataset directly with Feature To Raster or Polygon To Raster (Point To Raster and Polyline To Raster also), and use the resulting raster as your Zone input.
- If the zone input is feature dataset with small features, keep in mind that the resolution of the information needs to be appropriate relative to the resolution of the value raster. If the areas of single features are similar to or smaller than the area of single cells in the value raster, in the feature to raster conversion some of these zones may not be represented. To demonstrate this, try converting the feature dataset to a raster and specify the resolution to be that of the Value raster. The result from this conversion will give an indication about what the default output of Zonal Statistics will be. If you have fewer results in the output than you expected, you need to determine an appropriate raster resolution that will represent the detail of your feature input, and use this resolution as the Cell Size; of the Raster Analysis Settings of the Environment.
- If the zone input is a point feature dataset, it is possible to have more than one point contained within any particular cell of the value input raster. For such cells, the zone value is determined by the point with the highest feature ID.
- If the zone feature input has overlapping polygons, the zonal analysis will not be performed for each individual polygon. Since the feature input is converted to a raster, each location can only have one value. An alternative method is to process the zonal statistics iteratively for each of the polygon zones and collate the results.
- It is recommended to only use rasters as the zone input, as it offers you greater control over the vector-to-raster conversion. This will help ensure you consistently get the expected results.
- The input value raster can be either integer or floating point. However, when it is of floating-point type, the zonal calculations for majority, median, minority, and variety are not performed.
- For majority and minority calculations, when there is a tie the output for the zone is based on the lowest of the tied values.
- A series of fields will be created in the output table. Value, count, area, min, max, range, sum, mean, and std fields will be created regardless of the input values. Majority, minority, median, and variety fields will only be created when the input value raster is integer.
- The data type for each value under the items in the output table is dependent on the zonal calculation being performed. See how Zonal Statistics works; for the specific behavior of any statistic.
- The number of rows in the output table is the number of zones.
- An example of the output table is: VALUE COUNT AREA MEAN MIN MAX ... 0 5 125.0000 0.6 0.0 .0 ... 1 5 125.0000 1.0 0.0 3.0 ... 2 3 75.0000 1.667 1.0 2.0 ... 4 2 50.0000 3.0 3.0 3.0 ...
- The following environment settings affect this tool:
ZonalStatisticsAsTable
public ZonalStatisticsAsTable()
- Creates the Zonal Statistics as Table tool with defaults.
Initializes the array of tool parameters with the default values specified when the tool was created.
ZonalStatisticsAsTable
public ZonalStatisticsAsTable(Object inZoneData,
Object zoneField,
Object inValueRaster,
Object outTable)
- Creates the Zonal Statistics as Table tool with the required parameters.
Initializes the array of tool parameters with the values as specified for the required parameters and with the default values for the other parameters.
- Parameters:
inZoneData - Composite Geodataset, it can be a raster or feature dataset.zoneField - Field, field that holds the values that define each zone.inValueRaster - Composite Geodataset, raster that contains the values for which to calculate a statistic.outTable - Table, output table that will contain the summary of the values in each zone.
getInZoneData
public Object getInZoneData()
- Returns the Input raster or feature zone data parameter of this tool .
This parameter is Composite Geodataset, it can be a raster or feature dataset.
This is a required parameter.
- Returns:
- the Input raster or feature zone data
setInZoneData
public void setInZoneData(Object inZoneData)
- Sets the Input raster or feature zone data parameter of this tool .
This parameter is Composite Geodataset, it can be a raster or feature dataset.
This is a required parameter.
- Parameters:
inZoneData - Composite Geodataset, it can be a raster or feature dataset.
getZoneField
public Object getZoneField()
- Returns the Zone field parameter of this tool .
This parameter is Field, field that holds the values that define each zone.
This is a required parameter.
- Returns:
- the Zone field
setZoneField
public void setZoneField(Object zoneField)
- Sets the Zone field parameter of this tool .
This parameter is Field, field that holds the values that define each zone.
This is a required parameter.
- Parameters:
zoneField - Field, field that holds the values that define each zone.
getInValueRaster
public Object getInValueRaster()
- Returns the Input value raster parameter of this tool .
This parameter is Composite Geodataset, raster that contains the values for which to calculate a statistic.
This is a required parameter.
- Returns:
- the Input value raster
setInValueRaster
public void setInValueRaster(Object inValueRaster)
- Sets the Input value raster parameter of this tool .
This parameter is Composite Geodataset, raster that contains the values for which to calculate a statistic.
This is a required parameter.
- Parameters:
inValueRaster - Composite Geodataset, raster that contains the values for which to calculate a statistic.
getOutTable
public Object getOutTable()
- Returns the Output table parameter of this tool .
This parameter is Table, output table that will contain the summary of the values in each zone.
This is a required parameter.
- Returns:
- the Output table
setOutTable
public void setOutTable(Object outTable)
- Sets the Output table parameter of this tool .
This parameter is Table, output table that will contain the summary of the values in each zone.
This is a required parameter.
- Parameters:
outTable - Table, output table that will contain the summary of the values in each zone.
getIgnoreNodata
public String getIgnoreNodata()
- Returns the Ignore NoData in calculations parameter of this tool .
This parameter is String, denotes whether NoData values on the Value input will influence the results of the zone that they fall within.
This is an optional parameter.
- Returns:
- the Ignore NoData in calculations
setIgnoreNodata
public void setIgnoreNodata(String ignoreNodata)
- Sets the Ignore NoData in calculations parameter of this tool .
This parameter is String, denotes whether NoData values on the Value input will influence the results of the zone that they fall within.
This is an optional parameter.
- Parameters:
ignoreNodata - String, denotes whether NoData values on the Value input will influence the results of the zone that they fall within.
getToolName
public String getToolName()
- Returns the name of this tool.
- Returns:
- the tool name
getToolboxName
public String getToolboxName()
- Returns the name of the tool box containing this tool.
- Returns:
- the tool box name
getToolboxAlias
public String getToolboxAlias()
- Returns the alias of the tool box containing this tool.
- Returns:
- the tool box alias