# Extract the coordinates of polyline (wpf)

138
2
06-20-2021 06:24 PM
New Contributor

I would like to extract the coordinates of polyline one by one later.

Is there a way?

here is my Code

foreach (CableGPSInfo gpsinfo in StaticCommon.CableGPSInfoList)
{
string[] gps = gpsinfo.GPS.Split(';');
double[] mappoint = new double[2];
Dictionary<double, double> posdic = new Dictionary<double, double>();
foreach (string point in gps)
{
string[] text = point.Split(',');
//if(gpsinfo.Fiberstart==)
if (text.Length > 1)
{
mappoint[0] = Convert.ToDouble(text[0]);
mappoint[1] = Convert.ToDouble(text[1]);
}
}
polyline = new Esri.ArcGISRuntime.Geometry.Polyline(points);
points.Clear();

}

What I'm saying is that I want to extract the coordinate value of polyline drawn in overlay graphic.

1 Solution

Accepted Solutions
Esri Contributor

Hi Sung Hyun Kim. Every polyline has a parts property that contains a collection of read only parts . Each of these parts has a collection of points. You can project these points to Wgs84 to get latitude and longitude values for each point. This code snippet demonstrates getting coordinates from all of the points in the parts of a polyline.

``````foreach (ReadOnlyPart part in polyline.Parts)
{
foreach (MapPoint point in part.Points)
{
MapPoint projectedPoint = GeometryEngine.Project(point, SpatialReferences.Wgs84) as MapPoint;
double longitude = projectedPoint.X;
double latitude = projectedPoint.Y;

// Use the longitude / latitude values.
}
}``````

I hope this helps, please let me know if you have any more questions.

Zack

2 Replies
Esri Contributor

Hi Sung Hyun Kim. Every polyline has a parts property that contains a collection of read only parts . Each of these parts has a collection of points. You can project these points to Wgs84 to get latitude and longitude values for each point. This code snippet demonstrates getting coordinates from all of the points in the parts of a polyline.

``````foreach (ReadOnlyPart part in polyline.Parts)
{
foreach (MapPoint point in part.Points)
{
MapPoint projectedPoint = GeometryEngine.Project(point, SpatialReferences.Wgs84) as MapPoint;
double longitude = projectedPoint.X;
double latitude = projectedPoint.Y;

// Use the longitude / latitude values.
}
}``````

I hope this helps, please let me know if you have any more questions.

Zack

New Contributor

Thank you. That's the information I wanted.