import arcpy
import os
# all input data are in country.gdb and output will also go to this gdb
arcpy.env.workspace = os.path.join(os.getcwd(), "country.gdb")
try:
in_links_feats = "link_features"
out_link_table = "output_table"
# transformation method
method = "SIMILARITY"
result = arcpy.edit.CalculateTransformationErrors(in_links_feats, out_link_table, method)
# get the transformation error
error = float(result.getOutput(1))
# if error is less than 12.234 then run Transform Features
if error < 20.0:
# make a copy of the input features
arcpy.management.CopyFeatures(in_links_feats, "in_links_copy")
arcpy.edit.TransformFeatures("in_links_copy", in_links_feats, method, "out_link_table")
else:
print("Transformation error {} is too high".format(error))
except arcpy.ExecuteError as aex:
print(arcpy.GetMessages(2))
except Exception as ex:
print(ex.args[0])