Summary
Traverses a folder structure, building pyramids and calculating statistics for all the raster datasets it contains. It can also build pyramids and calculate statistics for all the items in a mosaic dataset.
Usage
Building pyramids improves the display performance of raster datasets
Calculating statistics allows ArcGIS applications to properly stretch and symbolize raster data for display.
All supported raster formats will be processed.
Raster catalogs and mosaic datasets must be specified as the input workspace. If the workspace includes a raster catalog or mosaic dataset, these items will not be included when the tool runs.
Wavelet compressed raster datasets, such as ECW and MrSID, do not need to have pyramids built. These formats have internal pyramids that are created upon encoding.
Syntax
arcpy.management.BuildPyramidsandStatistics(in_workspace, {include_subdirectories}, {build_pyramids}, {calculate_statistics}, {BUILD_ON_SOURCE}, {block_field}, {estimate_statistics}, {x_skip_factor}, {y_skip_factor}, {ignore_values}, {pyramid_level}, {SKIP_FIRST}, {resample_technique}, {compression_type}, {compression_quality}, {skip_existing}, {where_clause})
Parameter | Explanation | Data Type |
in_workspace | The workspace that contains all the raster datasets to be processed, a mosaic dataset, or a raster catalog. If the workspace includes a raster catalog or mosaic dataset, these items will not be included when the tool runs. | Text File; Mosaic Dataset; Workspace; Raster Catalog Layer; Raster Dataset; Mosaic Layer |
include_subdirectories (Optional) | Specify whether to include subdirectories.
Raster catalogs and mosaic datasets must be specified as the input workspace. If the workspace includes a raster catalog or mosaic dataset, these items will not be included when the tool runs. | Boolean |
build_pyramids (Optional) | Specify whether to build pyramids.
| Boolean |
calculate_statistics (Optional) | Specify whether to calculate statistics.
| Boolean |
BUILD_ON_SOURCE (Optional) | Specify whether to build pyramids and calculate statistics on the source raster datasets, or calculate statistics on the raster items in a mosaic dataset. This option only applies to mosaic datasets.
| Boolean |
block_field (Optional) | The name of the field within a mosaic dataset's attribute table used to identify items that should be considered one item when performing some calculations and operations. | String |
estimate_statistics (Optional) | Specify whether to calculate statistics for the mosaic dataset (not the rasters within it). The statistics are derived from the existing statistics that have been calculated for each raster in the mosaic dataset.
| Boolean |
x_skip_factor (Optional) |
The number of horizontal pixels between samples. A skip factor controls the portion of the raster that is used when calculating the statistics. The input value indicates the horizontal or vertical skip factor, where a value of 1 will use each pixel and a value of 2 will use every second pixel. The skip factor can only range from 1 to the number of columns/rows in the raster. The value must be greater than zero and less than or equal to the number of columns in the raster. The default is 1 or the last skip factor used. | Long |
y_skip_factor (Optional) | The number of vertical pixels between samples. A skip factor controls the portion of the raster that is used when calculating the statistics. The input value indicates the horizontal or vertical skip factor, where a value of 1 will use each pixel and a value of 2 will use every second pixel. The skip factor can only range from 1 to the number of columns/rows in the raster. The value must be greater than zero and less than or equal to the number of rows in the raster. The default is 1 or the last y skip factor used. | Long |
ignore_values [ignore_value,...] (Optional) |
The pixel values that are not to be included in the statistics calculation. The default is no value. | Long |
pyramid_level (Optional) | Choose the number of reduced-resolution dataset layers that will be built. The default value is -1, which will build full pyramids. A value of 0 will result in no pyramid levels. The maximum number of pyramid levels you can specify is 29. Any value of 30 or higher will create a full set of pyramids. | Long |
SKIP_FIRST (Optional) | Choose whether to skip the first pyramid level. Skipping the first level will take up slightly less disk space, but it will slow down performance at these scales.
| Boolean |
resample_technique (Optional) | The resampling technique used to build your pyramids.
| String |
compression_type (Optional) | The compression type to use when building the raster pyramids.
| String |
compression_quality (Optional) | The compression quality to use when pyramids are built with the JPEG compression method. The value must be between 0 and 100. The values closer to 100 will produce a higher-quality image, but the compression ratio will be lower. | Long |
skip_existing (Optional) | Specify whether to calculate statistics only where they are missing, or regenerate them even if they exist.
| Boolean |
where_clause (Optional) | An SQL expression to select raster datasets that will be processed. | SQL Expression |
Derived Output
Name | Explanation | Data Type |
out_workspace | The updated output workspace. | Text File; Workspace; Raster Layer; Mosaic Layer |
Code sample
BuildPyramidsAndStatistics example 1 (Python window)
This is a Python sample for the BuildPyramidsAndStatistics tool.
import arcpy
arcpy.BuildPyramidsAndStatistics_management(
"C:/Workspace", "INCLUDE_SUBDIRECTORIES", "BUILD_PYRAMIDS",
"CALCULATE_STATISTICS","BUILD_ON_SOURCE", "BlockField",
"ESTIMATE_STATISTICS", "10", "10", "0;255", "-1", "NONE",
"BILINEAR", "JPEG", "50", "OVERWRITE")
BuildPyramidsAndStatistics example 2 (stand-alone script)
This is a Python script sample for the BuildPyramidsAndStatistics tool.
#Build pyramids and calculate statistics for all raster in a folder
import arcpy
arcpy.env.workspace = "C:/Workspace"
inws = "folder"
includedir = "INCLUDE_SUBDIRECTORIES"
buildpy = "BUILD_PYRAMIDS"
calcstats = "CALCULATE_STATISTICS"
buildsource = "NONE"
blockfield = "#"
estimatemd = "#"
skipx = "4"
skipy = "6"
ignoreval = "0;255"
pylevel = "3"
skipfirst = "NONE"
resample = "BILINEAR"
compress = "JPEG"
quality = "80"
skipexist = "SKIP_EXISTING"
arcpy.BuildPyramidsAndStatistics_management(
inws, includedir, buildpy, calcstats, buildsource, blockfield,
estimatemd, skipx, skipy, ignoreval, pylevel, skipfirst,
resample, compress, quality, skipexist)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes