colorise single track in kml file

此生再无相见时 提交于 2019-11-29 20:26:54

问题


I am trying to have a gx:track's line to have different colour in different part in the track depending on some conditions, but I am unable to find way to colour part of a track. I am using C# to generate the kml file. BTW my gx:track's has extendedData.

I know I can apply lineStyle to the gx:track but that will only apply to the whole track, but I would like to have different colour along the track's line.

Thanks in advance.

Terry


回答1:


As previous answer says, you have to split track into segments and color each segment individually. There is no other way to do this using KML. But remember that this can create very large KML files for long tracks! So try to save some space by using shared styles.

I would recommend creating one "gx:track" with low "draworder" for whole track and collection of placemarks with different colors and high "draworder" for every small segment of track.

You can examine results of this approach here: http://www.zonefivesoftware.com/sporttracks/plugins/?p=dobrou-extensions (it is a plugin for application SportTracks).

It's my tool for visualization of GPS tracks. It does track coloring by creating placemark, with own color style, for every track segment.

Here you can see examples tracks colored in KML:

Track colored by speed #1 KMZ

Track colored by speed #2 KMZ

Track colored by elevation KMZ




回答2:


As you discovered, you can only style complete tracks. If you want different segments to have different colors, you need to break the track up, then style each segment.




回答3:


I used simplekml which uses Python to generate KML code. As the other answers point out you have to split the line into multiple linestrings each of which has a different style. You can use a common set of styles for making the size of kml smaller though.

the end coordinates of one line is the start coordinates of the next line.



来源:https://stackoverflow.com/questions/11874858/colorise-single-track-in-kml-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!