0

I wrote a Python script which takes an input Cropland Data Layer raster dataset and a user's defined Region of Interest, and returns a pop-up message telling the user the number of acres of each crop in that ROI. The script runs fine in ArcGIS Pro 2.5 as a script tool.

Ultimately, I want to now share this script tool as a web tool on enterprise. However, when I try to do this, the process fails out, and when I check the logs on the server, the message which seems to indicate the failure is

Invalid manifest. Unable to find dataset in extracted geodatabase.

I'm new to using Enterprise and Server and don't know how to address this error (I'm also not a Python wizard! Please forgive any poor coding). I would love any feedback pointing me in the right direction as to how to address this error so I can get the tool shared as a web tool. The code I have written follows.

I have a feeling the error lies in how I'm passing intermediate outputs, but I would not be surprised if I'm wrong.

Edit: I forgot to mention that I can successfully share the script tool as a geoprocessing package, if that matters

import arcpy
from arcpy.sa import ZonalHistogram
import tkinter
from tkinter import messagebox

#Set environments
arcpy.env.workspace = r"C:\Users\XXXXXXXXX\Documents\ArcGIS\Projects\CropAcreageTool\CropAcreageTool.gdb"
arcpy.env.overwriteOutput = True
root = tkinter.Tk()
root.wm_withdraw()

#Begin by having the user input their two parameters: Raster layer and ROI

#Parameter 1: Raster layer (input)
baseRaster = arcpy.GetParameterAsText(0)

#Parameter 2: Region of Interest (input)
ROI = arcpy.GetParameterAsText(1)

#Intermediate: Crop acreage table
cropTable = r"cropCount"

#Class key for join 
classTable = r"classKey.csv"

#Execute ZonalHistogram to give the counts for each unique class within the ROI in the output table
ZonalHistogram(ROI, "OBJECTID", baseRaster, cropTable)

#Join the output table with the class key table to associate counts with crop type
arcpy.JoinField_management(cropTable, "OID", classTable, "OID")

#Loop through table with a search cursor and perform calculation to generate acreage: (count * 900m2)/4047m2 per acre
#Write result to list
#Display list as a popup message
cursor = arcpy.da.SearchCursor(cropTable, ["OBJEC_1", "Class_Name"], """"OBJEC_1" > 0""")

Results = []

for i in cursor:
    Results.append("{} acres of {}".format(round((i[0] * 900) / 4047), i[1]))

messagebox.showinfo("Results", "\n".join(Results))
1
  • Beyond the error you're getting - you'll need to remove the tkinter stuff. Your code will be run on the Server. There is no mechanism for the server to popup that box on some client which runs the service. The ability to get the results from the service lies squarely on the client calling the gp service.
    – KHibma
    Apr 3, 2020 at 0:23

1 Answer 1

0

When writing Python to be used as a tool which will be published as a geoprocessing service, it is always advised to be explicit, rather than implicit when it comes to writing paths.

Your code makes use of arcpy.env.workspace and further on tools and functions just load datasets by name, taking advantage of the GP framework's ability to find these items in the workspace. When you publish a tool, that publishing process needs to do a best attempt at finding data and copying it and setting the proper paths on the server so your tool will continue to work there as a service. When paths are created implicitly, this process sometimes can fail to find data and properly set it.

My suggestion is to remove your workspace code, and change every data reference to a fully qualified path. After this, run it and try it again.

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.