5

I'm trying to figure out how to set my output extent before creating Thiessen Polygons in a loop of ~100 points shapefile. (ArcMap 10.0 - Python)

for i in range(3,51,1):
    arcpy.CreateThiessenPolygons_analysis("AVF%i" % i,"AVF%iVoronoi" % i,"ONLY_FID")

Basically I want my extent to be the same for each iteration.

I first found:

arcpy.Extent(293490,5898230,316430,5930230)

then someone told me about this ESRI help page:

#use 'CURRENT' if running from ArcMap, when published use MXD on disk

    mxd = arcpy.mapping.MapDocument("CURRENT")

    df = arcpy.mapping.ListDataFrames(mxd)[0]
    newExtent = df.extent
    newExtent.XMin, newExtent.YMin = 293490,5898230
    newExtent.XMax, newExtent.YMax = 316430,5930230
    df.extent = newExtent

but in any case, when I run my loop, the size of the output is not reflecting the changes.

ps: https://stackoverflow.com/questions/8996965/output-extent-environment-setting/8997122#8997122

8

I think you are just creating an Extent object with:

arcpy.Extent(293490,5898230,316430,5930230)

...but not actually setting the arcpy.env.extent property (unless you have more code that is not posted in your original question). From the docs:

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)  # <-- Have you tried this?

# Set the extent environment using a space-delimited string.
arcpy.env.extent = "-107.0 38.0 -104.0 40.0"

Try setting it like:

arcpy.env.extent = arcpy.Extent(293490,5898230,316430,5930230)
  • Hi, thanks it works perfectly ! import arcpy mxd = arcpy.mapping.MapDocument("C:/Users/nlec002/Documents/ArcGIS/Voronoi/AVFVoronoi.mxd") for i in range(3,51,1): arcpy.CreateThiessenPolygons_analysis("C:/Users/nlec002/Documents/ArcGIS/Voronoi/AVF%i.shp" % i,"C:/Users/nlec002/Documents/ArcGIS/Voronoi/AVF%iVoronoi.shp" % i,"ONLY_FID") arcpy.env.extent = arcpy.Extent(267936,5892195,341661,5940210) – user1166251 Jan 25 '12 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.