# This tool will build two scout maps based on Quarter section location and add a title and job number #import resources import sys import platform import imp print "Importing arcpy... this may take a moment\n" import arcpy print "START" #Map that the scout maps will be based on mxd = arcpy.mapping.MapDocument("C:\GIS_Data\ScoutMap.mxd") #Selecting the data frame df = arcpy.mapping.ListDataFrames(mxd)[0] # QUARTERS is what the map will use to zoom to the location QUART = arcpy.mapping.ListLayers(mxd, "QUARTERS", df)[0] zoomlayer = QUART # setting the location based on user input. the format must be correct print "Enter location of scout map. Must be like the following:NE Sec-03 Twp-012 Rge-15 Mer-4" subject = raw_input() zoomed = "DESCRIPTOR = '%s'" % subject #prompting for title of the map, will except and string. print " What would you like this map to be called? " name = raw_input() # uses job number for the title of the mamp as well as in the layout print " What is the job number? " jobnum = raw_input() print "building map from template,please wait" # print5 and print20 are used to show the scale of the map in the pdf title print5 = jobnum + '-5' print20 = jobnum + '-20' #rotangle = 30 #selects and zooms to the quarter section based on user imput arcpy.SelectLayerByAttribute_management(QUART, "NEW_SELECTION", zoomed) df.panToExtent(zoomlayer.getSelectedExtent()) #changes text elements in the map and adds the new titles ect. for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.text == "Location": elm.text = subject #print "2" for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.text == "Name of Site": elm.text = name for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.text == "replace": elm.text = jobnum print rotangle rotangle = "angle" print rotangle #for ang in arcpy.mapping.ListLayers(mxd, "QUARTERS", df)[0] : # arcpy.SelectLayerByAttribute_management(QUART, "NEW_SELECTION", zoomed) # fc = arcpy.mapping.ListLayers(mxd, "QUARTERS", df)[0] # field = 'angle' # rotangle = [row[0] for row in arcpy.da.SearchCursor(fc, field)] #Exports two copies of the map to pdf print "exporting map now" for df in arcpy.mapping.ListDataFrames(mxd): df.rotation = (rotangle) df.scale = 5000 arcpy.mapping.ExportToPDF(mxd, "C:\GIS_Data\%s.pdf" % print5 ) #for df in arcpy.mapping.ListDataFrames(mxd): # df.rotation = rotangle # df.scale = 20000 # arcpy.mapping.ExportToPDF(mxd, "C:\GIS_Data\%s.pdf" % print20 ) print " finished" print "Close this window and find your map in C:\GIS_Data\%s.pdf " % jobnum
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question