a = np.array([[0., 0.], [2., 10.], [4., 10.], [2., 0.], [0., 0.]])
a[[0, 1]]
array([[ 0.00, 0.00],
[ 2.00, 10.00]])
a[[-2, -1]]
array([[ 2.00, 0.00],
[ 0.00, 0.00]])
# -- two point array/line
b = np.array([[0., 0.], [2., 10.]])
b[[0, 1]]
array([[ 0.00, 0.00],
[ 2.00, 10.00]])
a[[-2, -1]]
array([[ 2.00, 0.00],
[ 0.00, 0.00]])
See if "part" supports fancy indexing, so rather than slicing one at a time, you can get both
Or you could take a different tact and convert the searchcursor row to an array
def _fc_as_narray_(in_fc, with_id=False):
"""Return geometry from a featureclass using `as_narray`."""
flds = ["SHAPE@X", "SHAPE@Y"]
if with_id:
flds = ["OID@", "SHAPE@X", "SHAPE@Y"]
with arcpy.da.SearchCursor(in_fc, flds, explode_to_points=True) as cursor:
a = cursor._as_narray()
del cursor
return a
then 'a' will be your polyline as an array
... sort of retired...