Here I want the midpoint of every polyline and add that point to List.

List<IPoint> pList = new ArrayList<IPoint>();
Polyline polyline = null;       
IPoint point = null;
for(int i=0;i<pFeatureLayerList.size();i++)
    IFeatureClass pFeatureClass = pFeatureLayerList.get(i).getFeatureClass();
    int numFeatures = pFeatureClass.featureCount(null);     
        for(int j=0; j<numFeatures; j++)
             IFeature pFeature = pFeatureClass.getFeature(j);
             polyline = (Polyline)pFeature.getShape();
             point = polyline.getCentroidEx();
  • Do you mean the centre-point of your geometry or the point at the n / 2-position of the corresponding pointlist. If the latter how would you handle multipart-geometries? – HimBromBeere Mar 31 '16 at 10:24
  • Here I need Centre-point of line geometry, the output should be point variable. – mahesh Mar 31 '16 at 10:27
  • And where is the problem? It should work with that piece of code, as far as I can estimate. – HimBromBeere Mar 31 '16 at 10:29
  • 1
    is this a duplicate of: gis.stackexchange.com/questions/187415/… ? – nmtoken Mar 31 '16 at 10:33
  • I´d rather do not flag this as a duplicate because the mentioned question seems quite worse posted than this one, making it a duplicate of this one. I think the linked one is going to be deleted soon, so the duplicate would link to nothing. – HimBromBeere Mar 31 '16 at 10:35

Try ICurve.QueryPoint with asRatio = true, and distanceAlongCurve = 0.5:

Copies to outPoint the properties of a point on the curve at a specified distance from the beginning of the curve.

| improve this answer | |

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.