Nibble (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

Replaces cells of a raster corresponding to a mask with the values of the nearest neighbors.

Learn more about how Nibble works

Illustration

Nibble illustration
OutRas = Nibble(InRas1, Mask_Ras)

Usage

Syntax

Nibble (in_raster, in_mask_raster, {nibble_values})
ParameterExplanationData Type
in_raster

The input raster that will be nibbled.

It must be of integer type.

Raster Layer
in_mask_raster

The raster used as the mask.

It must be of integer type.

Cells with NoData as their value will be nibbled in the in_raster.

Raster Layer
nibble_values
(Optional)

Keywords defining if NoData values in the in_raster are allowed to nibble into the area defined by the in_mask_raster.

  • ALL_VALUES Specifies that the nearest neighbor value will be used whether it is NoData or another data value in the input raster. NoData values in the input raster are free to nibble into areas defined in the mask if they are the nearest neighbor.
  • DATA_ONLYSpecifies that only data values are free to nibble into areas defined in the mask raster. NoData values in the input raster are not allowed to nibble into areas defined in the mask raster even if they are the nearest neighbor.
Boolean

Return Value

NameExplanationData Type
out_raster

The output nibbled raster.

The identified input cells will be replaced with the values of their nearest neighbors.

Raster

Code Sample

Nibble example 1 (Python window)

This example replaces cells identified by the mask input with values determined by the nearest neighbors of the input raster.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
nibbleOut = Nibble("land", "snow", "DATA_ONLY")
nibbleOut.save("C:/sapyexamples/output/nibbleout")
Nibble example 2 (stand-alone script)

This example replaces cells identified by the mask input with values determined by the nearest neighbors of the input raster.

# Name: Nibble_Ex_02.py
# Description: Replaces cells of a raster corresponding to a mask 
#              with the values of the nearest neighbors.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster = "land"
inMask = "snow"

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute Nibble
nibbleOut = Nibble(inRaster, inMask, "ALL_VALUES")

# Save the output 
nibbleOut.save("C:/sapyexamples/output/outnibble")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst
4/10/2014