[GIS] Using ArcPy to run Report Layout File (RLF) report and add to layout (for Data Driven Pages)

arcgis-10.1arcgis-desktoparcpydata-driven-pagesreports

I currently have a data driven page template set up which I manually cycle through and for each page run a Report Layout File (RLF) report and then add this to the ArcMap layout. The added element is then positioned on the legend to give additional data to the map user. The RLF draws it's data from the attribute table of a map layer that is not the DDP index layer.

I now want to automate the production of these maps. I have no problem with the scripting for the data driven page and exporting side of things, but not sure how to go about adding the report for each page before exporting.

Can anyone suggest if there is a way to do this?

I looked at arcpy.mapping.ExportReport but couldn't see how this works with bringing them back into the mxd and positioning them? It seems to be more for exporting standalone reports to later add to a book. Also the outputs were not quite the same as what the run report option within Arcmap produces, which is perfectly aligned to the size I need. They were either the wrong size, layout, or quality.

I also considered adding tables as is described here but don't want the grid lines to show.

Best Answer

I think you should put Data Driven Pages (DDP) to one side for now, because if that introduces any limitations to an application like this, they can usually be overcome by using a SearchCursor to iterate through the feature class that would have been your DDP index.

The key thing will be whether you can get ArcPy to run arcpy.mapping.ExportReport to run your pre-authored RLF file to create a TIF image that you can use as the source for a Picture Element on your layout.

The PictureElement object has a sourceImage property that allows you to read or modify the picture source location. If you plan on replacing a picture with pictures of different sizes and aspect ratios, author the map document with a picture that has a height and width set that represents the complete area you want all other pictures to occupy on the page layout. When a picture is replaced using the sourceImage property and has a different aspect ratio, it will be fit to the area of the original picture using the longest dimension. Replaced pictures will never be larger than the original authored size. You will also want to set the anchor position so that all new pictures are fit relative to that location. If you don't want pictures to be skewed, make sure the Preserve Aspect Ratio option is checked.

Once you can do this the remainder is relatively straightforward without DDP, and may or may not be possible with it.

Related Question