Lookup (Spatial Analyst)

License Level:BasicStandardAdvanced

Summary

Creates a new raster by looking up values found in another field in the table of the input raster.

Illustration

Lookup illustration
OutRas = Lookup(InRas1, "Category")

Usage

Syntax

Lookup (in_raster, lookup_field)
ParameterExplanationData Type
in_raster

The input raster that contains a field from which to create a new raster.

Raster Layer
lookup_field

Field containing the desired values for the new raster.

It can be a numeric or string type.

Field

Return Value

NameExplanationData Type
out_raster

The output raster whose values are determined by the specified field of the input raster.

Raster

Code Sample

Lookup example 1 (Python window)

This example creates a new raster determined by the specified field of the input raster.

import arcpy
from arcpy import env  
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outRaster = Lookup("mycity","land_code")
outRaster.save("C:/sapyexamples/output/mylandcode.img")
Lookup example 2 (stand-alone script)

This example creates a new raster determined by the specified field of the input raster.

# Name: lookup_example02.py
# Description: Creates a new raster by looking up values found in another 
#              field in the table of the input raster.
# 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 = "mycity"
lookupField = "land_code"

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

# Execute Lookup
outRaster = Lookup(inRaster, lookupField)

# Save the output 
outRaster.save("C:/sapyexamples/output/mylandcode")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires Spatial Analyst or 3D Analyst
ArcGIS for Desktop Standard: Requires Spatial Analyst or 3D Analyst
ArcGIS for Desktop Advanced: Requires Spatial Analyst or 3D Analyst
11/8/2012