I have an python tool that runs fine in ArcGIS pro. I was able to publish as a service to my ArcGIS Enterprise however when I try to run the service it gives an error. It looks like the it is hung up when trying to call arcpy.Project_management. Any ideas on why this would run fine in Pro but not as a GP service? Thanks in advance.
- esriJobMessageTypeError: Traceback (most recent call last): File "<string>", line 156, in execute File "<string>", line 441, in getMessages File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\management.py", line 11492, in Project raise e File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\management.py", line 11489, in Project retval = convertArcObjectToPythonObject(gp.Project_management(*gp_fixargs((in_dataset, out_dataset, out_coor_system, transform_method, in_coor_system, preserve_shape, max_deviation, vertical), True))) File "d:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000208: Error creating output feature class Failed to execute (Project).
# what to do with a polygon
logging.debug(
"Input feature is a polygon based on config, buffer will not be created")
poly = arcpy.AsShape(feature["geometry"], True)
try:
wkid = feature["geometry"]["spatialReference"]["latestWkid"]
except Exception:
wkid = feature["geometry"]["spatialReference"]["wkid"]
pass
in_sr = arcpy.SpatialReference(wkid)
poly_fc = arcpy.CreateFeatureclass_management(
"in_memory", "tempPoly", "POLYGON", spatial_reference=in_sr)[0]
logging.debug("Spatial Reference of poly_fc: " +
arcpy.Describe(poly_fc).spatialReference.name)
# Open an insert cursor
with arcpy.da.InsertCursor(poly_fc, ["SHAPE@"]) as cursor:
# add the poly to the feature class
cursor.insertRow([poly])
# reproject the poly feature class to 4326 if it's not already so the
# buffer output will be in 4326 and be more accurate
if wkid == 4326:
event_poly = poly_fc
else:
projected_poly = os.path.join(script_path,"prjPoly.shp")
arcpy.Project_management(
poly_fc, projected_poly, arcpy.SpatialReference(4326))
arcpy.CopyFeatures_management(projected_poly, event_poly)
arcpy.Delete_management(projected_poly)
logging.debug("event Poly feature count: " +
str(arcpy.GetCount_management(event_poly).getOutput(0)))
logging.debug("event Poly spatial reference: " +
arcpy.Describe(event_poly).spatialReference.name)