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.

  • Try to move arcpy.FeatureClassToFeatureClass_conversion directly after each arcpy.MakeXYEventLayer_management and see if this can solve the issue. – ahmadhanb Nov 15 '18 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. – dfour001 Nov 15 '18 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/… – ahmadhanb Nov 15 '18 at 19:12
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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