Zusammenfassung der Ressource
Frage 1
Frage
Which cursors of the arcpy.da module can be used to work with geometry objects using SHAPE@?
Antworten
-
SearchCursor, UpdateCursor, and InsertCursor
-
InsertCursor only
-
SearchCursor only
-
UpdateCursor only
-
UpdateCursor and InsertCursor
Frage 2
Frage
Which of the following is not a geometry token in ArcPy?
Antworten
-
SHAPE@
-
SHAPE@CENTROID
-
SHAPE@XY
-
SHAPE@LENGTH
Frage 3
Frage
What is the main reason to use geometry tokens instead of SHAPE@?
Antworten
-
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
Frage 4
Frage
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?
Antworten
-
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
Frage 5
Frage
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?
Antworten
-
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.
Frage 6
Frage
Which property(ies) of a geometry objects is (are) used to determine whether a specific feature is multipart or single part?
Antworten
-
partCount
-
type
-
isMultipart
-
pointCount
-
shapeType
Frage 7
Frage
Some polygon features contain 'holes'. When you work with geometry objects for such polygons, how can you determine whether these holes are present?
Antworten
-
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
Frage 8
Frage
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?
Antworten
-
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"])
Frage 9
Frage
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)
Antworten
-
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
Frage 10
Frage
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?
Antworten
-
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