7

How can i access to feature extent of a feature class and change the extent using arcpy ?

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 22, 2015 at 11:30

1 Answer 1

12

You can access the feature extent of a feature class by using the Describe function

import arcpy, os
fc = r'C:\path\to\your.gdb\fc'
desc = arcpy.Describe(fc)
xmin = desc.extent.XMin
xmax = desc.extent.XMax
ymin = desc.extent.YMin
ymax = desc.extent.YMax
print "xmin: %s \nxmax: %s \nymin: %s \nymax: %s" % (xmin, xmax, ymin, ymax)

You can change the output extent in the environment settings (source Esri).

The Output Extent environment setting defines what features or rasters will be processed by a tool. This setting is useful when you need to process only a portion of a larger dataset. You can think of this setting as a rectangle used to select input features and rasters for processing. Any feature or raster that passes through the rectangle will be processed and written to output. Note that the rectangle is used only to select features, not clip them. The extent of the output dataset will typically be larger than the Output Extent setting to account for features that pass through the extent rectangle.

import arcpy
# Set the extent environment using a keyword.
arcpy.env.extent = "MAXOF"
# Set the extent environment using the Extent class.
arcpy.env.extent = arcpy.Extent(-107.0, 38.0, -104.0, 40.0)
# Set the extent environment using a space-delimited string.
arcpy.env.extent = "-107.0 38.0 -104.0 40.0"

If you are referring to changing the actual geometry of a feature class, which may subsequently alter the extent, then your best is to use a Cursor.

answered Aug 22, 2015 at 12:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.