Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am quite sure there is a function in NTS that actually gets us a point at a distance along a line starting at first vertex. I am using NetTopologySuite version 1.12.1.

In Shapely, the python version of JTS, it is quite simple to use

>>> LineString([(0, 0), (0, 1), (1, 1)]).interpolate(0.75, normalized=True).wkt
'POINT (0.5000000000000000 1.0000000000000000)'

I am trying to do the same thing using NTS but i hightly doubt they could be using a jargon word for this. I tried LinearReferencing namespace, but could not find a suitable method.

Does anyone have idea on this?

share|improve this question
1  
PointAlongSegmentByFraction ? it is in LinearLocation –  simplexio Jan 9 '13 at 13:53
    
@simplexio - would you mind posting this as an answer? –  vinayan Jan 10 '13 at 7:00

2 Answers 2

up vote 2 down vote accepted

PointAlongSegmentByFraction(Coordinate p0, Coordinate p1, double fraction) in LinearLocation.cs

share|improve this answer

complete code based on help of @simplexio's answer..

string wkt = "LINESTRING (0 0, 10 0, 20 0)";
WKTReader rdr = new WKTReader();
IGeometry g1 = rdr.Read(wkt);

ILineString lstring = (ILineString)g1;
Coordinate pt1 = lstring.GetCoordinateN(0);
Coordinate pt2 = lstring.GetCoordinateN(lstring.NumPoints - 1);

Coordinate c = LinearLocation.PointAlongSegmentByFraction(pt1,pt2, 0.25);
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.