1

I have a layer in the TOC, with a query on a field. Then in layout view, I insert the table to the layout.

When I change the query the table does not update automatically. Then I double click on the table, and now it is changed manually.

How can I change the table in the layout dynamically when I change the query?

I am using ArcMap 10.8

enter image description here

4
  • This page may help?
    – Hornbydd
    Commented Sep 23, 2023 at 13:28
  • Thank you for your answer ..... but this documention help doesn't fix my problem . Commented Sep 23, 2023 at 13:53
  • Does it update if you click on the refresh button below to the layout?
    – Berend
    Commented Sep 24, 2023 at 20:18
  • No it doesn't , the table is updated manually only when i double click on the table and just see the properties and click ok. Commented Sep 24, 2023 at 20:34

3 Answers 3

1

The dynamic table functionality that you seek is available in ArcGIS Pro as a Table Frame which you can see in Work with a table frame.

It is not available in ArcMap although, with a Production Mapping license, there is something akin to it, which is known as an Interactive Table. You can see them at Creating an interactive table.

Using ArcPy, you can use graphic and text elements to create pseudo-dynamic tables or table-like data frames with both ArcMap and ArcGIS Pro, but I consider that to be an advanced topic.

6
  • As I understand the question, the table does update after a double click. And the TableFrame class holds a reference to the table it is displaying, so it should be possible for it to refresh itself.
    – Berend
    Commented Sep 24, 2023 at 20:12
  • The table is updated manually only when i double click on the table and just see the properties and click ok. Commented Sep 24, 2023 at 20:35
  • Unlike ArcGIS Pro, ArcPy with ArcMap does not provide a TableFrame class.
    – PolyGeo
    Commented Sep 24, 2023 at 21:50
  • But someone here told my this answer ...Using ArcPy, you can use graphic and text elements to create pseudo-dynamic tables or table-like data frames with both ArcMap and ArcGIS Pro, but I consider that to be an advanced topic. .... it means that i can use ArcMap to solve my problem through python script - ArcPy Commented Sep 25, 2023 at 4:46
  • 1
    They are not using a TableFrame class and therefore are not truly dynamic.
    – PolyGeo
    Commented Sep 25, 2023 at 6:49
1

My preference is using 2nd dataframe, but this script will also work for basic tables. Just insert picture element and call it "myTABLE":

import matplotlib.pyplot as plt
import pandas as pd
# play with this
plt.figure(figsize=(8,1))
sourceFile = "f:/scratch/table.png"
tbl=arcpy.da.TableToNumPyArray("subc_5ha",("GRIDCODE","Shape_Area","SUBC_NAME","HA"))

df = pd.DataFrame(tbl)
data =  df.values
plt.axis("off")
plt.table(cellText=data, colLabels=df.columns, loc="center",fontsize=8)
plt.savefig(sourceFile)
plt.close()
mxd = arcpy.mapping.MapDocument("CURRENT")
for elm in arcpy.mapping.ListLayoutElements(mxd, "PICTURE_ELEMENT"):
    if elm.name == "myTABLE":
        try:elm.sourceImage = ""
        except: elm.sourceImage = sourceFile

Before: enter image description here

After:

enter image description here

Script converts table to png raster/image and replaces source of the picture in existing picture. To make it work you need to change 3 lines of code:

plt.figure(figsize=(8,1))

these are dimensions (width =8', height = 1') of your table image.

sourceFile = "f:/scratch/table.png"

this is name of the image on disk.

tbl=arcpy.da.TableToNumPyArray("subc_5ha",("GRIDCODE","Shape_Area","SUBC_NAME","HA"))

first parameter here (subc_5ha) is name of the layer in the current mxd table of content, followed by list of fields (GRIDCODE,..HA) that you'd like to show. No Shape field though.

Add picture element to your layout and name it 'myTABLE':

enter image description here

Attach script to custom tool or run it from Python window. Check if table fits into element. If not modify figsize in line 1.

UPDATE:

It seems that using text element and prettytable Python module produces much nicer output:

enter image description here

Unfortunately ArcGis 10.8 doesn't want to work directly with that module, so workflow involves call to tiny external script. If of interest I can post it.

3
  • Can you explain to me what should i do with more details. Commented Sep 29, 2023 at 10:47
  • That's a nifty way of creating a table using the matplotlib then getting ArcMap to embed it into a layout! Never used matplotlib but if others want to explore this approach here is a useful blog on creating tables and saving them as a graphic.
    – Hornbydd
    Commented Sep 30, 2023 at 16:29
  • It's a mighty tool especially in combination with DDP gis.stackexchange.com/questions/181390/…
    – FelixIP
    Commented Sep 30, 2023 at 19:14
0

This seems to be a refresh issue of the table layout element. I don't know if this is by design.

I haven't found a way to automatically refresh the table, so you must do one of the following:

  • Click the Refresh button below the layout: Refresh button. But it looks as if this doesn't always work.
  • Right click on the table element, select Properties (Or just double click) and click OK or Apply
  • Close and reopen the mxd
  • There may be other options...
1
  • The same result for me , nothing change the table automatically when i change the query for the layer. Commented Sep 26, 2023 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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