Skip to main content
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
can someone show how to format the code with correct indentations?
Source Link
Brad Nesom
  • 17.4k
  • 2
  • 44
  • 68

Any suggestions will be appreciated.

import arcpy arcpy.env.overwriteOutput = True

fc_Nodes = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\LinkNodes_point.shp'

arcpy.DeleteRows_management(fc_Nodes)

fc_Links = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\DRN_SevUp_14Recs_polyline.shp'

shapeName = arcpy.Describe(fc_Links).shapeFieldName

rows = arcpy.SearchCursor(fc_Links) InCurs = arcpy.InsertCursor(fc_Nodes)

Ins = 0

for row in rows:

feat = row.getValue(shapeName) ANode = feat.firstPoint

#check to see if node has already been inserted arcpy.MakeFeatureLayer_management(fc_Nodes, "fl_P1", """"X" = ANode.X""") if int(arcpy.GetCount_management("fl_P1").getOutput(0)) == 0:

Ins = Ins + 1

print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0)) print "Inserted: "+ str(Ins) print "ANodeX: " + str(ANode.X) print ""

newNode = InCurs.newRow() newNode.SHAPE = ANode newNode.setValue("CHECK", 1) newNode.setValue("X", ANode.X) newNode.setValue("Y", ANode.Y) newNode.setValue("ID", Ins)

InCurs.insertRow(newNode) del ANode arcpy.Delete_management("fl_P1") else:

print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0)) print "NOT Inserted : " + str(ANode.X) print "" del ANode arcpy.Delete_management("fl_P1")

arcpy.Delete_management("fl_P1")
del InCurs del rows

import arcpy
arcpy.env.overwriteOutput = True

fc_Nodes = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\LinkNodes_point.shp'

arcpy.DeleteRows_management(fc_Nodes)

fc_Links = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\DRN_SevUp_14Recs_polyline.shp'

shapeName = arcpy.Describe(fc_Links).shapeFieldName

rows = arcpy.SearchCursor(fc_Links)
InCurs = arcpy.InsertCursor(fc_Nodes)

Ins = 0

for row in rows:

 feat = row.getValue(shapeName)
 ANode = feat.firstPoint


#check to see if node has already been inserted
 arcpy.MakeFeatureLayer_management(fc_Nodes, "fl_P1", """"X" = ANode.X""")
 if int(arcpy.GetCount_management("fl_P1").getOutput(0)) == 0:

  Ins = Ins + 1

  print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0))
  print "Inserted: "+ str(Ins)
  print "ANodeX: " + str(ANode.X)
  print ""


  newNode = InCurs.newRow()
  newNode.SHAPE = ANode
  newNode.setValue("CHECK", 1)
  newNode.setValue("X", ANode.X)
  newNode.setValue("Y", ANode.Y)
  newNode.setValue("ID", Ins)

  InCurs.insertRow(newNode)
  del ANode
  arcpy.Delete_management("fl_P1") 
 else:
  
  print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0))
  print "NOT Inserted : " + str(ANode.X)
  print ""
  del ANode
  arcpy.Delete_management("fl_P1") 
 
arcpy.Delete_management("fl_P1")      
del InCurs
del rows


print "--------------End---------"

print "--------------End---------"`

Any suggestions will be appreciated.

import arcpy arcpy.env.overwriteOutput = True

fc_Nodes = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\LinkNodes_point.shp'

arcpy.DeleteRows_management(fc_Nodes)

fc_Links = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\DRN_SevUp_14Recs_polyline.shp'

shapeName = arcpy.Describe(fc_Links).shapeFieldName

rows = arcpy.SearchCursor(fc_Links) InCurs = arcpy.InsertCursor(fc_Nodes)

Ins = 0

for row in rows:

feat = row.getValue(shapeName) ANode = feat.firstPoint

#check to see if node has already been inserted arcpy.MakeFeatureLayer_management(fc_Nodes, "fl_P1", """"X" = ANode.X""") if int(arcpy.GetCount_management("fl_P1").getOutput(0)) == 0:

Ins = Ins + 1

print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0)) print "Inserted: "+ str(Ins) print "ANodeX: " + str(ANode.X) print ""

newNode = InCurs.newRow() newNode.SHAPE = ANode newNode.setValue("CHECK", 1) newNode.setValue("X", ANode.X) newNode.setValue("Y", ANode.Y) newNode.setValue("ID", Ins)

InCurs.insertRow(newNode) del ANode arcpy.Delete_management("fl_P1") else:

print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0)) print "NOT Inserted : " + str(ANode.X) print "" del ANode arcpy.Delete_management("fl_P1")

arcpy.Delete_management("fl_P1")
del InCurs del rows

print "--------------End---------"

import arcpy
arcpy.env.overwriteOutput = True

fc_Nodes = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\LinkNodes_point.shp'

arcpy.DeleteRows_management(fc_Nodes)

fc_Links = 'C:\Users\Rob&LP\Documents\GIS General\DRN Configuration\DRN Sample\DRN_SevUp_14Recs_polyline.shp'

shapeName = arcpy.Describe(fc_Links).shapeFieldName

rows = arcpy.SearchCursor(fc_Links)
InCurs = arcpy.InsertCursor(fc_Nodes)

Ins = 0

for row in rows:

 feat = row.getValue(shapeName)
 ANode = feat.firstPoint


#check to see if node has already been inserted
 arcpy.MakeFeatureLayer_management(fc_Nodes, "fl_P1", """"X" = ANode.X""")
 if int(arcpy.GetCount_management("fl_P1").getOutput(0)) == 0:

  Ins = Ins + 1

  print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0))
  print "Inserted: "+ str(Ins)
  print "ANodeX: " + str(ANode.X)
  print ""


  newNode = InCurs.newRow()
  newNode.SHAPE = ANode
  newNode.setValue("CHECK", 1)
  newNode.setValue("X", ANode.X)
  newNode.setValue("Y", ANode.Y)
  newNode.setValue("ID", Ins)

  InCurs.insertRow(newNode)
  del ANode
  arcpy.Delete_management("fl_P1") 
 else:
  
  print "NumRows: " + str(arcpy.GetCount_management("fl_P1").getOutput(0))
  print "NOT Inserted : " + str(ANode.X)
  print ""
  del ANode
  arcpy.Delete_management("fl_P1") 
 
arcpy.Delete_management("fl_P1")      
del InCurs
del rows


print "--------------End---------"

`

Source Link
Robert
  • 125
  • 1
  • 11
Loading