Output Extent

08-09-2012 04:27 AM
New Contributor
Hello All,

Is there a way to set the final extent of a map based on one of your outputs in a model?

If so how


0 Kudos
4 Replies
Occasional Contributor III
You need to describe the model output data set.
describeObject = Describe(r"c:\ModelWork.gdb\ModelOutput")

from the describe object you can get the extent object,
extentObject = describeObject.extent

which has the following properties:
XMin, YMin, XMax, YMax, ZMin, ZMax, MMin, MMax
all as double precision numbers.
xMin = extentObject.XMin

It will also give you the corners as point objects.

The dataframe object in the map has an extent object too, which can be set using these values.
If you make a python list of the dataset x and y extent values, such as this:
extent = [xMin, yMin, xMax, yMax],
then you could set the dataframe extent values like this:
##      set extent
df = arcpy.mapping.ListDataFrames(mxd, theFrame)[0]
newExtent = df.extent
newExtent.XMin = extent[0]
newExtent.YMin = extent[1]
newExtent.XMax = extent[2]
newExtent.YMax = extent[3]
df.extent = newExtent
del newExtent

##      set extent a second time - v10 bug workaround
df2 = arcpy.mapping.ListDataFrames(mxd, theFrame)[0]
anotherExtent = df2.extent
anotherExtent.XMin = extent[0]
anotherExtent.YMin = extent[1]
anotherExtent.XMax = extent[2]
anotherExtent.YMax = extent[3]
df2.extent = anotherExtent
del anotherExtent

I set it twice here because there is a bug in version 10.0 that sometimes ignores the code setting the dataframe extent.
0 Kudos
New Contributor
Thanks for the quick reply but you just threw a fastball right by me. 😄

I may need a little more explanation

The model I am making is going to be used as a Geoprocessing service, if this matters.

I have attached an image of an example of a model with the basics of what I am trying to do.

I am hoping to eventually build a widget for a viewer to run this process and would like the output results to be zoomed to.
However I am not entirely sure if this is something that I should do in the model or if this is a parameter for the widget.

So your opinion or any help you could provide would be great.


0 Kudos
New Contributor
Here is the attachment
0 Kudos
Occasional Contributor III
A geoprocessing model does just that: it geo-processes data.
When you talk about "map extents" and "zooming", you are dealing with graphic expressions of data: maps.

It is not entirely clear which you are wanting to obtain as a result: a data set or a map. Your subsquent expalnations raise doubts about my original understanding of your question.

My suggestions pertain to creating a map with map extents matching the extents of the data set output from the geoprocessing  model / script / service. For that, you need to go through the python arcpy.mapping module, and to have set up (at least a rudementary) mxd, so as to compose and output the map.

If, on the other hand, you are using the term " final extent of a map" to mean "extent of a data set", then most of what I wrote is entirely beside the point.
0 Kudos