1

Here's the scenario: I have two different data frames in ArcGIS (10.3.1). In both, a dataset is added from an Excel spreadsheet.

In one data frame (call it "Map"), a layer is created from x,y coordinates. In the other data frame (call it "TAS"), it is symbolized from the values of two different elements (think - local coordinates).

There's also a column called "ID" which is a unique ID.

I would love to know if there's any way of making a selection set in one data frame and have it dynamically update with the same selection in the other data frame (preferably two-way communication). So the problem is not only is it separate data frames but separate coordinate systems.

  • If selection is based on attributes, consider data driven pages and definition query. One way – FelixIP Nov 2 '16 at 19:35
  • Unfortunately, users are going to want to use the select features tools, instead of via attributes. – ollyoop Nov 2 '16 at 19:44
  • It is a script, very basic though – FelixIP Nov 2 '16 at 19:55
  • Yes, I was leaning towards a custom tool. Could you please expand on your script comment? – ollyoop Nov 2 '16 at 19:57
1

SCRIPT:

try: arcpy
except: import arcpy
# GET DATAFRAMES AND LAYERS
mxd = arcpy.mapping.MapDocument("CURRENT")
parentFrame=arcpy.mapping.ListDataFrames(mxd,"MAP")[0]
childFrame=arcpy.mapping.ListDataFrames(mxd,"TAS")[0]
parentLayer, childLayer="PARENT","CHILD"
parentLayer=arcpy.mapping.ListLayers(mxd,parentLayer,parentFrame)[0]
childLayer=arcpy.mapping.ListLayers(mxd,childLayer,childFrame)[0]
# CHECK SELECTION IN SOURCE
descParent = arcpy.Describe(parentLayer)
if len(descParent.FIDset)==0:
    descChild = arcpy.Describe(childLayer)
    if len(descChild.FIDset)==0:
        arcpy.AddMessage("No selection found")
        exit()
    else:
        parentLayer, childLayer=childLayer,parentLayer
selectedIDs= [row[0] for row in arcpy.da.TableToNumPyArray(parentLayer,"ID")]
if len(selectedIDs)==0:selectedIDs.append(-1)
# SELECT CHILD
quer='"ID" IN '+str(tuple(selectedIDs))
arcpy.SelectLayerByAttribute_management(childLayer, "NEW_SELECTION", quer)

EXAMPLE: enter image description here

IMPORTANT NOTES:

  • script tested on shapefiles, query syntax is different for features in database
  • I assumed that your ID field is integer, query syntax is different for strings
  • selection in TAS processed only when NO selection found in MAP
  • If you add script to menu item, it will execute immediately without "NO PARAMETERS" window display

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.