Lookup (Spatial Analyst)
Summary
Creates a new raster by looking up values found in another field in the table of the input raster.
Usage
-
If the lookup field is a numeric type, the values of that field will be written to the output raster attribute table as Value. Other items in the input raster attribute table will not be transferred to the output raster attribute table.
For example, an attribute table of input raster with numeric field Attr1:
Value Count Attr1 1 294 1 2 345 8 3 654 3Output attribute table from Lookup on Attr1 field:
Value Count 1 294 3 654 8 345 -
If the lookup field is a character type, the lookup field will appear in the output raster attribute table, and the value field will be the same as for input raster. Any other items in the input raster's attribute table will not be transferred to the output raster's attribute table.
For example, an attribute table of input raster with character field Text1:
Value Count Attr1 Text1 1 294 1 A 2 6218 8 B 3 28 3 4 3603 9 3Output attribute table from Lookup on Text1 field:
Value Count Text1 1 294 A 2 6218 B 3 28 4 3603 3
Syntax
| Parameter | Explanation | Data Type |
in_raster |
The input raster that contains a field from which to create a new raster. | Raster Layer |
lookup_field |
Field containing the values for the new raster. | Field |
Return Value
| Name | Explanation | Data Type |
| out_raster |
The output reclassified raster. | Raster |
Code Sample
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")
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
# Author: ESRI
# 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")