1

I wondering if something like this is possible. I would like to create a PDF output using a pre-established map template. The tricky part is I want to create maps in batch by adding (what will usually be 2)feature classes as layers to a data frame in the map document. These feature classes have similar names, the only difference is one of the names is preceded by "buffer_". The feature classes will then be symbolized. I am very new to arcpy mapping and seems like this may be possible however, I am stumped as to how to do this. The limited code I have so far (which doesn't run properly) looks as follows:

import arcpy, os, fnmatch

from arcpy import env


mapTemplate = arcpy.mapping.MapDocument(r"template location")
try:
df = arcpy.mapping.ListDataFrames(mapTemplate)[1]
print df
arcpy.env.workspace = r"file geodatabase"
fc = arcpy.ListFeatureClasses()
for fcs in fc:
    name = fcs.getValue().replace("Buffer_","")
    for i in os.listdir("file geodatabase"):
        if fnmatch.fnmatch(i, name):    
            arcpy.MakeFeatureLayer_management(fcs, "fc_layer")
            layer = arcpy.mapping.Layer("fc_layer")
            arcpy.mapping.AddLayer(df, layer + fcs, "AUTO_ARRANGE")
            mapTemplate.save()

except Exception, e:
import traceback, sys
tb = sys.exc_info()[2]
print "Line %i" % tb.tb_lineno
print e.message

I know this is no where close but I am having trouble even using the .getValue statement for the feature classes. Thanks for any suggestions or help you can provide.

1 Answer 1

1

The getValue method belongs to cursors- http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000050000000. That said, you could also try using re.search rather than stripping "Buffer_" if you're including those files in your search anyway. You can retrieve feature class names using describe as well, e.g.

desc = arcpy.Describe(fcs)
name = desc.name

Refer to this documentation as well for exporting to pdf - http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000027000000

Your Answer

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

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