Select to view content in your preferred language

Passing a FeatureSet with Attributes to a Geoprocessor

3482
2
05-17-2011 02:19 PM
DeonaEvans
Emerging Contributor
How do you set up the FeatureSet to pass as an input parameter to a geoprocessing function and pass the attributes as well?  Given a graphic:Graphic, I need to pass it as an input.  The model for the geoprocessing tool was built with the same feature class (schema) as the graphic I'm trying to input.  I get a "Failed" on the status messages when I run the geoprocessor.

var featureSet:FeatureSet = new FeatureSet();
var features:Array = new Array();
var geom:Geometry = graphic.geometry;
var attrs:Object = graphic.attributes;
var obj:Object = {geometry:geom, attributes:attrs};
features.push(obj);
featureSet.features = features;
Tags (2)
0 Kudos
2 Replies
DeonaEvans
Emerging Contributor
I tried this another way.....

var featureSet:FeatureSet = new FeatureSet();
featureSet.features = new Array();
featureSet.features.push(graphic);
featureSet.spatialReference = map.extent.spatialReference;

This didn't work either. My gp tool only has one input parameter as show here:

[INDENT]Parameter: Feature_Class

Data Type: GPFeatureRecordSetLayer
Display Name: Feature Class
Direction: esriGPParameterDirectionInput
Default Value:

Geometry Type: esriGeometryPolygon
Spatial Reference: 4326
Fields:
FID (Type: esriFieldTypeOID, Alias: FID)
Shape (Type: esriFieldTypeGeometry, Alias: Shape)
OBJECTID (Type: esriFieldTypeInteger, Alias: OBJECTID)
Shape_Leng (Type: esriFieldTypeDouble, Alias: Shape_Leng)
NAME (Type: esriFieldTypeString, Alias: NAME)
MAX_RANGE (Type: esriFieldTypeString, Alias: MAX_RANGE)
MIN_RANGE (Type: esriFieldTypeString, Alias: MIN_RANGE)
WIDTH (Type: esriFieldTypeString, Alias: WIDTH)
AZIMUTH (Type: esriFieldTypeString, Alias: AZIMUTH)
LAT (Type: esriFieldTypeString, Alias: LAT)
LON (Type: esriFieldTypeString, Alias: LON)
CLASS (Type: esriFieldTypeString, Alias: CLASS)
COMMENTS (Type: esriFieldTypeString, Alias: COMMENTS)
BUFF_GEOM (Type: esriFieldTypeString, Alias: BUFF_GEOM)
BUFF_LYR (Type: esriFieldTypeString, Alias: BUFF_LYR)
BUFF_TYPE (Type: esriFieldTypeString, Alias: BUFF_TYPE)
CLIP_GEOM (Type: esriFieldTypeString, Alias: CLIP_GEOM)
CLIP_LYR (Type: esriFieldTypeString, Alias: CLIP_LYR)
CLIP_TYPE (Type: esriFieldTypeString, Alias: CLIP_TYPE)
MERGED (Type: esriFieldTypeInteger, Alias: MERGED)
SHOW_MIN (Type: esriFieldTypeInteger, Alias: SHOW_MIN)
THRT_TYPE (Type: esriFieldTypeString, Alias: THRT_TYPE)
THRT_ID (Type: esriFieldTypeInteger, Alias: THRT_ID)
TRIGRAPH (Type: esriFieldTypeString, Alias: TRIGRAPH)
COUNTRY (Type: esriFieldTypeString, Alias: COUNTRY)
SYSTEM_ID (Type: esriFieldTypeString, Alias: SYSTEM_ID)
SYSTEM (Type: esriFieldTypeString, Alias: SYSTEM)
FEAT_NAME (Type: esriFieldTypeString, Alias: FEAT_NAME)
Shape_Length (Type: esriFieldTypeDouble, Alias: Shape_Length)
Shape_Area (Type: esriFieldTypeDouble, Alias: Shape_Area)
Parameter Type: esriGPParameterTypeRequired[/INDENT]

When I don't send the attributes with the graphic, then it works. Otherwise it does not. What am I doing wrong?
0 Kudos
DeonaEvans
Emerging Contributor
I figured out what the problem was.  The input featureclass was expecting an FID (instead of OBJECTID) for the OID field.  The featureclass I was sending didn't have this.  The reason the FID entered the picture in the first place was I exported that layer using ArcMap and FID was introduced that that point.  I didn't even notice it.  So when I created the GP model and pointed to that featureclass (exported with FID) for the schema for the input parameter, FID was expected.
0 Kudos