Data Driven Pages - show legend items only if they are in the map extent

750
3
05-04-2011 05:51 AM
MarkVolz
Occasional Contributor III
Hello,

I am using Data Driven Pages to create a mapbook of several cities within a county.  My legend includes an area of interest layer.  I would like to automatically remove items from the layer if they are not found in the map extent.  For example, I would like to remove the University class from the area of interest layer in the legend if the data driven page does not have a university in the map. 


For Example:

City A
-Airport
-University
-School
-Park

City B
-Airport
-School
-Park

City C
- School
- Park

Thanks
0 Kudos
3 Replies
JeffBarrette
Esri Regular Contributor
This will be one of the new features available with the Legend in 10.1.

Currently, the only way to do it is via ArcObjects development.  It could be done with arcpy.mapping but each feature type would need to be its own layer.  Then you could perform a spatial overlay, determine what is in the extent, and then remove or add the appropriate layers.  You would need to make sure your legend has the setting to automatically update with layer changes.

Jeff
0 Kudos
beckycrosswhite
New Contributor
Do you have an example using arcpy.mapping?
0 Kudos
JeffBarrette
Esri Regular Contributor
Not all in one example but here are two samples that should get you going:

The 4th sample in the DataFrame class help.

The AddLayer or RemoveLayer help samples

If all your layers are already in the MXD, then use the first sample to see if they intersect with the data frame.  If they don't, then remove the layer using those samples.

Jeff
0 Kudos