Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a geo service that seems to finally be working. I have the service setup with a list of Polylines as the returned object. This is what I'm trying to implement but it doesn't work:

 IPointCollection points = new MultipointClass();
 messages.AddMessage(string.Format("Computing distance from origin to target {0}", index));
 Polyline result = distanceComputer.CostPathAsPolyline(points,
     hydrographyRasterDataset) as Polyline;
 IGeometry feature = result as IGeometry;
 messages.AddMessage("Getting new row for output.");
 IFeatureBuffer buffer = outputClass.CreateFeatureBuffer();
 IFeature polyline = (IFeature) buffer;
 messages.AddMessage("adding shape");
 polyline.Shape = feature;
 messages.AddMessage("adding object");
 polyline.set_Value(polyline.Fields.FindField("SHAPE"), result);
 messages.AddMessage("adding length");
 polyline.set_Value(polyline.Fields.FindField("SHAPE_Length"), ((IPolyline)result).Length);
 messages.AddMessage("Commiting to output");

When I try setting the value for "SHAPE" I get an exception and the message is:

This spatial reference object cannot be defined from the available information

So how exactly to I set the polyline in the return object (basically adding rows of Polylines to the OutputFeatureSet) so that it does not blow up?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.