14

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. – Raj Jan 6 '11 at 13:45
  • 1
    @Raj - Oh no, I don't plan on doing that maintaining the maps will be pain – dassouki Jan 6 '11 at 14:14
  • 1
    The linked question is another question that has been answered. So ask a new question describing your problem in detail. – MathiasWestin Jul 24 '11 at 17:11
  • 1
    The 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 Cummins Jul 24 '11 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 Cummins Jul 24 '11 at 18:44
9

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.

http://arcscripts.esri.com/details.asp?dbid=16097

  • That is the closest to what I need, In essence, I have to convert all my symbology to unique value – dassouki Jan 6 '11 at 15:44
  • @ Mapperz - there's a fix for ArcGIS 10 here: forums.arcgis.com/threads/24968-Legend-Limiter-in-Arc-10 – Dano Jul 23 '11 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)/ – Dano Jul 24 '11 at 16:02
  • 3
    Run in Windows compability mode on Windows 7. – Mapperz Jul 25 '11 at 4:00
  • @ 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/… – Dano Jul 25 '11 at 14:09
11

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.

4

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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.