Term
arcpy.AddMessage Method - informative message arcpy.AddWarning Method arcpy.AddError Method |
|
Definition
What kind of error messages are there in arcpy? |
|
|
Term
| specific, non specific, licence checking |
|
Definition
|
|
Term
| What kind of error messages are there in arcpy? |
|
Definition
arcpy.AddMessage Method - informative message arcpy.AddWarning Method arcpy.AddError Method |
|
|
Term
|
Definition
| syntax, execution, errors you raise yourself |
|
|
Term
| How does GetMessages work?(index) |
|
Definition
GetMessage(index) Returns a string of all messages from the last geoprocessing tool executed |
|
|
Term
| How does GetMessages work? (severity) |
|
Definition
GetMessages(severity) You can filter messages based on error severity |
|
|
Term
| How does GetMessages work? |
|
Definition
messages only, use 0 warnings only, use 1 errors only, use 2 |
|
|
Term
| How does a try statement work? |
|
Definition
the try clause is executed, if no exception occurs, the except clause is skipped and execution of the try statement is finished.
If an exception occurs during execution of the try clause, the rest of the clause is skipped. If it’s type matches the exception named after the except keyword, the except clause is executed, and then execution continues after the try statement. |
|
|
Term
| How do you check an extension in / out? |
|
Definition
arcpy.CheckExtension() - to see if a license is available to be checked out arcpy.CheckOutExtension() - to retrieve, and lock, a license from the license manager arcpy.CheckInExtension() - to return a license to the license manager |
|
|
Term
| What is an arcpy class? (not python class) |
|
Definition
| It can be used to create objects, often referred to as an instance. SpatialReference and Extent are examples of arcpy classes, arcpy classes are often used as shortcuts to complete a geoprocessing tool parameters. arcpy includes several predefined classes, including SpatialReference, ValueTable, and Point. Once instantiated, its properties and methods may be used. Classes have one or more methods called constructors. A constructor is a method for initializing a new instance of a class. |
|
|
Term
|
Definition
| A piece of code that is called by name and that is associated with an object |
|
|
Term
|
Definition
| A piece of code that is called by name |
|
|
Term
|
Definition
| Collections of data and functions that can be used over and over |
|
|
Term
| How do you return a value for a function? |
|
Definition
def test_value ( number ): if number == 1 : outputs = ' Value is 1 ' return outputs < == ?? else: outputs = ' Value is not 1 ' return outputs < == ??
Test = test_value (3) |
|
|
Term
|
Definition
Collections of data and functions that can be used over and over - capitalized by convention, end line with a colon |
|
|
Term
| How do you create an instance of a Class? |
|
Definition
By assigning a variable name to it. x = MyClass() To apply a function to the new instance, you must use a fully qualified name --instance.method() x.hello() If the method takes an argument, be sure to include all needed values. x.math(2,4) |
|
|
Term
| What can you do with the arcpy.mapping module? |
|
Definition
Allows you to open and manipulate ArcMap map documents (.mxd) and layer files (.lyr). You can open map documents and layers; query and alter the contents; and print, export, or save a modified document. Allows for more than just batch processing manipulate maps, layouts, and layers through Python scripting Managing map documents and layers Printing, exporting, map automation and creation of map books Publication to ArcGIS Server |
|
|
Term
| How can you get a list of dataframes for selection? |
|
Definition
| The line of code below gets a python list. [0] gets the first data frame in the python list it finds that has Transportation in the name. |
|
|
Term
| If you have 3 data frames that have the word Transportation in it, it would grab the first one in the list. |
|
Definition
| df = arcpy.mapping.ListDataFrames(mxd, "Transportation*")[0] |
|
|
Term
| If you wanted the 2nd data frame, you would use: |
|
Definition
| df = arcpy.mapping.ListDataFrames(mxd, "Transportation*")[1] |
|
|
Term
| If you wanted "Transportation" only. An alternate approach: |
|
Definition
for df in arcpy.mapping.ListDataFrames(mxd): if df.name == "Transportation": do something |
|
|
Term
Code example from exam review: import arcpy mxd = arcpy.mapping.MapDocument(ïnput.mxd”) df = arcpy.mapping.ListDataFrames(mxd) df.scale = 24000 df.rotation = 2.7 for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == “landuse”: lyr.visible = True lyr.showLabels = True lyr.saveACopy(“output.lyr”) mxd.save() del mxd
-What is the name of the mxd? |
|
Definition
|
|
Term
Code example from exam review: import arcpy mxd = arcpy.mapping.MapDocument(ïnput.mxd”) df = arcpy.mapping.ListDataFrames(mxd) df.scale = 24000 df.rotation = 2.7 for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == “landuse”: lyr.visible = True lyr.showLabels = True lyr.saveACopy(“output.lyr”) mxd.save() del mxd
-What does the “for” loop do? |
|
Definition
| “Checks for layer called landuse then turns on labels and visibility then saves a copy to output.lyr” |
|
|
Term
Code example from exam review: import arcpy mxd = arcpy.mapping.MapDocument(ïnput.mxd”) df = arcpy.mapping.ListDataFrames(mxd) df.scale = 24000 df.rotation = 2.7 for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == “landuse”: lyr.visible = True lyr.showLabels = True lyr.saveACopy(“output.lyr”) mxd.save() del mxd
-What does “del” do? |
|
Definition
| “Releases memory storage of mxd” |
|
|
Term
| When can you use “CURRENT” in arcpy.mapping? |
|
Definition
| when you are working with ArcMap session only |
|
|
Term
| When you update some Map Frame parameters in arcpy, will the changes appear automatically? |
|
Definition
“No, you need to update/refresh the screen: arcpy.RefreshActiveView() arcpy.RefreshContents() |
|
|
Term
| What is the purpose of [0]? |
|
Definition
to get the first list element from the list generated by ListDataFrames: df = arcpy.mapping.ListDataFrames(MXD)[0] |
|
|
Term
|
Definition
-always the first function / method -is a constructor, it runs when an instance of a class is created |
|
|
Term
| What is a widget in Tkinter? |
|
Definition
| Widgets include things like windows, buttons, menus, menu items, drop-down lists, scroll bars |
|
|
Term
| What is an event handler in Tkinter? |
|
Definition
| - Routine that does the work of the GUI... or a callback routine that handles input received in a script
- code executed when an event occurs - binding associates this event handler with a widget.
events include:
etc. |
|
|
Term
| What is the purpose of packing? |
|
Definition
| To orientate button placement. The default is to "pack" buttons (widgets) one above the other Packing options are LEFT, RIGHT, TOP, and BOTTOM |
|
|
Term
| What is the difference between button and Button? |
|
Definition
| button is the "name" of the widget. Variable definition |
|
|
Term
| What is the difference between button and Button? |
|
Definition
| Button is a standard Tkinter class |
|
|
Term
| How do you define a global variable? |
|
Definition
| variable that can be pulled and used by different functions and methods |
|
|
Term
| What are different ways of assigning parameters to a button? |
|
Definition
self.button1 = Button(self.myContainer) self.button1["text"] = "Hello World!" self.button1["background"] = "green" self.button1.pack() |
|
|
Term
| What are different ways of assigning parameters to a button? |
|
Definition
self.button2 = Button(self.myContainer) self.button2.configure(text="Off to join the circus!") self.button2.configure(background="tan") self.button2.pack() |
|
|
Term
| What are different ways of assigning parameters to a button? |
|
Definition
self.button3 = Button(self.myContainer) self.button3.configure(text="Join me?", background="cyan") self.button3.pack() |
|
|
Term
| What are different ways of assigning parameters to a button? |
|
Definition
self.button4 = Button(self.myContainer1, text="Goodbye!", background="red") self.button4.pack() |
|
|
Term
|
Definition
"Binding" is the process of defining a connection or relationship between: a widget, an event, an "event handler" Events that can be bound: |
|
|
Term
| what are some events that can be bound? |
|
Definition
| The mouse is moved, with mouse button 1 being held down.
Button 1 was released.
Button 1 was double clicked.
The mouse pointer entered the widget
The user pressed the Enter key.
The user pressed any key. |
|
|
Term
|
Definition
The Listbox widget is a standard Tkinter widget used to display a list. A listbox can only contain text items, and all items must have the same font and colour. Depending on the widget configuration, the user can select one or more items from the list. |
|
|
Term
| What are some parameters of a listbox |
|
Definition
parameters: listbox = Listbox(master, selectmode=SINGLE)
SINGLE - (just a single choice. Default mode.) BROWSE (same as SINGLE, but the selection can be moved using the mouse) MULTIPLE (multiple items can be chosen, by clicking on them one at a time) EXTENDED (multiple ranges of items can be chosen, using the Shift + Control keys) |
|
|
Term
| How does a scrollbar work? |
|
Definition
| When the widget view is modified, the widget notifies the scrollbar by calling the set method. And when the user manipulates the scrollbar, the widget’s yview method is called with the appropriate arguments. |
|
|
Term
|
Definition
Used to enter text strings User can only enter one line of text, to enter multiple lines you would have to use the Text widget |
|
|
Term
| How do you apply symbology to a feature class? A tool!!! |
|
Definition
ApplySymbologyFromLayer_management (in_layer, in_symbology_layer) Note: - can only be applied to features of SAME geometry type - Input Layer Field name must be the same as that of the corresponding Symbology Layer Field |
|
|
Term
| What makes a good user interface? |
|
Definition
| Simple, Intuitive, respects common conventions, visually organized, native look |
|
|
Term
|
Definition
| Treats a frame as a table (a grid of rows and columns) |
|
|
Term
|
Definition
Origin of each frame is in upper left corner (0,0) X coordinates increase to the right Y coordinates increase towards the bottom |
|
|
Term
| What are some grid parameters? |
|
Definition
| column, columnspan, ipadx, ipady, padx, pady, row, rowspan, sticky |
|
|
Term
| What are sticky parameters and how do they work? |
|
Definition
Cardinal Directions (i.e. N, S, E, W, NE, etc) Can combine directions i.e. N + S → stretches widget out vertically across the cell i.e. E + W → stretches widget out horizontally across the cell |
|
|
Term
| Assigning a title to a Tkinter menu |
|
Definition
define your title in your local variables:
Title = “This is my fabulous whatever-you-wanna-call it”
then below where you make an instance of your root: root = Tk() app.master.title(Title) app.mainloop() |
|
|
Term
| Adding an image (logo) to a Tkinter menu |
|
Definition
PhotoImage(file = f) to place a logo or a full colour image in your frame Import “Photo Imaging Library (PIL)” for more format availability. Will convert automatically to make it Tkinter compatible |
|
|
Term
| What kind of layout elements can you select? |
|
Definition
GraphicElement: groups of elements, inserted tables, graphs LegendElement: MapsurroundElement: North Arrow, scale text, and scale bar TextElement: inserted text, callouts, rectangle text, titles etc PictureElement: a raster or image that has been inserted into a page layout (logo) |
|
|
Term
| What kind of changes can you apply to layout elements? |
|
Definition
- change elem position X/Y (note units are set as inches... so divide by 2.54 for cm) - can change string values of text elements - can add or remove items in the legend (partially through layer management) |
|
|
Term
#This script clips all feature classes in a file geodatabase import arcpy
# Create path variables sourceWorkspace == "C:\\Data\\Lesson2PracticeExercise\\USA.gdb" targetWorkspace == "C:\\Data\\Lesson2PracticeExercise\\Iowa.gdb" clipFeature == "C:\\Data\\Lesson2PracticeExercise\\Iowa.gdb\\Iowa" #all three of the above should only have just ONE =
# Get a list of all feature classes in the USA folder arcpy.env.workspace = SourceWorkspace #should be sourceWorkspace featureClassList = arcpy.ListFeatureClasses()
try: for featureClass in featureClassList # Loop through all USA feature classes outClipFeatureClass = targetWorkspace + "\Iowa" + featureClass # Construct the output path #the above should be “\\Iowa” arcpy.Clip_analysis(featureClass, clipFeature, outClipFeatureClass) # Perform the clip and report what happened
arcpy.AddMessage("Wrote clipped file " + outClipFeatureClass + ". ") except: arcpy.AddError("Could not clip feature classes") # Report if there was an error print arcpy.GetMessages() |
|
Definition
|
|