com.esri.arcgis.geoprocessing.tools.spatialanalysttools
Class ZonalStatistics
java.lang.Object
com.esri.arcgis.geoprocessing.AbstractGPTool
com.esri.arcgis.geoprocessing.tools.spatialanalysttools.ZonalStatistics
- All Implemented Interfaces:
- GPTool
public class ZonalStatistics
- extends AbstractGPTool
Calculates statistics on values of a raster within the zones of another dataset.
The Zonal Statistics tool is contained in the Spatial Analyst Tools tool box.
Usage tips:
- A zone is defined as all areas in the input that have the same value. The areas do not have to be contiguous. Both raster and feature datasets can be used for the zone input.
- 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 the coarser input rasters to the resolution of the finer input raster, or set the to Minimum Of Inputs in the Raster Analysis .
- 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 to create one.
- If the zone input is a 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 or , (, and . Generate an attribute table for it as described in the previous tip 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 with the appropriate feature-to-raster conversion tool 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 the zonal operation 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 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 floating-point type, the zonal calculations for majority, median, minority, and variety will not be computed.
- For majority and minority calculations, when there is a tie, the output for the zone is based on the lowest of the tied values.
- The data type of the output is dependent on the zonal calculation being performed and the input value raster type. See for more information.
Constructor Summary |
ZonalStatistics()
Creates the Zonal Statistics tool with defaults. |
ZonalStatistics(java.lang.Object inZoneData,
java.lang.Object zoneField,
java.lang.Object inValueRaster,
java.lang.Object outRaster)
Creates the Zonal Statistics tool with the required parameters. |
Method Summary |
java.lang.String |
getIgnoreNodata()
Returns the Ignore NoData in calculations parameter of this tool . |
java.lang.Object |
getInValueRaster()
Returns the Input value raster parameter of this tool . |
java.lang.Object |
getInZoneData()
Returns the Input raster or feature zone data parameter of this tool . |
java.lang.Object |
getOutRaster()
Returns the Output raster parameter of this tool . |
java.lang.String |
getStatisticsType()
Returns the Statistics type parameter of this tool . |
java.lang.String |
getToolboxAlias()
Returns the alias of the tool box containing this tool. |
java.lang.String |
getToolboxName()
Returns the name of the tool box containing this tool. |
java.lang.String |
getToolName()
Returns the name of this tool. |
java.lang.Object |
getZoneField()
Returns the Zone field parameter of this tool . |
void |
setIgnoreNodata(java.lang.String ignoreNodata)
Sets the Ignore NoData in calculations parameter of this tool . |
void |
setInValueRaster(java.lang.Object inValueRaster)
Sets the Input value raster parameter of this tool . |
void |
setInZoneData(java.lang.Object inZoneData)
Sets the Input raster or feature zone data parameter of this tool . |
void |
setOutRaster(java.lang.Object outRaster)
Sets the Output raster parameter of this tool . |
void |
setStatisticsType(java.lang.String statisticsType)
Sets the Statistics type parameter of this tool . |
void |
setZoneField(java.lang.Object zoneField)
Sets the Zone field parameter of this tool . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ZonalStatistics
public ZonalStatistics()
- Creates the Zonal Statistics tool with defaults.
Initializes the array of tool parameters with the default values specified when the tool was created.
ZonalStatistics
public ZonalStatistics(java.lang.Object inZoneData,
java.lang.Object zoneField,
java.lang.Object inValueRaster,
java.lang.Object outRaster)
- Creates the Zonal Statistics 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
- dataset that defines the zones. the zones can be defined by an integer raster or a polygon feature layer.zoneField
- field that holds the values that define each zone. it can be an integer or a string field of the zone dataset.inValueRaster
- raster that contains the values on which to calculate a statistic.outRaster
- the output zonal statistics raster.
getInZoneData
public java.lang.Object getInZoneData()
- Returns the Input raster or feature zone data parameter of this tool .
This parameter is dataset that defines the zones. the zones can be defined by an integer raster or a polygon feature layer.
This is a required parameter.
- Returns:
- the Input raster or feature zone data
setInZoneData
public void setInZoneData(java.lang.Object inZoneData)
- Sets the Input raster or feature zone data parameter of this tool .
This parameter is dataset that defines the zones. the zones can be defined by an integer raster or a polygon feature layer.
This is a required parameter.
- Parameters:
inZoneData
- dataset that defines the zones. the zones can be defined by an integer raster or a polygon feature layer.
getZoneField
public java.lang.Object getZoneField()
- Returns the Zone field parameter of this tool .
This parameter is field that holds the values that define each zone. it can be an integer or a string field of the zone dataset.
This is a required parameter.
- Returns:
- the Zone field
setZoneField
public void setZoneField(java.lang.Object zoneField)
- Sets the Zone field parameter of this tool .
This parameter is field that holds the values that define each zone. it can be an integer or a string field of the zone dataset.
This is a required parameter.
- Parameters:
zoneField
- field that holds the values that define each zone. it can be an integer or a string field of the zone dataset.
getInValueRaster
public java.lang.Object getInValueRaster()
- Returns the Input value raster parameter of this tool .
This parameter is raster that contains the values on which to calculate a statistic.
This is a required parameter.
- Returns:
- the Input value raster
setInValueRaster
public void setInValueRaster(java.lang.Object inValueRaster)
- Sets the Input value raster parameter of this tool .
This parameter is raster that contains the values on which to calculate a statistic.
This is a required parameter.
- Parameters:
inValueRaster
- raster that contains the values on which to calculate a statistic.
getOutRaster
public java.lang.Object getOutRaster()
- Returns the Output raster parameter of this tool .
This parameter is the output zonal statistics raster.
This is a required parameter.
- Returns:
- the Output raster
setOutRaster
public void setOutRaster(java.lang.Object outRaster)
- Sets the Output raster parameter of this tool .
This parameter is the output zonal statistics raster.
This is a required parameter.
- Parameters:
outRaster
- the output zonal statistics raster.
getStatisticsType
public java.lang.String getStatisticsType()
- Returns the Statistics type parameter of this tool .
This parameter is statistic type to be calculated.
This is an optional parameter.
- Returns:
- the Statistics type
setStatisticsType
public void setStatisticsType(java.lang.String statisticsType)
- Sets the Statistics type parameter of this tool .
This parameter is statistic type to be calculated.
This is an optional parameter.
- Parameters:
statisticsType
- statistic type to be calculated.
getIgnoreNodata
public java.lang.String getIgnoreNodata()
- Returns the Ignore NoData in calculations parameter of this tool .
This parameter is denotes whether NoData values in 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(java.lang.String ignoreNodata)
- Sets the Ignore NoData in calculations parameter of this tool .
This parameter is denotes whether NoData values in the Value input will influence the results of the zone that they fall within.
This is an optional parameter.
- Parameters:
ignoreNodata
- denotes whether NoData values in the Value input will influence the results of the zone that they fall within.
getToolName
public java.lang.String getToolName()
- Returns the name of this tool.
- Returns:
- the tool name
getToolboxName
public java.lang.String getToolboxName()
- Returns the name of the tool box containing this tool.
- Returns:
- the tool box name
getToolboxAlias
public java.lang.String getToolboxAlias()
- Returns the alias of the tool box containing this tool.
- Returns:
- the tool box alias