Using ArcGIS Desktop, is there a way for the legend, to only show the subitems that are displayed on the map?
-
Did you try converting the legend into graphics? After converting into graphics you can manually delete the items in legend that you do not need. I hope that helps. Thanks.– RajCommented Jan 6, 2011 at 13:45
-
1@Raj - Oh no, I don't plan on doing that maintaining the maps will be pain– dassoukiCommented Jan 6, 2011 at 14:14
-
1The linked question is another question that has been answered. So ask a new question describing your problem in detail.– MathiasWestinCommented Jul 24, 2011 at 17:11
-
1The old question is tagged arcgis 9.3, so you should be OK asking a new question and tagging for ArcGIS 10. Also, the linked question is an answer and you are asking a troubleshooting question for legend limiter.– Jay CumminsCommented Jul 24, 2011 at 18:40
-
Also, troubleshooting questions can take some time to get traction and you should work to try and keep the question body organized with new information so that it's easy to follow. Or else other users will look it and move along to the next question.– Jay CumminsCommented Jul 24, 2011 at 18:44
4 Answers
There is no need to write any additional ArcPy for this. Simply use dynamic legends (which were added at ArcGIS 10.1) when you are authoring your maps.
The Map Extent Options allow you to control how eligible legend items interact with the current map extent. If the Only show classes that are visible in the current map extent check box is checked, a legend item class will only appear in the legend if a feature from that class is in the current extent. If no features from that legend item are in the current extent, the entire item will be removed from the legend.
Legend Limiter
The Legend Limiter only works on layers that use "unique value categories" to define symbology. This style of legend can be set up in the Symbology tab of the Layer Properties dialog. Legend Limiter will not limit the symbology of layers set up with single symbol symbology.
-
That is the closest to what I need, In essence, I have to convert all my symbology to unique value– dassoukiCommented Jan 6, 2011 at 15:44
-
@ Mapperz - there's a fix for ArcGIS 10 here: forums.arcgis.com/threads/24968-Legend-Limiter-in-Arc-10– DanoCommented Jul 23, 2011 at 15:04
-
@ Mapperz (or anyone) - I downloaded the necessary files fo Legend Limiter at the link I posted above. When trying to install, I received an error message, which I googled. I get the impression that there's no patch in existence making this add-on compatible with both ArcGIS 10 and Windows 7. On this thread, should I start a new question related to this topic? Or .... is anyone aware of a patch meeting both parameters (Arc 10 & Windows 7)/– DanoCommented Jul 24, 2011 at 16:02
-
3
-
@ Mapperz - can you post this answer so I can select it as the answer. My question on this problem is here: gis.stackexchange.com/questions/12609/…– DanoCommented Jul 25, 2011 at 14:09
In the map view, right-click on the Legend to open the Properties window, then click the "Items" tab. Under "Map Extent Options", select "Only show classes that are visible in the current map extent".
It'll refresh as you move around the map or toggle on/off classes within the layer.
-
This seems to be the same as another answer posted a year earlier.– PolyGeo ♦Commented Sep 19, 2016 at 1:08
-
Thanks for being specific about where the checkbox was hiding!– JMersCommented May 13, 2019 at 18:35
i think this code will help:
import arcpy
import arcpy.mapping
import os
import sys
from arcpy import env
import string
env.workspace = r"C:\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"C:\Project\\" + mxdname)
legend = arcpy.mapping.ListLayoutElements(mxd,"LEGEND_ELEMENT")[0]
for lyr in legend.listLegendItemLayers():
legend.updateItem(lyr, use_visible_extent = True)
print 'updateItem'
mxd.save()
del mxd