This project has moved and is read-only. For the latest updates, please go here.

Extract coordinates from polygon

Jul 27, 2015 at 1:25 AM
Edited Jul 27, 2015 at 1: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="" xmlns:gx="" xmlns:kml="" xmlns: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 7: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,