Good enhancement. This functionality is not available at 10. However, it is being investigated for a future release - perhaps 10.1. For your records, I will post the NIM tracking number when I have it.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0] for bkmk in arcpy.mapping.ListBookmarks(mxd, data_frame=df): df.extent = bkmk.extent outFile = r"C:\Project\Output\\" + bkmk.name + ".jpg" arcpy.mapping.ExportToJPEG(mxd, outFile, df) del mxd
Here is a help topic sample. If you join the beta community you'll be able to try out so much more of the arcpy.mapping functionality that was added at 10.1.ListBookmarks example 2 Similar to example 1, the following script will loop through each bookmark in the Transportation data frame, set the data frame extent, and export the data frame to a JPEG file.import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0] for bkmk in arcpy.mapping.ListBookmarks(mxd, data_frame=df): df.extent = bkmk.extent outFile = r"C:\Project\Output\\" + bkmk.name + ".jpg" arcpy.mapping.ExportToJPEG(mxd, outFile, df) del mxd
import arcpy, os # The map with the bookmarks mxd = arcpy.mapping.MapDocument(r"C:\Project\BookmarksToFeatures.mxd") # The output feature class to be created - # This feature class will store the bookmarks as features outFC = r'C:\Project\BookmarkFeatures.gdb\Bookmarks' # A template feature class that contains the attribute schema # E.g. a "name" field to store the bookmark name template = r'C:\Project\BookmarkFeatures.gdb\Template' if arcpy.Exists(outFC): arcpy.Delete_management(outFC) arcpy.CreateFeatureclass_management(os.path.dirname(outFC), os.path.basename(outFC), "POLYGON", template, spatial_reference=template) cur = arcpy.da.InsertCursor(outFC, ["SHAPE@", "Name"]) array = arcpy.Array() for bkmk in arcpy.mapping.ListBookmarks(mxd): array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMax)) array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMin)) # To close the polygon, add the first point again array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin)) cur.insertRow([arcpy.Polygon(array), bkmk.name]) array.removeAll()
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.