Dynamic Text

2262
4
05-03-2012 10:30 AM
AaronNotte
New Contributor
Hi, I'm looking to add dynamic text to data driven pages. The text is areas from an attribute table from a polygon feature class that must change with each map layout. I have 180 gravel pits and i need to display each individual area in Hectares on each page. For example map 1 is titled "Pit 1 Site Plan", 2 is "Pit 2 site Plan". Now I need to have the area of site 1 on map 1 and the area of site 2 on map 2 and so on. Can anyone help me out?

Thanks
Tags (2)
0 Kudos
4 Replies
MathewCoyle
Frequent Contributor
You just want to edit the built in dynamic text to display a custom title?

Something like this? Which uses the page number as the Pit title.
Pit <dyn type="page" property="number"/> Site Plan
0 Kudos
AaronNotte
New Contributor
No i have the pit title labeled already. I am looking to have the area of the polygon displayed and then as you click through the dynamic pages i want the area to automatically update to the corrisponding pit being shown.
0 Kudos
MathewCoyle
Frequent Contributor
Oh you mean the shape area of the feature? If you want that as you are working in ArcMap, that would have to be ArcObjects.

You could write a script that does that if you just want it for exporting. I've never tried it with data driven pages before, here's a bit of code to get you on the path.

for page in export_loop:
    layer = "data_driven_layer"
    ddp_field = "Field_Name"
    desc = arcpy.Describe(layer)
    shapeField = desc.shapeFieldName

    where = "%s = '%s'" %(ddp_field,ddp_value)
    s_cursor = arcpy.SearchCursor(layer,where)
    for row in rows:
        page_area = row.getValue(shapeField).area
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
        if elm.name == "Dyn_Area":
            elm.text = page_area


Edit: What Darren said below. My suggestion would be more use accessing other layers attributes based on the current data driven page.
0 Kudos
DarrenWiens2
MVP Honored Contributor
You can access any attribute in your index layer (ie. pits) using the dynamic text: <dyn type="page" property="thefieldname"/>. So, in your case, it would be: <dyn type="page" property="Shape_area"/>

From the help (waaaaay down, in a tip):
With the

dyn type="page"

you can create dynamic text with any attribute field of the Data Driven Pages index layer. For example, if you have an attribute on the index layer named POPULATION, you can create a dynamic text tag using this field,

<dyn type="page" property="POPULATION"/>

to dynamically display the POPULATION values for each page in the layout.

edit: I see now that you want hectares. You'll have to calculate a new field in your index layer for that.
0 Kudos