Build Pyramids And Statistics (Data Management)

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 raster catalog or mosaic dataset.

Usage

Syntax

BuildPyramidsandStatistics_management (in_workspace, {include_subdirectories}, {build_pyramids}, {calculate_statistics}, {build_on_source})
ParameterExplanationData Type
in_workspace

The workspace that contains all the raster datasets to be processed.

Raster catalogs and mosaic datasets must be specified as the input workspace. If the workspace includes a raster catalog or mosaic dataset, then these items will not be included when the tool runs.

Mosaic Dataset; Raster Catalog Layer; Raster Dataset; Workspace
include_subdirectories
(Optional)

Specify whether to include subdirectories.

  • NONEDoes not include subdirectories.
  • INCLUDE_SUBDIRECTORIESIncludes all the raster datasets within the subdirectories when loading. This is the default.

Raster catalogs and mosaic datasets must be specified as the input workspace. If the workspace includes a raster catalog or mosaic dataset, then these items will not be included when the tool runs.

Boolean
build_pyramids
(Optional)

Specify whether to build pyramids.

  • NONEDoes not build pyramids.
  • BUILD_PYRAMIDSBuilds pyramids. This is the default.
Boolean
calculate_statistics
(Optional)

Specify whether to calculate statistics.

  • NONEDoes not calculate statistics.
  • CALCULATE_STATISTICSCalculates statistics. This is the default.
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.

  • NONEStatistics will be calculated for each raster item in the mosaic dataset (on each row in the attribute table). Any functions added to the raster item will be applied before generating the statistics. This is the default.
  • BUILD_ON_SOURCEBuilds pyramids and calculates statistics on the source data of the mosaic dataset.
Boolean

Code Sample

BuildPyramidsandStatistics example 1 (Python window)

This is a Python sample for the BuildPyramidsandStatistics tool.

import arcpy
from arcpy import env
env.workspace = "c:/data"
arcpy.env.pyramid = "PYRAMIDS 3 BILINEAR JPEG"
arcpy.env.rasterStatistics = "STATISTICS 4 6 (0)"
arcpy.BuildPyramidsAndStatistics_management("folder", "INCLUDE_SUBDIRECTORIES",
                                            "BUILD_PYRAMIDS", "CALCULATE_STATISTICS")
BuildPyramidsandStatistics example 2 (stand-alone script)

This is a Python script sample for the BuildPyramidsandStatistics tool.

##====================================
##Build Pyramids and Statistics
##Usage: BuildPyramidsAndStatistics_management in_workspace {INCLUDE_SUBDIRECTORIES
##                                                 | NONE} {BUILD_PYRAMIDS | NONE}
##                                                 {CALCULATE_STATISTICS | NONE}
    
try:
    import arcpy
    arcpy.env.workspace = r"C:/Workspace"

    ##Define parameters for build pyramids and calculate statitics in environment setting
    arcpy.env.pyramid = "PYRAMIDS 3 BILINEAR JPEG"
    arcpy.env.rasterStatistics = "STATISTICS 4 6 (0)"
    
    ##Build pyramids and calculate statistics for all raster in a folder
    arcpy.BuildPyramidsAndStatistics_management("folder", "INCLUDE_SUBDIRECTORIES",
                                                "BUILD_PYRAMIDS", "CALCULATE_STATISTICS")
    
    ##Build pyramids and calculate statistics for all raster in a GDB
    arcpy.BuildPyramidsAndStatistics_management("fgdb.gdb", "INCLUDE_SUBDIRECTORIES",
                                                "BUILD_PYRAMIDS", "CALCULATE_STATISTICS")
    
    ##Build pyramids and calculate statistics for all raster in a Mosaic Dataset
    arcpy.BuildPyramidsAndStatistics_management("fgdb.gdb/md", "INCLUDE_SUBDIRECTORIES",
                                                "BUILD_PYRAMIDS", "CALCULATE_STATISTICS")

except:
    print "Build Pyramids and Statistics example failed."
    print arcpy.GetMessages()

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

10/27/2014