Extract by Circle (Spatial Analyst)

Available with Spatial Analyst license.

Summary

Extracts the cells of a raster based on a circle by specifying the circle's center and radius.

Illustration

Extract by Circle illustration
OutRas = ExtractByCircle(InRas1, Point(2.5,2.5), 2, "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), all bands will be used.

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

    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.

  • The center of the cell is used to determine whether a cell is inside or outside a circle. If the center is within the arc of the circle, the cell is considered fully inside even if portions of the cell fall outside the circle.

  • 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.

Syntax

ExtractByCircle(in_raster, center_point, radius, {extraction_area})
ParameterExplanationData Type
in_raster

The input raster from which cells will be extracted.

Raster Layer
center_point

The Point class dictates the center coordinate (x,y) of the circle defining the area to be extracted.

The form of the class is:

  • Point (x, y)

The coordinates are specified in the same map units as the input raster.

Point
radius

Radius of the circle defining the area to be extracted.

The radius is specified in map units and is in the same units as the input raster.

Double
extraction_area
(Optional)

Identifies whether to extract cells inside or outside the input circle.

  • INSIDEA keyword specifying that the cells inside the input circle should be selected and written to the output raster. All cells outside the circle will receive NoData values on the output raster.
  • OUTSIDEA keyword specifying that the cells outside the input circle should be selected and written to the output raster. All cells inside the circle will receive NoData values on 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

ExtractByCircle example 1 (Python window)

This example extracts cells within a 500-meter radius around a point location.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outExtCircle = ExtractByCircle("elevation", arcpy.Point(482838.823, 222128.982),
                                500, "INSIDE")
outExtCircle.save("c:/sapyexamples/output/extcircle")
ExtractByCircle example 2 (stand-alone script)

This example extracts cells within a 1,000-meter radius around a point location.

# Name: ExtractByCircle_Ex_02.py
# Description: Extracts the cells of a raster based on a circle.
# 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 = ("elevation")
centerPoint = arcpy.Point(482838.823, 222128.982)
circRadius = 1000
extractType = "INSIDE"

# Execute ExtractByCircle
outExtCircle = ExtractByCircle(inRaster, centerPoint, circRadius, 
                               extractType)

# Save the output 
outExtCircle.save("c:/sapyexamples/output/extcircle02")

Licensing information

  • Basic: Requires Spatial Analyst
  • Standard: Requires Spatial Analyst
  • Advanced: Requires Spatial Analyst

Related topics