Split Line by Point --change output to original line feature class

827
7
05-13-2022 08:19 AM
YinghongLi1
Occasional Contributor
arcpy.management.SplitLineAtPoint(in_features, point_features, out_feature_class, {search_radius})

 The above code line outputs the split features to a new feature class or rewrites an existing feature class.  I want the split features to be output to the original SDE line feature class.  It seems not doable.  I got the feature class exists message.

I need to have split features in the original line feature class and delete the original feature after the feature is split.  If the split features have to be in another feature class then I have to add them back.  I am wondering if it is a better way to create new features based on the line's start/endpoints and the split point.

I'd like to know if there is a better way to do this.

Thanks

 

0 Kudos
7 Replies
DanPatterson
MVP Esteemed Contributor

The obvious would be to edit the features that you need to change, but you obviously have many to do and this wouldn't be an option.

Overwriting anything without a backup is obviously not recommended, so creating a new featureclass would be best if editing isn't an option.


... sort of retired...
0 Kudos
BlakeTerhune
MVP Regular Contributor

If you are certain that replacing the original feature class is safe, try adding arcpy.env.overwriteOutput = True before you call the gp tool.

env—ArcGIS Pro | Documentation

0 Kudos
YinghongLi1
Occasional Contributor

I only want to add the split features to the original feature class -- the one contains feature to be split, not overwrite the feature class.  I want the split to behave like the split tool in ArcGIS Pro.  I guess it is not doable.  I may have to create two new features and insert them to the original feature class.

Thanks.

0 Kudos
BlakeTerhune
MVP Regular Contributor

If you add the split features to the original feature class, then you'll have duplicate features: the original lines and the split lines. If that what you want, just use Append.

YinghongLi1
Occasional Contributor

The reason I need to have new features and original feature coexist in the feature class is that I have to copy non-system attributes to the new features and length fields need to have the calculation done.  once I finish the processing of the attribute I can delete the original feature.

I tested append it worked.  However, the field mapping is a problem.  I do not know which line feature class is the editing layer so I can not hard-code the fields.  in theory, new features have same fields as the original one.  Do not know why the fields do not match.  Any suggestion?

Thanks.

 

0 Kudos
BlakeTerhune
MVP Regular Contributor

Either run the split tool manually in ArcGIS Pro or output the result to a file geodatabase so you can see what it looks like. Compare the fields yourself and see if anything changes and make the field mappings accordingly. Alternatively, use the "NO_TEST" schema_type option for Append:

Fields from the input dataset do not need to match the fields of the target dataset. Any fields from the input datasets that do not match the fields of the target dataset will not be mapped to the target dataset unless the mapping is explicitly set in the Field Map parameter.
0 Kudos
DanPatterson
MVP Esteemed Contributor

make a copy as suggested earlier, then append


... sort of retired...
0 Kudos