Extract coordinates from polygon

Jul 27, 2015 at 12:25 AM
Edited Jul 27, 2015 at 12:47 AM

I need to extract the coordinates of a polygon from .KML file.
Following the example below of .kml, need to extract the coordinates of the tag <coordinates>

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <name>poligono kml.kml</name>
    <Style id="s_ylw-pushpin">
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
    <StyleMap id="m_ylw-pushpin">
    <Style id="s_ylw-pushpin_hl">
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
        <name>poligono kml</name>
                        -46.72666928318849,-23.52792136167547,0 -46.71975617107682,-23.53737144188922,0 -46.70524161260465,-23.53625596387829,0 
Converting the extracted coordinates to the following format string

"-46.72666928318849 -23.52792136167547, -46.71975617107682 23.53737144188922, -46.70524161260465 -23.53625596387829"

Longitude and latitude separated by whitespace, and separated with commas each point of the polygon.

Is there any solution that I can do this using the SharpKml?

Thank you for attention
Jul 27, 2015 at 6:35 AM
You should be able to use the library to extract that information, take a quick look at the Extracting information from a KML file example that will show you a quick way of finding the Placemarks - from there you will need to cast the Geometry property to a Polygon to get hold of the OuterBoundary that contains the coordinates.

Hope that points you in the right direction,