GEOM 73 - Python Quiz 3

Description

Geography Quiz on GEOM 73 - Python Quiz 3, created by Maggie Samson on 13/04/2019.
Maggie Samson
Quiz by Maggie Samson, updated more than 1 year ago
Maggie Samson
Created by Maggie Samson over 5 years ago
101
2

Resource summary

Question 1

Question
Which cursors of the arcpy.da module can be used to work with geometry objects using SHAPE@?
Answer
  • SearchCursor, UpdateCursor, and InsertCursor
  • InsertCursor only
  • SearchCursor only
  • UpdateCursor only
  • UpdateCursor and InsertCursor

Question 2

Question
Which of the following is not a geometry token in ArcPy?
Answer
  • SHAPE@
  • SHAPE@CENTROID
  • SHAPE@XY
  • SHAPE@LENGTH

Question 3

Question
What is the main reason to use geometry tokens instead of SHAPE@?
Answer
  • Working with the full geometry objects of large datasets can be very slow
  • You only need SHAPE@ to create new features, not to read properties of existing ones
  • Geometry tokens give you access to the individual vertices of geometry objects, while SHAPE@ only gives you the entire geometry object
  • Some feature classes do not have a SHAPE field and using geometry tokens is the only option

Question 4

Question
When using geometry tokens in a search cursor for single part polylines and polygons, what does the search cursor return for each row in the feature attribute table?
Answer
  • an array of point objects
  • an array containing an array of point objects
  • a list of point objects
  • a list containing a list of point objects

Question 5

Question
Consider the following script, in particular line 8 that uses getPart (0): import arcpy from arcpy import env env.workspace = "C:/Data" fc = "roads.shp" cursor = arcpy.da.SearchCursor (fc, ["OID@", "SHAPE@"]) for row in cursor: print ("Feature {0}: ".format (row[0])) for point in row[1].getPart (0): print ("{0}, {1}".format (point.X, point.Y)) Why is getPart (0) needed here, even if the features are all single part?
Answer
  • For polylines and polygons, the cursor returns the parts of a geometry object as an array, so for single part features you need to get the first (and only) part
  • If you don't use getPart, all vertices for the entire feature class would print together and you would not be able to tell which vertices belong to which feature.
  • The use of getPart makes it possible to use the same script for point, polyline and polygon features.
  • All geometry objects consist of arrays of points, so get at the individual points you need to examine the parts.

Question 6

Question
Which property(ies) of a geometry objects is (are) used to determine whether a specific feature is multipart or single part?
Answer
  • partCount
  • type
  • isMultipart
  • pointCount
  • shapeType

Question 7

Question
Some polygon features contain 'holes'. When you work with geometry objects for such polygons, how can you determine whether these holes are present?
Answer
  • the geometry property ringCount is greater than 1 for polygons with holes
  • you can use the geometry property isExterior to determine whether an array of point objects is an exterior or interior ring
  • the shapeType property of the geometry object is MultiPatch instead of Polygon
  • the array of point objects for a feature contains 'null point objects' which seperate the exterior and interior rings

Question 8

Question
Consider a scenario where you write a script to create a new polyline out of a text file with coordinates for the vertices. You will need to use a cursor object to create new geometry objects. Which of the following is the correct line of code to set up your cursor object?
Answer
  • cursor = arcpy.da.UpdateCursor(fc, ["SHAPE@"])
  • cursor = arcpy.da.InsertCursor(fc, "SHAPE@XY")
  • cursor = arcpy.da.InsertCursor(fc, "SHAPE@")
  • cursor = arcpy.da.UpdateCursor(fc, ["SHAPE@XY"])
  • cursor = arcpy.da.InsertCursor (fc, ["SHAPE@XY"])
  • cursor = arcpy.da.UpdateCursors(fc, ["SHAPE@XY"])

Question 9

Question
Consider the following script to print the coordinates of the vertices of the features of a feature class. import arcpy from arcpy import env env.workspace = "C:/Data" fc = "features.shp" cursor = arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]) for row in cursor: print ("Feature {0}: ".format(row[0])) partnum = 0 for part in row[1]: print ("Part {0}:".format(partnum)) for point in part: print ("{0}, {1}".format(point.X, point.Y)) partnum += 1 For which types of datasets will this script work correctly? (check all that apply)
Answer
  • Single-part point features
  • Multi-part point features
  • Multi-part polygon features with holes
  • Multi-part polyline and polygon features
  • Single-part polyline and polygon features
  • Single-part polygon features with holes

Question 10

Question
Consider the following script to print the coordinates of the vertices of the features of a feature class. import arcpy from arcpy import env env.workspace = "C:/Data" fc = "features.shp" cursor = arcpy.da.SearchCursor(fc, ["OID@", "SHAPE@"]) for row in cursor: print ("Feature {0}: ".format(row[0])) partnum = 0 for part in row[1]: print ("Part {0}:".format(partnum)) for point in part: print ("{0}, {1}".format(point.X, point.Y)) partnum += 1 Line 10 of the code reads 'for part in row[1]:'. Why does the code use row[1] instead of just row?
Answer
  • because you only want to obtain the first part of the geometry object
  • because the search cursor returns a list and row[1] obtains the geometry object
  • because the script is only designed to work for single part features
  • because the search cursor returns a list and row[1] obtains the list of coordinates
  • because you want to start numbering the parts of each features at 1
Show full summary Hide full summary

Similar

Geography Quiz
PatrickNoonan
Geography Coastal Zones Flashcards
Zakiya Tabassum
Using GoConqr to study geography
Sarah Egan
All the Countries of the World and their Capital Cities
PatrickNoonan
Tectonic Hazards flashcards
katiehumphrey
Volcanoes
1jdjdjd1
River Processes and Landforms
1jdjdjd1
GCSE Geography - Causes of Climate Change
Beth Coiley
The Rock Cycle
eimearkelly3
Plate Tectonics
eimearkelly3
Characteristics and Climate of a hot desert
Adam Collinge