Create polygon / fc from map extent

13212
16
11-21-2011 08:22 AM
MatthiasAbele
New Contributor II
Hallo,

there are several topics on different forums concerning this matter, but
I haven't found a hint how to this in ArcGIS 10.

Do you have an idea or a code snippet?

Thanx,

Matthias
Tags (2)
0 Kudos
16 Replies
DarrenWiens2
MVP Honored Contributor

In most cases (mutually exclusive index features), you could use Spatial Join for this but not necessarily for more complex cases (e.g. coincident or overlapping index features).

0 Kudos
WesMiller
Regular Contributor III

I was thinking you could use Match Option HAVE_THEIR_CENTER_IN and get the desired results.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Yes, that would work most of the time, although some index features may not cover the center of the map extent, and the center of some map extents may cover multiple index features. Whether or not that matters would depend on why you wanted to know which feature produced which map extent, or if any would do.

0 Kudos
CraigPrisland1
New Contributor II

I initially used the Spatial Join geoprocessing tool using the matching option HAVE_THEIR_CENTER_IN, however as Darren eluded to, some index features do not cover the center of the map extent while several others cover multiple index features.  The CONTAINS option works similar as well, however there are several index features contained in each map extent so there will be a large amount of manual QC involved by going this route.

0 Kudos
CraigPrisland1
New Contributor II

I have found a workaround to incorporate the attributes into the Polygon_Extent output from the index layer from Data Driven Pages by first sorting my map in ascending alphabetical order and then running the script.  The polygons are then created in order.  By using the FID field, I can then join it with the index layer when I create a temporary field in that layer and add ascending values into this field.

I did have one other question to see if this is feasible.  My map pages have an engineering scale tied to each page (i.e 1" = 210') using the following expression in the text:

SCALE: 1" = <dyn type="dataFrame" name="DataFrameName"

property="scale" pageUnits="in" mapUnits="ft" pageValue="1"

decimalPlaces="0"/>'

Would it be possible to get this value into the Polygon_Extent output file as well?

Thanks again for your assistance.

0 Kudos
DarrenWiens2
MVP Honored Contributor

I believe you can grab the scale inside the loop, once you've got your dataframe object, using:

scale = dataframe.scale

This will return an absolute scale for the dataframe, like 5000 would equal a scale of 1:5000. You could then do some math to calculate how many feet would equal one inch. For example:

scale = dataframe.scale # e.g. 5000
engScale = '1 inch = ' + int(scale/12) + ' feet' # returns "1 inch = 417 feet"

You can escape quotes inside the string, but that's an extra step for me.

0 Kudos
AmbroseClarke
Esri Contributor

Old thread I know - but there is now an easy way in case anyone searching...

arcpy.Extent has a polygon property that neatly returns the extent as a polygon

ex  = extent.polygon‍