Compute Pansharpen Weights (Data Management)

License Level:BasicStandardAdvanced

Summary

Calculates an optimal set of pan-sharpened weights for new or custom sensor data.

Usage

Syntax

ComputePansharpenWeights_management (in_raster, in_panchromatic_image, {band_indexes})
ParameterExplanationData Type
in_raster

The input multispectral raster.

Mosaic Dataset; Mosaic Layer; Raster Dataset; Raster Layer
in_panchromatic_image

The input panchromatic raster.

Raster Layer
band_indexes
(Optional)

The band order for the pansharpened weights.

If a raster product is used as the in_raster parameter, the band order within the raster product template will be used.

String

Code Sample

ComputePansharpenWeights example 1 (Python window)

This is a Python sample for the ComputePansharpenWeights tool.

import arcpy
arcpy.ComputePansharpenWeights_management(
    "c:/data/rgb.tif", "c:/data/image.tif", "3 2 1 4")
ComputePansharpenWeights example 2 (stand-alone script)

This is a Python script sample for the ComputePansharpenWeights tool.

#Run Compute Pan Sharpen Weights tool using the bands 4,3,2,1 

import arcpy

InMSraster = "C:\\Landsat7\\L71046029_02920050705_MTL.txt\Multispectral" 
InPANraster = "C:\\Landsat7\\L71046029_02920050705_MTL.txt\Panchromatic"
band_index = "3 2 1 5"

arcpy.ComputePansharpenWeights_management(InMSraster, InPANraster, band_index)
ComputePansharpenWeights example 3 (workflow script)

This is a Python script sample to use the ComputePansharpenWeights output in another tool.

#Compute the pansharpening weights and use the results in the 
#create pansharpening tool.

try:
    import arcpy
    
    InRGBraster = "C:\\temp\\rgb.img"
    InPanraster = "C:\\temp\\pan.tif"
    
    #Compute Pan Sharpen Weights  
    out_pan_weight = arcpy.ComputePansharpenWeights_management(
        InRGBraster, InPanraster, "3 2 1 4")
    
    #Get results 
    pansharpen_weights = out_pan_weight.getOutput(0)
    
    #Split the results string for weights of each band
    pansplit = pansharpen_weights.split(";")
    
    #Run the Create pan sharpened raster dataset tool. 
    arcpy.CreatePansharpenedRasterDataset_management(
        InRGBraster, "3", "2", "1", "4", "C:\\temp\\pansharpened_raster.tif",
        InPanraster, "Gram-Schmidt", pansplit[0].split(" ")[1],  
        pansplit[1].split(" ")[1], pansplit[2].split(" ")[1],
        pansplit[3].split(" ")[1])
    
except arcpy.ExecuteError:
    print(arcpy.GetMessages())
except Exception as err:
    print(err[0])

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Yes
ArcGIS for Desktop Standard: Yes
ArcGIS for Desktop Advanced: Yes
5/7/2015