Clip geoprocessing task not returning attributes in output feature class

2142
4
05-23-2012 04:28 AM
SujaSudhan
New Contributor
Hi,

I have published a geoprocessing task (which contains the Extract --> Clip tool) called Clip. When testing the model within the ArcMap, the resulting output feature class has all the attributes of the input feature. However, when I consume the geoprocessing service using Silverlight API, the output features do not have the attributes of the input features. However, the output features have got 3 new attributes as below:

FID-new created for each clipped features
Shape.Leng - length of the original feature
Shape.Length - length of the new clipped feature

Why is it missing the original attributes? Attached is my model, what am I missing while publishing this as a geoprocessing service which leaves out the original attributes?

Thanks!
0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor
Have you tried executing this task from the browser through the REST endpoint? Do you get your expected outfields there?
0 Kudos
SujaSudhan
New Contributor
Have you tried executing this task from the browser through the REST endpoint? Do you get your expected outfields there?


Hi, The results from the REST endpoint on browser are exactly the same as I get through the code. Based on this link (http://support.esri.com/en/bugs/nimbus/TklNMDY2NzMx), I am assuming I need to set the input feature set's field definitions as shown in the code block below. Also, I have set all the possible parameters as possible. But, nothing has made any difference. All these are ignored in the output feature class.

Code block:


              
   FeatureSet featureSet = new FeatureSet(graphicsToSerialize);

                  featureSet.Fields = metroFLI.Fields;
                  featureSet.GlobalIdFieldName = metroFLI.GlobalIdField;
                  featureSet.ObjectIdFieldName = metroFLI.ObjectIdField;
                  featureSet.DisplayFieldName = metroFLI.DisplayField;

                    FeatureSet clipFeatureSet = new FeatureSet(GetExtentAsPolygon(_InterfaceFeatureExtent));         

                    Geoprocessor gpTask = new Geoprocessor("http://myarcgisserver/ArcGIS/rest/services/Geoprocess/GPServer/Clip");
               
                    gpTask.JobCompleted += new EventHandler<JobInfoEventArgs>(gpTask_JobCompleted);
                    gpTask.Failed += new EventHandler<TaskFailedEventArgs>(gpTask_Failed);

                    List<GPParameter> gpParameters = new List<GPParameter>();
                    gpParameters.Add(new GPFeatureRecordSetLayer("Input_Features", featureSet));                   
                    gpParameters.Add(new GPFeatureRecordSetLayer("Clip_Features", clipFeatureSet));
                    gpTask.ProcessSpatialReference = _Map.SpatialReference;
                    gpTask.OutputSpatialReference = _Map.SpatialReference;                    
                   
                    gpTask.SubmitJobAsync(gpParameters);


Code block of Job_Completed event:
 void gpTask_JobCompleted(object sender, JobInfoEventArgs e)
        {
            Geoprocessor gpTask = (Geoprocessor)sender as Geoprocessor;
            gpTask.GetResultDataCompleted += new EventHandler<GPParameterEventArgs>(gpTask_GetResultDataCompleted);
            gpTask.Failed += new EventHandler<TaskFailedEventArgs>(gpTaskGetResults_Failed);
            gpTask.GetResultDataAsync(e.JobInfo.JobId, "Output_Feature_Class", e.UserState);

        }


Code block of GetResultDataCompleted:
 void gpTask_GetResultDataCompleted(object sender, GPParameterEventArgs e)
        {
            GPFeatureRecordSetLayer resultRecordSet = e.Parameter as GPFeatureRecordSetLayer;
            FeatureSet resultFeatureSet = resultRecordSet.FeatureSet;

           

            IList<Graphic> resultGraphics = resultFeatureSet.Features;

}


As I said in my previous post, each graphic in my resultGraphics has FID, shape.leng and shape.length as their only attributes ignoring the whole set of attributes that the input_features had.

Any further pointers is highly appreciated.

Thanks.
0 Kudos
SujaSudhan
New Contributor
Can someone from ESRI confirm if this is a bug?

Thanks!
0 Kudos
JenniferNery
Esri Regular Contributor
I checked the status of that NIMBUS bug and it has the following notes:
We don't recommend input feature set without schema set when publishing the GP service; and rest input field definition has to match the defined schema otherwise the output will only have OBJECTID and geometry fields. But customer would like to publish schema less feature set input and input schema/field definition on the rest directory so the GP service will have a much wider use (to take different input schema, etc).
0 Kudos