Extract Values to Points (Spatial Analyst)
Summary
Extracts the cell values of a raster based on a set of point features and records the values in the attribute table of an output feature class.
Usage
All fields from the input point feature class will be included in the output point feature class.
-
The output feature class will have a new field added to it named RASTERVALU.
Note:This field cannot already exist in the attribute table of the input features. If it does, an error will occur. If you wish to keep the original information, before performing Extract Values to Points you can add a new field (for example, RASVAL1) to the attribute table, calculate the values to it, and then delete the original RASTERVALU field.
-
When Extract Values to Points is used on a multiband raster, the RASTERVALU field will contain values from the last band of the input raster. To extract values from multiple rasters or a multiband raster dataset, use the Extract Multi Values To Points tool.
-
For the RASTERVALU field of the attribute table, NoData cells in the value raster will be given a value of -9999.
-
The interpolation option determines how the values will be obtained from the raster. The default option is to use the value at the center of the cell being sampled. The interpolation option will use bilinear interpolation to interpolate a value for the cell center.
-
If the input raster is floating-point type, the resulting output point dataset will only contain attributes from the input feature data and the value of the cell, as determined by the interpolation option.
-
When adding the attributes from the input raster, if the output point feature dataset is a shapefile, there can be no fields in the input raster with a name more than 10 characters in length. If there are, these fields must be renamed before running the tool.
Multipoint datasets are not supported as input.
Syntax
Parameter | Explanation | Data Type |
in_point_features |
The input point features defining the locations from which you want to extract the raster cell values. | Feature Layer |
in_raster |
The raster dataset whose values will be extracted. It can be an integer or floating-point type raster. | Raster Layer |
out_point_features |
The output point feature dataset containing the extracted raster values. | Feature Class |
interpolate_values (Optional) |
Specifies whether or not interpolation will be used.
| Boolean |
add_attributes (Optional) |
Determines if the raster attributes are written to the output point feature dataset.
| Boolean |
Code Sample
This example extracts the cell values from a raster based on locations defined by a point shapefile, and creates an output point feature class of those values.
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
ExtractValuesToPoints("rec_sites.shp", "elevation",
"C:/sapyexamples/output/outValPnts","INTERPOLATE",
"VALUE_ONLY")
This example extracts the cell values from a raster based on locations defined by a point shapefile, and creates an output point shapefile of those values.
# Name: ExtractValuesToPoints_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
inPointFeatures = "rec_sites.shp"
inRaster = "elevation"
outPointFeatures = "C:/sapyexamples/output/extractvaluespts.shp"
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute ExtractValuesToPoints
ExtractValuesToPoints(inPointFeatures, inRaster, outPointFeatures,
"INTERPOLATE", "VALUE_ONLY")