# Extract the coordinates of polyline (wpf)

643
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;
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 = Convert.ToDouble(text);
mappoint = Convert.ToDouble(text);
}
}
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 by 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 by 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.671728,"math_prob":0.8308312,"size":2306,"snap":"2022-27-2022-33","text_gpt3_token_len":529,"char_repetition_ratio":0.1342311,"word_repetition_ratio":0.6605505,"special_character_ratio":0.23243712,"punctuation_ratio":0.17882353,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9581097,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"im_url_duplicate_count":[null,null,null,2,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-05T04:46:53Z\",\"WARC-Record-ID\":\"<urn:uuid:ee9c178b-1e22-4545-863c-07e4e66d3969>\",\"Content-Length\":\"216437\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:af7f5b7e-0fac-40bd-a3ba-38d9a5e8b9aa>\",\"WARC-Concurrent-To\":\"<urn:uuid:1fd60d07-8ede-4556-99f1-978cc848eba5>\",\"WARC-IP-Address\":\"13.32.151.10\",\"WARC-Target-URI\":\"https://community.esri.com/t5/arcgis-runtime-sdk-for-net-questions/extract-the-coordinates-of-polyline-wpf/td-p/1070263\",\"WARC-Payload-Digest\":\"sha1:BTO5W6EBNLRDNZRCKC3TDTZDEUZHRE7A\",\"WARC-Block-Digest\":\"sha1:GSSYOOVE6JVGF7YLDJQQDPX6YGNITXTK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104512702.80_warc_CC-MAIN-20220705022909-20220705052909-00558.warc.gz\"}"}