2

I've been given a KML file which should consist of linear features (train lines), but for some reason they're all represented as <Polygon> types. Each appears to have the right data, from end of the route to the other, but they end up getting displayed with a straight line back to the start.

Is there any simple way to force them back to lines, perhaps using OGR2OGR? Here's an example:

        <Placemark>
            <styleUrl>#style013</styleUrl>
            <Polygon>
                <altitudeMode>relativeToGround</altitudeMode>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            115.964098859778,-32.0315028760304,0 115.964341724802,-32.0317245932987,0 115.964542217656,-32.0319358011368,0 115.964647923659,-32.0321468844092,0 115.964711196528,-32.0324108954529,0 115.964711217686,-32.0326220438325,0 115.964689983026,-32.0329599395964,0 115.964552921763,-32.0335405684244,0 115.96437328518,-32.0338573549601,0 115.964109337303,-32.0342690027496,0 115.963761062567,-32.0346703082917,0 115.962335595171,-32.0363701095327,0 115.961522621044,-32.0373097675095,0 115.960730829958,-32.0381861099762,0 115.959991839264,-32.0390940652384,0 115.959601168599,-32.0395797019635,0 115.95828143181,-32.0410895001365,0 115.957225616643,-32.0423352695285,0 115.956159387375,-32.0436127783309,0 115.955378027477,-32.0445207271644,0 115.954839524041,-32.0451331177952,0 115.954227198969,-32.0456821560527,0 115.953108092682,-32.0466006683283,0 115.952590699426,-32.0470123779511,0 115.95217894983,-32.0473714061235,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
2

Ok, this turned out to be as simple as text search and replace:

<Polygon><outerBoundaryIs><LinearRing>

to

<LineString>

and

</Polygon></outerBoundaryIs></LinearRing>

to

</LineString>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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