AnsweredAssumed Answered

Comparing Extent of Layer to Extent of Dataframe

Question asked by BrokenLegMike on Mar 20, 2012
Latest reply on Mar 20, 2012 by BrokenLegMike
Hey everyone,

I have a template map I use to create figures for a report. One of the layers in the map always determines the scale of the map. It is a polygon feature class. If the extent of the polygon is so big that the scale is over 1:3000, I need to make a second figure (i.e. instead of having one map to cover the area, if the scale is over 1:3000 the rule is to create a second map and have half of the polygon in Figure 1a and the other half in Figure 1b)

My approach is this:


  1. Set the scale in the map to 1:3000

  2. Read in the extent of the dataframe

  3. Read in the extent of the Layer ("PDA Boundary")

  4. Compare the results. If the extent of the dataframe is bigger than the extent of the layer, then one figure is only needed. If the extent of the dataframe is smaller, than the a second figure needs to be created

My code is (keep in mind that I have a map already set to 1:3000, so I didn't set this in my script yet):

mxd = arcpy.mapping.MapDocument("Z:\test.mxd")  for df in arcpy.mapping.ListDataFrames(mxd):     print df.extent     for lyr in arcpy.mapping.ListLayers(mxd):         if lyr.name == "PDA Boundary":             print lyr.getExtent             # This is my test between the extent of the dataframe and the extent of the layer             if df.extent < lyr.getExtent():                 print "Less Than"             else:                 print "Greater Than" 


The code doesn't seem to work. I've played with the scale in the map so that the polygon fits inside the dataframe and then I set it so that the polygon is bigger than the dataframe and it always returns "Less Than"

Also, I set some print statements to print out the extents. I compared the extent printed from the layer to the one under the source tab in the layers properties dialogue box and they are different. The whole values are the same, but the values after the decimal are different. I'm not sure why this is?

My printed values are:

529979.202902999 6054934.30494232 530433.448547836 6055506.30284459 NaN NaN NaN NaN


My layers dialogue box is here:

[ATTACH=CONFIG]12861[/ATTACH]

Any suggestions?

Thanks,
Mike

Attachments

Outcomes