XY not in correct location via GP tool

2510
33
Jump to solution
10-03-2019 08:04 AM
jaykapalczynski
Frequent Contributor

I have an application that I am testing out.  But first a little back information

My Steps:

I created a simple Python script that creates a new point in a FeatureClass. (see below)

I then add this script to a toolbox

I then set the parameters for the Classification, X and Y in the properties (Classifcation=string, XY are set to double)

I can run this with hard coded values via IDLE and it works fine as seen below

Next:

Seeing that the script works in IDLE I publish a GP Service from the process I just ran to my ArcGIS Server.

I can run the GP Service from our ArcGIS Server and it runs fine.

Finally:

I then reference this from AppStudio and attempt to run it with hard coded values as seen below

1. I can get it to run and create a new point THIS WORKS

2. BUT the XY coordinates I feed it don't appear where they should.  If I use the EXACT same ones that I use in the script below they don't show up in the same place as the points added .

The data in SDE is WGS 84 decimal degrees.

MY ISSUE:

If I hard code the XY in the script and run from IDLE it works fine

If I add the exact same Coordinates from the GP Service that I published in ArcGIS Service it works fine

If I hard code the exact same Coordinates as seen below in AppStudio it puts the points at roughly (-78, 39)

      I dont see where and how to coordinates I am submitting in the job are being converted from (-77.43153, 37.527056) to (-78, 39)

     Funny thing is if I export the data and calculate XY for the points the ones done through AppStudio are truncated and have no Sig Figs, while the points added in the Service and Script via IDLE have sig figs.

Very confused.  Seems the sig figs are being dropped but then again the XY corrds are goin from 77 to 78 and 37 to 39?

      

I know this is a lot to digest but figure someone might have seen this before?

import arcpy
from arcpy import env
import os

#varXCoord = arcpy.GetParameterAsText(4)
#varYCoord = arcpy.GetParameterAsText(5)
#varClassification = arcpy.GetParameterAsText(6)

varClassification = "New Classification"
varYCoord = "37.527056"
varXCoord = "-77.43153"

fc = 'xE.DBO.xxx'
workspace = arcpy.env.workspace = r'C:\Users\x\AppData\Roaming\ESRI\Desktop10.5\ArcCatalog\x@xxxxxxx.sde'

## Start an edit session. Must provide the workspace.
edit = arcpy.da.Editor(workspace)

edit.startEditing(False, False)

## Start an edit operation
edit.startOperation()

row_values = [( varXCoord ,varYCoord, varClassification)]
print(row_values)

cursor = arcpy.da.InsertCursor(fc,['SHAPE@X', 'SHAPE@Y', 'Classification'])
for row in row_values:   
    cursor.insertRow(row) 
del cursor
                         
## Stop the edit operation.
edit.stopOperation()

## Stop the edit session and save the changes
edit.stopEditing(True)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

GeoprocessingTask {
   id: insertCursorTask
   url: "https://xxx.xx.xxxx.xx/arcgis/rest/services/xxx/InsertCursor/GPServer/InsertCursor/submitJob"

   function insertFunction() {

       var varClassification = "New Classification";
       var xlocation = -77.43153;
       var ylocation = 37.527056;

       var gpParametersInsert = ArcGISRuntimeEnvironment.createObject("GeoprocessingParameters",
     {executionType: Enums.GeoprocessingExecutionTypeSynchronousExecute});

       var inputsI = {};

       inputsI["classification"] = ArcGISRuntimeEnvironment.createObject("GeoprocessingString", {value: varClassification});
       inputsI["SHAPE@X"] = ArcGISRuntimeEnvironment.createObject("GeoprocessingString", {value: xlocation });
       inputsI["SHAPE@Y"] = ArcGISRuntimeEnvironment.createObject("GeoprocessingString", {value: ylocation });

       //var inputresults = inputs;
       gpParametersInsert.inputs = inputsI;

       // Create the job that handles the communication between the application and the geoprocessing task
       insertCursorJob = insertCursorTask.createJob(gpParametersInsert);

       console.log("gp job: " + JSON.stringify(insertCursorJob));
 
       insertCursorJob.start();

}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
33 Replies
jaykapalczynski
Frequent Contributor

I can see here how knowing the jobid can result in the needed information I am seeking...

I just cant see where I make the call to get the jobid.  It has to be a return from the 

insertCursorJob.start();

I just cant figure out where and how....and the syntax....

This can get me the results again but I need the job number

GP Result—ArcGIS REST API: Services Directory | ArcGIS for Developers 

0 Kudos
ErwinSoekianto
Esri Regular Contributor

It looks like the submitJob operation for yours is the uploadRequest NetworkRequest. 

Again, Esri Technical Support‌ should be able help you troubleshoot your code to find the jobId. 

0 Kudos
jaykapalczynski
Frequent Contributor

for Reference...the submit job question was solved with this example

Viewshed (geoprocessing) | ArcGIS for Developers 

0 Kudos
jaykapalczynski
Frequent Contributor

Not sure how choose the answer for this....if anyone has any questions about this please respond and look me up...would be more than happy to help.

Thanks Erwin for all your help.

0 Kudos