Extract by Points (Spatial Analyst)

Summary

Extracts the cells of a raster based on a set of coordinate points.

Legacy:

This tool is deprecated and will be removed in a future release.

The Extract by Mask tool provides enhanced functionality or performance.

Illustration

Extract by Points illustration
OutRas = ExtractByPoints(InRas1, [Point(1.5,0.5),Point(1.5,4.5),Point(4.5,4.5),Point(4.5,0.5)], "INSIDE")

Usage

  • Additional attributes from the input raster, if any, will be carried over as-is to the output raster attribute table. Depending on the property being recorded, some of the attribute values may need to be recalculated.

  • When a multiband raster is specified as the Input Raster (in_raster in Python) value, all bands will be used.

    To process a selection of bands from a multiband raster, first create a raster dataset composed of those particular bands using the Composite Bands tool. Then use the result as the Input Raster (in_raster in Python) value.

    The default output format is a geodatabase raster. If an Esri Grid stack is specified as the output format, the name of the stack cannot start with a number, use spaces, or be more than nine characters in length.

  • Cell locations that are not selected are assigned a value of NoData.

  • If the input raster is integer, the output raster will be integer. If the input is floating point, the output will be floating point.

  • See Analysis environments and Spatial Analyst for additional details on the geoprocessing environments that apply to this tool.

Parameters

LabelExplanationData Type
Input raster

The input raster from which cells will be extracted.

Raster Layer
Input points

The points where values will be extracted from the raster.

The points are specified as x,y coordinate pairs in the same map units as the input raster.

Point
Extraction area
(Optional)

Identifies whether to extract cells based on the specified point locations (inside) or outside the point locations (outside) .

  • InsideThe cell in which the selected point falls will be written to the output raster. All cells outside the box will receive NoData on the output raster.
  • OutsideThe cells outside the input points should be selected and written to the output raster.
String

Return Value

LabelExplanationData Type
Output raster

The output raster containing the cell values extracted from the input raster.

Raster

ExtractByPoints(in_raster, points, {extraction_area})
NameExplanationData Type
in_raster

The input raster from which cells will be extracted.

Raster Layer
points
[point,...]

A Python list of Point class objects denote the locations where values will be extracted from the raster.

The point objects are specified in a list of x,y coordinate pairs in the same map units as the input raster.

The form of the object is:

  • [point(x1,y1), point(x2,y2),...]
Point
extraction_area
(Optional)

Identifies whether to extract cells based on the specified point locations (inside) or outside the point locations (outside) .

  • INSIDEThe cell in which the selected point falls will be written to the output raster. All cells outside the box will receive NoData on the output raster.
  • OUTSIDEThe cells outside the input points should be selected and written to the output raster.
String

Return Value

NameExplanationData Type
out_raster

The output raster containing the cell values extracted from the input raster.

Raster

Code sample

ExtractByPoints example 1 (Python window)

This example extracts cells from a raster based on the specified point coordinates.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
pointList = [arcpy.Point(743050, 4321275), arcpy.Point(743100, 4321200),
             arcpy.Point(734500,4322000)]
outPointExtract = ExtractByPoints("soil", pointList,"INSIDE")
outPointExtract.save("c:/sapyexamples/output/pntextract")
ExtractByPoints example 2 (stand-alone script)

This example extracts cells from a raster based on the specified point coordinates.

# Name: ExtractByPoints_Ex_02.py
# Description: Extracts the cells of a raster based on a set of points.
# 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 = "soil"
pointList = [arcpy.Point(743050, 4321275), 
             arcpy.Point(743100, 4321200), 
             arcpy.Point(743500, 4322000),
             arcpy.Point(742900, 4321800)]

# Execute ExtractByPoints
outPointExtract = ExtractByPoints("soil", pointList,"INSIDE")

# Save the output 
outPointExtract.save("c:/sapyexamples/output/pntext")

Related topics