I generate a layer file that has multiple parallel lines, that I want is to sequentially (from OBJECTID(1) to OBJECTID(Max)) create a point at each end point of the line segments and number these points. The other problem is alternating which side it starts creating a point from...

Say I have 2 lines parallel to each other going left to right and one is above the other. The first line would have a point at the left-end point labeled 1, the right-end point labeled 2. The next line would have the right end-point labeled 3, and the left end-point labeled 4 and so on.

  • 1
    Look at feature vertices to points (Advanced license only) resources.arcgis.com/en/help/main/10.2/index.html#//… and use either "START" or "BOTH_ENDS" depending on your requirements. If you don't have advanced or that solution isn't suitable please draw a picture with the lines and points and I'll help you through the arcpy. Commented Sep 17, 2014 at 21:36
  • My organization won't be upgrading from 10.0 to 10.2 for another year (which means our advanced licenses won't migrate until then) but I did convince them to let me upgrade one of the 10.0 licenses to a 10.2 basic for testing. i.imgur.com/RA3g4Ay.png - I already have made a couple python scripts that will generate those lines automatically but making end-points and alternating them is becoming a difficult task. I just labeled the first 6 points (3 lines)... They may not always be horizontal tho. pastebin.com/8WuZ7MJX - I already made a script that will alternate a field
    – Numus
    Commented Sep 17, 2014 at 21:46
  • Feature vertices to points has been almost the same since 8.3 (not a misprint, version 8.3 was when I went from ArcINFO to ArcMap) the only part that's changed is "DANGLE" which appears to be new but I'm not sure when that became an option. With the points you can perform Near resources.arcgis.com/en/help/main/10.2/index.html#//… or perform a spatail join to add fields to join to the contributing lines if not already present. Commented Sep 17, 2014 at 21:51
  • I have modified this script arcgis.com/home/item.html?id=e19b53170e004e46827b8129d6ef9bfe to create the points that generate the lines... I was thinking I can use the Shape_ID field that the polyline layer has to specify the distance, one of the problems I have tho is alternating which end segment is the first and which is the 2nd. My end goal is to generate a layer that looks like the black line - i.imgur.com/tx5phxg.png This will allow me to output the file into a FPL format to integrate in a Garmin G1000 (or other aviation GPS)
    – Numus
    Commented Sep 17, 2014 at 21:53
  • 1
    It seems that you're really keen to get an arcpy solution to this.. have a read of resources.arcgis.com/en/help/main/10.2/index.html#//… which will give the fundamentals, if you use SHAPE@ and return the geometry object you can get the firstPoint and lastPoint (please ensure single part features or that might not be what you really want) which can be used to insert points on an insert cursor. Does that make sense to you? Commented Sep 17, 2014 at 21:59

1 Answer 1

import arcpy, os 

infc = sys.argv[1] # make sure this is a proper path 
outfc = sys.argv[2] # make sure this is a proper path 

# split the output into a folder and file name 
OutPath = os.path.dirname(outfc) 
OutName = os.path.basename(outfc) 
NameOfFile,ext = os.path.splitext(OutName) # separate file name from extension (if any) 
NameOfFile = NameOfFile + ".shp" # include shape file extension 
OutFC_Clean = OutPath + "\\" + NameOfFile # clean full path to output 

# Get the spatial reference from the input feature class 
desc = arcpy.Describe(infc) 
SR = desc.spatialReference 

n = 1 
arcpy.CreateFeatureclass_management(OutPath,NameOfFile,"POINT",spatial_reference = SR) 

# Enter for loop for each feature 
with arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@", "alternate"]) as sCur:
    with arcpy.da.InsertCursor(OutFC_Clean,["SHAPE@","Waypoint"]) as iCur:
        for row in sCur:
            if row[2] == "False":
                #insert the feature
                n = n + 1 
                n = n + 1 
                n = n + 1 
                n = n + 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.