Get startx-StartY and EndX-Endy, of a polyline within a Class Featrure

1150
2
Jump to solution
11-26-2012 11:02 AM
GualbertoHernández_Juárez
New Contributor
Hi,

Get startX-StartY and EndX-EndY, of a polyline within a Class Featrure

I need to get startX-StartY and EndX-EndY, of a polyline within a Class Featrure, but must be for a specific polyline, ie for a given "ObjectID". So far I have the following code but I get no what I need.

On the other hand, if I comment the line if "ObjectID" == 50: get the points for all the polylines of feature class, and I just need to a specific ObjectID, eg 50.

Can you tell me what you're missing?

Thank you very much,
Gualberto

import arcpy #infc = arcpy.GetParameterAsText(0) inFeatures = "Database Connections\Con_GDBHuracanesHistoricos.sde\GDBCiclonesTropicales.SDE.Huracanes_Historicos\GDBCiclonesTropicales.SDE.Ciclones_Historicos" # Enter for loop for each feature # for row in arcpy.da.SearchCursor(inFeatures, ["ObjectID", "SHAPE@"]):     # Print the current line ID     if "ObjectID" == 50:            print("Feature {0}:".format(row[0]))         #print "ObjectID"         #Set start point         startpt = row[1].firstPoint         #Set Start coordinates         startx = startpt.X         print startx         starty = startpt.Y         print starty         #Set end point         endpt = row[1].lastPoint         #Set End coordinates         endx = endpt.X         print endx         endy = endpt.Y         print endy
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor
I admit I haven't used the new arcpy.da cursors yet, but from the help (look for "Accessing and setting field values") it looks like your 'if' statement should be:
if row[0] == 50: #check first column returned by cursor 

View solution in original post

0 Kudos
2 Replies
DarrenWiens2
MVP Honored Contributor
I admit I haven't used the new arcpy.da cursors yet, but from the help (look for "Accessing and setting field values") it looks like your 'if' statement should be:
if row[0] == 50: #check first column returned by cursor 
0 Kudos
GualbertoHernández_Juárez
New Contributor
dkwiens,

Excellent! It worked very well.

Thank you very much!

Gualberto
0 Kudos