|
POST
|
Are there any data types that the dissolve tool won't accept as a field to aggregate by? I am getting this error but I think it's a error of misdirection because my python tool works perfectly fine when run locally but after it is published to ArcGIS Server, I get this error when it reaches the line in the script where it runs the dissolve tool. I am trying to dissolve using numerous fields with data types of string, integer, float, GUID, and date. I'm not understanding why it would work in ArcMap but not when it's published to the server.
... View more
04-05-2018
06:37 AM
|
0
|
2
|
1596
|
|
POST
|
I'm running a python script as a GP service, this script works great when run in the IDE or when run from a toolbox in ArcMap, but I cannot run the tool once it's published in a geoprocessing service. The error I receive is when it hits a line that uses the dissolve tool. It says "Error 000308: Invalid field type". All the fields being used to dissolve are integers, strings, float, and GUID data types. It runs successfully when it's not a geoprocessing service, so I know the fields are of a valid data type. I think it has something to do with my use of in_memory workspaces, but from what I have read, using in_memory workspace is the best practice when creating a lot of intermediate data in a GP service. I don't think the program is running out of memory when dissolving either because it's only dissolving a max of 200 features (and more often than not, it's really dissolving 50 or less). In the non-GP service code: try:
#Intersect buffer with selected patches to evaluate appropriate access to protective cover
intersect_result = arcpy.Intersect_analysis([[aa2PCPolys, 1], [pc_buffer, 2]], 'in_memory/pc_intersect')
except:
intsctError = traceback.format_exc()
arcpy.AddError(intsctError)
sys.exit(1)
#Define fields by which to aggregate features in the intersect_result FC
dissolveFields = ['StateID', 'Point', 'PatchNum', 'IsDeveloped', 'CropTypeID', 'CropResidue', 'CnpyOver12', 'CnpyDecid',
'CnpyConif', 'ShrubCover', 'ShbHiStemsDens', 'GrassCover', 'ForbCover', 'FrbAsProtect', 'ForbSpecies',
'BareGround', 'HerbHeight', 'IsQuailHab', 'ObsvDate', 'FirstName', 'LastName', 'Overstory', 'Understory',
'OfficialQH', 'StatePoint', 'MonitoringPointID', 'Orig_OID', 'Imputation', 'WhereImpute', 'QHonImputedVals',
'ObsvType']
#Aggregate features (ERRORS OUT ON THIS LINE)
try:
dislvIntersect = arcpy.Dissolve_management(intersect_result, 'in_memory/pc_dislvIntersect', dissolveFields) Once it has been published as GP service it replaces the in_memory stuff with ESRI variables: try:
#Intersect buffer with selected patches to evaluate appropriate access to protective cover
intersect_result = arcpy.Intersect_analysis([[aa2PCPolys, 1], [pc_buffer, 2]], g_ESRI_variable_28)
except:
intsctError = traceback.format_exc()
arcpy.AddError(intsctError)
sys.exit(1)
#Define fields by which to aggregate features in the intersect_result FC
dissolveFields = ['StateID', 'Point', 'PatchNum', 'IsDeveloped', 'CropTypeID', 'CropResidue', 'CnpyOver12', 'CnpyDecid',
'CnpyConif', 'ShrubCover', 'ShbHiStemsDens', 'GrassCover', 'ForbCover', 'FrbAsProtect', 'ForbSpecies',
'BareGround', 'HerbHeight', 'IsQuailHab', 'ObsvDate', 'FirstName', 'LastName', 'Overstory', 'Understory',
'OfficialQH', 'StatePoint', 'MonitoringPointID', 'Orig_OID', 'Imputation', 'WhereImpute', 'QHonImputedVals',
'ObsvType']
#Aggregate features (ERRORS OUT ON THIS LINE)
try:
dislvIntersect = arcpy.Dissolve_management(intersect_result, g_ESRI_variable_29, dissolveFields) This part of the python script is recursive, in that it will do this process many times on different selected features. I noticed from the error messages it went through it one full time, and then errored out on the second pass (see the first two messages in the picture, that message prints every time it starts a new pass). Does it have to do with overwriting issues maybe? I have arcpy.env.overwriteOutput = True set, but I don't know how that effects in_memory datasets.
... View more
04-04-2018
11:56 AM
|
0
|
2
|
2958
|
|
POST
|
Is this possible? I can use the UniqueValueRenderer with one integer field, but I can't get it to work with two. The renderer really has about 50 values, but I've only included one below so you get the idea: var fineRenderer = new UniqueValueRenderer(defaultSymbol, "Overstory", "Understory", null, ":");
fineRenderer.addValue(11000:11000, new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,0]), 1), new Color([217, 0, 0]))); I cannot figure out what I'm doing wrong. I'm specifying null for the third attribute field and then specifying the delimiter. My FeatureLayer has both "Overstory" and "Understory" fields. I don't know what the deal is. Do I need to put quotes around 11000:11000? I don't know if that'd work because the fields are integers, not strings. Do I need to try putting it in brackets like [11000:11000] or something? I'm at a loss here.
... View more
04-02-2018
01:20 PM
|
0
|
2
|
2048
|
|
POST
|
Quick question - when you call abortOperation() in an edit session -- you still have to stopEditing() afterward right? abortOperation is described as "canceling" an edit, I wasn't sure if stopEditing was necessary. Does what I have below look appropriate? try:
editor = arcpy.da.Editor(db_con)
editor.startEditing(False, False)
editor.startOperation()
with arcpy.da.InsertCursor(gpTestWriteFC, ['SHAPE@', 'FirstName', 'LastName']) as iCursor:
for item in insertList:
iCursor.insertRow(item)
editor.stopOperation()
editor.stopEditing(True)
except:
if editor.isEditing == True:
editor.abortOperation()
editor.stopEditing(False)
fullError = traceback.format_exc()
arcpy.AddError(fullError)
sys.exit(1)
... View more
04-02-2018
11:09 AM
|
0
|
2
|
1908
|
|
POST
|
Check your spelling kids... I looked at my input parameters in the service directory and found a spelling mistake that caused this issue. In my Javascript, I set the input parameter "State_Abbreviation" when in my service directory it was mispelled "State_Abbrevation". All fixed now. I'll leave the post up since it's a good example of how to input parameters into a geoprocessing service using Javascript API.
... View more
04-02-2018
07:23 AM
|
1
|
0
|
1566
|
|
POST
|
I'm having issues submitting string input to a GP Service. Using AGS 10.4.1. The service has one input parameter of string type, but every time I run the service it runs it with the default string input rather than the value I am passing to the GP Service. How do you get it to accept your new string input? I'm calling the service from Javascript API 3.23. I upload a zip file and accept string input from a form element: <form id="uploadForm" method="post" enctype="multipart/form-data">
State Abbreviation: <input type="text" name="stateAbbrev" id="stateAbbrev"><br>
<label class="custom-file-upload"><input type="file" name="file" id="dataUpload"/>File Upload</label>
<input type="button" value="Upload" id="upload"/>
</form> Then, after clicking the upload button, it gets to this function: function uploadSucceeded(response) {
var itemID = response["item"].itemID;
var dataFile = new esri.tasks.DataFile();
dataFile.itemID = itemID;
var stateAbbrv = document.getElementById("stateAbbrev").value;
console.log("File upload successful");
var params = {"Input_Zip_File": dataFile, "State_Abbreviation": stateAbbrv};
console.log('Input parameters: '+ dojo.toJson(params));
gp.submitJob(params, gpJobComplete, gpJobStatus, function(error){
console.error(error.jobStatus + '(' + error.jobId + '):' + dojo.toJson(error));
});
} In the function above, the line var params = {"Input_Zip_File": dataFile, "State_Abbreviation": stateAbbrv}; sets the State_Abbreviation parameter to the new user-supplied string input. This prints out correctly in the browser console: Input parameters: {"Input_Zip_File":{"itemID":"i0cd7358b-f7d4-4238-8d10-4bbdc624e895"},"State_Abbreviation":"AR"} But, using messages in the browser console, I can see it's running the GP Service using the default string input of "TN" which is the value the GP Service was published with (thus it becomes the default value). I need to somehow override that value, but I can't figure out how?
... View more
04-02-2018
06:51 AM
|
0
|
1
|
1860
|
|
POST
|
Glad I'm not the only one who's seen this before. Thanks for the response, even if there's no resolution at the moment.
... View more
04-02-2018
06:33 AM
|
0
|
2
|
1999
|
|
POST
|
I'm taking one last stab at an answer for this - has anybody had this happen before? When I publish a geoprocessing service that involves an SDE connection file, it copies that SDE connection file to the server (this is expected behavior) but then duplicates that connection down in arcgisserver/directories/arcgissystem/arcgisinput/../../extracted/v101 folder. I cannot figure out why it's doing this and I have tested everything I can possibly think of to see if it'll stop duplicating the connection file but it won't. It does this with any database connection and it does it no matter where the SDE file is stored on the publishing machine. The service works and it's the exact same database connection, so I'm not sure how much it matters, I just find it really weird and would like to understand it! The only thing I can think of at this point is that it's because I'm publishing a GP server from Desktop 10.6 to AGS 10.4.1. This simple script published as a GP process yields this in the above-mentioned directory: import arcpy
db_con = r"C:\Users\xxx\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\HbMonitoringTest_nbcidb_HabitatTestWriter.sde"
arcpy.AddMessage(db_con)
if arcpy.Exists(db_con):
arcpy.AddMessage("your db connection worked")
else:
arcpy.AddMessage("your db connection sucks") The script that resides on the server once the GP service is published references the duplicate (HbMonitoringTest_nbcidb_HabitatTestWriter1.sde) and not the original. You'll notice that there are two different dates/times listed for each of the SDE files; I created a database connection to the one without the 1 appended to the end yesterday, so when it copies this file to the server, the metadata (date/time) come with it and are not updated to reflect today's date since it's simply a copy. Once it's on the server, I guess it must duplicate it, hence why the file with a "1" appended to the end has the current date/time. I have outright deleted the GP service, made sure all the files are gone in the directory, and then republished from scratch to assure myself that there aren't two different files simply because one wasn't overwritten. That's not the issue. I'm tempted to roll back to Desktop 10.4.1 just to see if this issue goes away because I am out of ideas.
... View more
03-28-2018
12:55 PM
|
0
|
4
|
2263
|
|
POST
|
I've republished a couple times, and it still publishes up with 2 SDE connection files (the dates have been updated to today). Very strange.
... View more
03-27-2018
12:22 PM
|
0
|
0
|
2515
|
|
POST
|
I think there was actually an error during publishing because when I went into the /extracted/v101 folder, no SDE file was present. I have republished the service now and it's working, but there are two copies of the SDE file instead of one and I'm not sure why that is. When publishing GP services, the database connection gets copied to the server even though my data store settings have the "Allow data to be copied to the site when publishing services" checkbox unchecked. Why would it duplicate it though? For reference, my python script is very simple: import arcpy, zipfile
db_con = r'Database Connections\HbMonitoringTest_nbcidb_HabitatTestWriter.sde'
arcpy.AddMessage(db_con)
if arcpy.Exists(db_con):
arcpy.AddMessage("your db connection worked")
else:
arcpy.AddMessage("your db connection sucks")
try:
myZipFile = arcpy.GetParameterAsText(0)
arcpy.AddMessage(myZipFile)
scratch = arcpy.env.scratchFolder
arcpy.AddMessage(scratch)
zip_ref = zipfile.ZipFile(myZipFile, 'r')
zip_ref.extractall(scratch)
zip_ref.close()
arcpy.AddMessage("success")
except:
arcpy.AddMessage("fail") It's using the copy as well in the script for some reason (HbMonitoringTest_nbcidb_HabitatTestWriter1.sde): g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'C:\\arcgisserver\\
directories\\arcgissystem\\arcgisinput\\xxx\\ZipTest.GPServer\\extracted\\v101
\\HbMonitoringTest_nbcidb_HabitatTestWriter1.sde') Our GIS server is remote, so the publishing machine and the server are different machines.
... View more
03-27-2018
10:15 AM
|
0
|
2
|
2515
|
|
POST
|
I have an SDE database that is registered in the Data Store of my server: I reference this database connection in the python script (the geoprocessing service) as this: db_con = r'Database Connections\HbMonitoringTest_nbcidb_HabitatTestWriter.sde' I check to see if the connection evaluates to true, but it doesn't and I'm not sure why. if arcpy.Exists(db_con):
arcpy.AddMessage("your db connection worked")
else:
arcpy.AddMessage("your db connection sucks") Is this not the appropriate way to reference database connections in a geoprocessing service? Do I need to store the .sde connection file in a local folder on the server and connect using that instead? I have noticed int he v101 folder on the server, that the python script it contains did not replace "Database Connections" with the ESRI generated variable arcpy.env.packageWorkspace. Might that have something to do with it?
... View more
03-27-2018
08:33 AM
|
0
|
4
|
3833
|
|
POST
|
I swear, immediately after I post a question I always figure out the mistake I made. My geoprocessing service URL was missing the actual tool name at the end of it. Should be this: gp = new Geoprocessor("https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer/ZipTest");
... View more
03-27-2018
06:58 AM
|
2
|
1
|
3471
|
|
POST
|
I'm having a really hard time with this and I hope someone can shed some light. I've published a geoprocessing service that accepts uploads, I've also enabled "info" level messages. Unfortunately, nothing ever gets logged in server manager when this error occurs, so the messaging is kind of useless at this point. When I run the GP Service from ArcMap it works perfectly. When I run it from the rest API, I get a plain "failure" message. When I run it from my Javascript API, I get this error message: I don't even know where to start debugging this. I don't know what URL it's looking evaluating as bad. I've never done a file upload via the Javascript API before so it could be something in the code that's wrong, but in the console it successfully uploads the zip file and creates an item ID, so it's uploading fine, I just can't seem to pass it to my GP service correctly. This is my javascript code: require([
"esri/map",
"esri/request",
"esri/arcgis/utils",
"esri/layers/FeatureLayer",
"esri/tasks/Geoprocessor",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
],
function(
Map,
esriRequest,
arcgisUtils,
FeatureLayer,
Geoprocessor,
dom,
on
) {
var map = new Map("map", {
basemap: "hybrid",
center: [-77.069, 36.950],
zoom: 14
});
var featureLayer = new FeatureLayer("https://URL/servername/rest/services/HbMonitoringTest/HabitatData/MapServer/1");
map.addLayer(featureLayer);
gp = new Geoprocessor("https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer");
on(dom.byId("upload"), "click", upload);
function upload(){
//upload the zip file and get back the itemID (via uploadSucceeded)
console.log("Inside upload function now");
var upload = esri.request({
url: "https://URL/servername/rest/services/Web_Map_GP_Services/ZipTest/GPServer/uploads/upload",
form: dojo.byId("uploadForm"),
content: {f: 'json'},
handleAs: 'json',
}).then(uploadSucceeded, uploadFailed);
}
function uploadSucceeded(response) {
var itemID = response["item"].itemID;
console.log("File upload successful, item ID: ", itemID);
var params = {"Input_Zip_File": "{'itemID':" +itemID+ "}" };
console.log('Input parameters: '+ dojo.toJson(params));
console.log("submitting job");
gp.submitJob(params, gpJobComplete, gpJobStatus, function(error){
console.error(error.jobStatus + '(' + error.jobId + '):' + dojo.toJson(error));
});
}
function gpJobComplete(result){
console.log(result.jobStatus + '(' + result.jobId + ')')
}
function gpJobStatus(result){
console.log(result.jobStatus + '(' + result.jobId + '):' + dojo.toJson(message));
}
function uploadFailed(response){
console.log("Failed: ", response);
}
}); I've tried running it in the rest API, it successfully creates a job, but the process fails. Input page: After clicking "Submit Job (POST)":
... View more
03-27-2018
06:39 AM
|
1
|
2
|
4205
|
|
POST
|
I'm having trouble extracting the year from my date fields, mostly because it gets reformatted into that weird integer that doesn't look like a date. How do you get this type of integer to look like a date: 1518566400000 I tried using the Date constructor but I don't think I'm using it right (or maybe I can't use it for this purpose at all?). Date | API Reference | ArcGIS API for JavaScript 4.6 My code queries features, and for each feature I want to extract the year from the observation date to put into a select HTML element (drop-down menu). This is the code I have: //Get all the years in which data was collected
function getYears(response){
var features = response.features;
//Put date of each feature into an array
var values = features.map(function(feature){
var obsvDate = feature.attributes.ObsvDate; //this is the weird integer
//Do something here to change the date to a legible format
//...
//...
return myLegibleDate;
});
return values;
} I've attempted something as simple as var obsvDate = new Date(feature.attributes.ObsvDate); But when I try to print obsvDate to the console -- console.log(obsvDate) -- to see what it looks like, nothing prints. Total javascript newbie so it's possible I'm just doing something stupid.
... View more
03-26-2018
10:42 AM
|
0
|
3
|
3296
|
|
POST
|
I would like to use a user-uploaded zip file in my geoprocessing service. The GP service is called from a Javascript web app, so I need to switch on "uploads" for the GP service. In doing so, it's my understanding that the file will now be uploaded to the server for me, but then I need to get the itemID to pass as a parameter to my GP service. Then in my python script tool, I can do the logic for unzipping and getting the FGDB and go about my merry way. I feel like I understand the basics but I'm having a really hard time without a sample to look at. Does anybody have a good example of doing this? I'm working with AGS 10.4.1 and Javascript API 4.6. I would really like to see both an example of how the itemID is retrieved and passed to the GP service in the Javascript and then how it is used in the subsequent python script (e.g. is it just "GetParameterAsText()" or "sys.argv[]"?). While I'm not totally clear on how to retrieve the itemID in the Javascript, I do know you end up passing something like this as a parameter to the service. {itemID:"i83fa38d5-69e8-40c0-bd9c-30beb643e522} How is that then consumed in the python script? If I pass the itemID, will it be translated into the file I actually need? So say I had this script - would the GetParameterAsText actually retrieve the zip file and the below code would execute as expected, or would it just be that itemID and then I have to do something with that itemID to get the actual file associated with it? import arcpy, os, sys, zipfile
myZipFile = GetParameterAsText(0)
zip_ref = zipfile.ZipFile(myZipFile, 'r')
zip_ref.extractall(r"C:\someDirectory")
zip_ref.close()
... View more
03-21-2018
08:16 AM
|
1
|
5
|
6943
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-18-2020 10:31 AM | |
| 2 | 09-16-2025 02:17 PM | |
| 3 | 09-12-2025 09:26 AM | |
| 1 | 08-16-2023 05:11 PM | |
| 1 | 02-27-2024 06:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-16-2025
02:16 PM
|