1

I have a line with begin and end node XY data (IHS_NET_EDIT_DISSOLVE) and would like to create a point feature class representing the begin and end nodes. With the following code I am able to successfully create the XY event layers, but the resulting feature classes are empty:

arcpy.MakeXYEventLayer_management(IHS_NET_EDIT_DISSOLVE, "START_X", "START_Y", "lyrBeginNodes")
arcpy.MakeXYEventLayer_management(IHS_NET_EDIT_DISSOLVE, "END_X", "END_Y", "lyrEndNodes")
print("Begin Node Layer Count: " + str(arcpy.GetCount_management("lyrBeginNodes")))
print("End Node Layer Count: " + str(arcpy.GetCount_management("lyrEndNodes")))
arcpy.FeatureClassToFeatureClass_conversion("lyrBeginNodes", outputPath, "BeginNodes")
arcpy.FeatureClassToFeatureClass_conversion("lyrEndNodes", outputPath, "EndNodes")
print("Begin Node FC Count: " + str(arcpy.GetCount_management("BeginNodes")))
print("End Node FC Count: " + str(arcpy.GetCount_management("EndNodes")))

As you can see from what's printed, the layer counts look good, but the feature classes are empty:

>>>
Begin Node Layer Count: 2452
End Node Layer Count: 2452
Begin Node FC Count: 0
End Node FC Count: 0
>>>

What am I doing wrong here? I imagine it has to do with how I'm referencing the layers as input, but I don't know how else to make it work.

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Nov 15, 2018 at 18:46
3
  • Try to move arcpy.FeatureClassToFeatureClass_conversion directly after each arcpy.MakeXYEventLayer_management and see if this can solve the issue. Commented Nov 15, 2018 at 18:56
  • No luck with that solution. I also tried putting MakeXYEventLayer_management directly as the input parameter of FeatureClassToFeatureClass_conversion, but both methods resulted in an empty output. Commented Nov 15, 2018 at 19:02
  • 1
    I think you need to use arcpy.SaveToLayerFile_management() which works with arcpy.MakeXYEventLayer_management() before using arcpy.FeatureClassToFeatureClass_conversion(). You can refer to the help of arcpy.MakeXYEventLayer_management(): desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/… Commented Nov 15, 2018 at 19:12

1 Answer 1

1

I found the answer - it turns out in my case that the problem wasn't with FeatcureClassToFeatureClass, but with the spatial reference. Somewhere along the line the spatial reference setting (which I thought is supposed to default to the spatial reference of the input feature) wasn't adding up and the resulting coordinates were out of bounds, resulting in an empty feature class.

My solution was to set sref = arcpy.Describe(IHS_NET_EDIT).spatialReference then set the spatial reference parameters to sref for both AddGeometryAttributes_management and MakeXYEventLayer_management.

answered Nov 15, 2018 at 20:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.