0

I am building an app in the ArcGIS Web AppBuilder.

I am trying to pass the geoetry resulting from the drawbox dijit to a geoprocessor. Its an extent.

But when I attempt it and log the parameter to console from the geoprocessing script its always empty.

I get the geometry from the drawbox dijit like so :-

_onDrawComplete: function(graphic) {
  var geometry = graphic.geometry;
  this._bathyList(this.bathyList, geometry)
},

I then want to pass this geometry into a geoprocessor. I tried passing it in directly and it complained it needed to be a gpfeatureset.

So I have attempted to create a gpfeatureset which seems to have got round the above error.

The problem is that when I log the param out on the geoprocessing end it is always null.

var features = [];
  features.push(geometry);

  var featureSet = new FeatureSet();
  featureSet.features = features;

  console.log(geometry)
  console.log(featureSet)

  // setup gp stuff and params
  var params = { "boolList":boollist, "poly": featureSet };
  var gp = new
  Geoprocessor('https://arcgispreprodent.admiralty.co.uk/server/rest/services/Jim/BathyClip/GPServer/BathyClip')

  gp.submitJob(params, this._processresults, this._jobstatus, this._joberr)
},

I am not sure how to debug this now, I assume I must be building an invalid gpfeatureset but it doesnt error.

I can change the datatypes, I can chacge the gp script, I just dont know how to get it to pass the polygon.

Heres my gp script

boolList = arcpy.GetParameterAsText(0)
poly = arcpy.GetParameterAsText(1)

arcpy.AddMessage('Param 0 : ' + boolList)
arcpy.AddMessage('Param 1 : ' + poly)

Output_Zip_File = os.path.join(arcpy.env.scratchFolder, 'output.zip')

tiflist = [u"Whole_UK_Mosaic", u"Whole_UK_COMORG"]


def cliptif(clippee, clipper, output):
    desc = arcpy.Describe(clipper)
    extent = desc.extent
    arcpy.Clip_management(clippee, str(extent), output, in_template_dataset=poly, clipping_geometry="ClippingGeometry")

for i in range(len(tiflist)):
    if boolList[i]:
        outTif = os.path.join(arcpy.env.scratchFolder, 'output'+str(i) + '.tif')
        cliptif(tiflist[i], poly, outTif)

zipper = zipfile.ZipFile(Output_Zip_File, 'w')
for i in range(len(tiflist)):
    zipper.write(os.path.join(arcpy.env.scratchFolder, 'output'+str(i) + '.tif'), tiflist[i]+'.tif')
zipper.close()


for i in range(len(tiflist)):
    if boolList[i]:
        outTif = os.path.join(arcpy.env.scratchFolder, 'output'+str(i) + '.tif')
        arcpy.Delete_management(outTif)

arcpy.SetParameter(2, Output_Zip_File)

I am not sure why my second parameter is always null when logging from the geoprocessor, I might be falling foul of asynchronous stuff somewhere or building feature set wrong.

0

The problem was I was just trying to pass the geometry returned from the drawbox, I should pass the whole graphic into the featureset not just the geometry.

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.