Tuesday, August 25, 2009

Changing the size and colour of placemarks in Google Earth

In follow up to my previous post I have now found out how to change the size and colour of my placemarks. The trick here is to create a "style" of placemark right at the top of the file. Again, this is pretty simple when you get down to it. This time you need to post a little bit of code at the top of the file, just after the <Document> tag:

<Style id="normalPlacemark">
<IconStyle>
<color>ffffff00</color>
<scale>5</scale>
</IconStyle>
</Style>

The id part of the opening <style> tag is important as it gives each style a name that we can then refer to later for each individual placemark. This allows the user to create different styles of placemark that can be used together in the same file (rather like CSS does for HTML). Colour (<color>) and size (<scale>) are then defined as elements of the <IconStyle> tag. Colours are in a hexadecimal format:

The range of values for any one color is 0 to 255 (00 to ff). For alpha, 00 is fully transparent and ff is fully opaque. The order of expression is aabbggrr, where aa=alpha (00 to ff); bb=blue (00 to ff); gg=green (00 to ff); rr=red (00 to ff). For example, if you want to apply a blue color with 50 percent opacity to an overlay, you would specify the following: 7fff0000, where alpha=0x7f, blue=0xff, green=0x00, and red=0x00.

Whereas scale is just a number.

Now we just need to make an addition to our <placemark> tag to state that we want to use this style:

<Placemark>
<name>110_671B</name>
<styleUrl>#normalPlacemark</styleUrl>
<Point>
<coordinates>-58.73,15.52,-1622</coordinates>
</Point>
</Placemark>

So now I am able to plot my holes as giant green pushpins:

Unfortunately it is not easy to modify the colours of the pushpin icon as it has a yellow overlay to it and I have yet to work out if there is an easier way to colour placemarks exactly as I want. This will have to wait until next time.


Update:

OK, this last bit has been solved by someone who asked to be referred to as "my clever volcanologist friend." Basically a white pushpin needs to be called in the <style> tag like this:

<Style id="normalPlacemark">
<IconStyle>
<color>ffffff00</color>
<scale>5</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/wht-pushpin.png</href>
</Icon>
</IconStyle>
</Style>

Friday, August 21, 2009

Multiple placemarks in Google Earth

In my current job I am producing a database of fossil occurrences from the North Atlantic deep sea record and one of the fields in the data base is latitude-longitude for each of the IODP holes included. For a while now I've been wanting to export this data to a KML file (Google Earth's HTML-like file format). At first I figured this would be easy. I created an SQL query in Access to get my data out as a comma-delimited file which I then import into R. All I need to do is create a table of unique lat-long occurrences (holes) and their names then format them in the KML-style. However, I came up against a bit of a snag.

The first part is easy. Just set the header of the file to:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">

The footer to:

</kml>

Then each hole is entered as a Placemark using the following syntax:

  <Placemark>
<name>Hole name</name>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>

Where the coordinates are longitude, latitude and altitude respectively.

Simple.

But once you import the whole file into Google Earth it only shows the first point (hole) and skips all the others. Google's own code site wasn't much use on this, and the few forum's I looked at seemed to be missing a proper answer to this problem. In the end I figured out that all that needs to be done is wrap the placemarks in a simple

<Document></Document>

tag.

Lesson learned, and shared.

(Image and original code below.)


<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark><name>110_671B</name><Point><coordinates>-58.73,15.52,-1622</coordinates></Point></Placemark>
<Placemark><name>110_672A</name><Point><coordinates>-58.6,15.5,-1581</coordinates></Point></Placemark>
<Placemark><name>110_673B</name><Point><coordinates>-58.64,15.53,-1875</coordinates></Point></Placemark>
<Placemark><name>110_674A</name><Point><coordinates>-58.9,15.5,-2003</coordinates></Point></Placemark>
<Placemark><name>110_676A</name><Point><coordinates>-58.7,15.53,-1494</coordinates></Point></Placemark>
<Placemark><name>149_897A</name><Point><coordinates>-12.47,40.83,-5320</coordinates></Point></Placemark>
<Placemark><name>149_899B</name><Point><coordinates>-12.26,40.77,-5291</coordinates></Point></Placemark>
<Placemark><name>149_900A</name><Point><coordinates>-11.6,40.68,-5037</coordinates></Point></Placemark>
<Placemark><name>149_901A</name><Point><coordinates>-11.05,40.67,-4719</coordinates></Point></Placemark>
<Placemark><name>152_914A</name><Point><coordinates>-39.72,63.46,-533</coordinates></Point></Placemark>
<Placemark><name>152_919A</name><Point><coordinates>-37.46,62.67,-2088</coordinates></Point></Placemark>
<Placemark><name>157_950A</name><Point><coordinates>-25.6,31.15,-5438</coordinates></Point></Placemark>
<Placemark><name>157_951A</name><Point><coordinates>-24.87,32.03,-5437</coordinates></Point></Placemark>
<Placemark><name>157_952A</name><Point><coordinates>-24.5,30.79,-5432</coordinates></Point></Placemark>
<Placemark><name>159_959A</name><Point><coordinates>-2.73,3.62,-2091</coordinates></Point></Placemark>
<Placemark><name>159_960A</name><Point><coordinates>-2.73,3.58,-2048</coordinates></Point></Placemark>
<Placemark><name>159_961A</name><Point><coordinates>-3.05,3.44,-3292</coordinates></Point></Placemark>
<Placemark><name>159_962B</name><Point><coordinates>-3.18,3.25,-4637</coordinates></Point></Placemark>
<Placemark><name>160_966F</name><Point><coordinates>32.7,33.79,-923</coordinates></Point></Placemark>
<Placemark><name>101_627B</name><Point><coordinates>-78.29,27.63,-1026</coordinates></Point></Placemark>
<Placemark><name>160_967E</name><Point><coordinates>32.72,34.06,-2553</coordinates></Point></Placemark>
<Placemark><name>160_969B</name><Point><coordinates>24.88,33.84,-2202</coordinates></Point></Placemark>
<Placemark><name>164_994C</name><Point><coordinates>-75.54,31.78,-2799</coordinates></Point></Placemark>
<Placemark><name>165_998A</name><Point><coordinates>-82.93,19.48,-3180</coordinates></Point></Placemark>
<Placemark><name>101_628A</name><Point><coordinates>-78.3,27.5,-964</coordinates></Point></Placemark>
<Placemark><name>105_646B</name><Point><coordinates>-48.36,58.2,-3106</coordinates></Point></Placemark>
<Placemark><name>101_635B</name><Point><coordinates>-77.3,25.4,-3081</coordinates></Point></Placemark>
<Placemark><name>103_637A</name><Point><coordinates>-12.9,42.1,-1243</coordinates></Point></Placemark>
<Placemark><name>101_626C</name><Point><coordinates>-79.54,25.6,-844</coordinates></Point></Placemark>
<Placemark><name>149_898A</name><Point><coordinates>-12.12,40.68,-5279</coordinates></Point></Placemark>
<Placemark><name>103_638B</name><Point><coordinates>-12.19,42.15,-1890</coordinates></Point></Placemark>
<Placemark><name>103_639A</name><Point><coordinates>-12.24,42.14,-1829</coordinates></Point></Placemark>
<Placemark><name>103_640A</name><Point><coordinates>-12.5,42,-1363</coordinates></Point></Placemark>
<Placemark><name>103_641A</name><Point><coordinates>-12.18,42.15,-1918</coordinates></Point></Placemark>
<Placemark><name>104_642B</name><Point><coordinates>2.92,67.22,-1283</coordinates></Point></Placemark>
<Placemark><name>104_643A</name><Point><coordinates>1,67.7,-2769</coordinates></Point></Placemark>
<Placemark><name>104_644A</name><Point><coordinates>4.57,66.67,-1215</coordinates></Point></Placemark>
<Placemark><name>107_651A</name><Point><coordinates>12.8,40.2,-2974</coordinates></Point></Placemark>
<Placemark><name>107_652A</name><Point><coordinates>12.1,40.4,-3094</coordinates></Point></Placemark>
<Placemark><name>107_653A</name><Point><coordinates>11.44,40.26,-2821</coordinates></Point></Placemark>
<Placemark><name>107_654A</name><Point><coordinates>10.7,40.6,-2209</coordinates></Point></Placemark>
<Placemark><name>107_655A</name><Point><coordinates>12.46,40.17,-3234</coordinates></Point></Placemark>
<Placemark><name>108_657A</name><Point><coordinates>-20.94,21.33,-2332</coordinates></Point></Placemark>
<Placemark><name>108_658A</name><Point><coordinates>-18.58,20.74,-2264</coordinates></Point></Placemark>
<Placemark><name>108_659B</name><Point><coordinates>-21.02,18.07,-3073</coordinates></Point></Placemark>
<Placemark><name>108_660A</name><Point><coordinates>-19.24,10.01,-2221</coordinates></Point></Placemark>
<Placemark><name>108_661A</name><Point><coordinates>-19.38,9.44,-2541</coordinates></Point></Placemark>
<Placemark><name>108_662A</name><Point><coordinates>-11.73,-1.39,-2740</coordinates></Point></Placemark>
<Placemark><name>108_663A</name><Point><coordinates>-11.87,-1.19,-2856</coordinates></Point></Placemark>
<Placemark><name>108_664B</name><Point><coordinates>-23.22,0.1,-2747</coordinates></Point></Placemark>
<Placemark><name>108_665A</name><Point><coordinates>-19.66,2.95,-1813</coordinates></Point></Placemark>
<Placemark><name>108_666A</name><Point><coordinates>-20.2,3.5,-2037</coordinates></Point></Placemark>
<Placemark><name>108_667A</name><Point><coordinates>-21.91,4.56,-3029</coordinates></Point></Placemark>
<Placemark><name>108_668A</name><Point><coordinates>-20.92,4.76,-2690</coordinates></Point></Placemark>
<Placemark><name>108_668B</name><Point><coordinates>-20.9,4.8,-2693</coordinates></Point></Placemark>
<Placemark><name>174A_1071A</name><Point><coordinates>-72.72,39.38,-88</coordinates></Point></Placemark>
<Placemark><name>174A_1072A</name><Point><coordinates>-72.69,39.36,-98</coordinates></Point></Placemark>
<Placemark><name>174A_1073A</name><Point><coordinates>-72.27,39.22,-639</coordinates></Point></Placemark>
<Placemark><name>1_1</name><Point><coordinates>-92.18,25.85,-2827</coordinates></Point></Placemark>
<Placemark><name>1_2</name><Point><coordinates>-92.05,23.04,-3572</coordinates></Point></Placemark>
<Placemark><name>1_3</name><Point><coordinates>-92.04,23.03,-3747</coordinates></Point></Placemark>
<Placemark><name>1_4</name><Point><coordinates>-73.79,24.47,-5319</coordinates></Point></Placemark>
<Placemark><name>1_5</name><Point><coordinates>-73.64,24.72,-5354</coordinates></Point></Placemark>
<Placemark><name>1_6A</name><Point><coordinates>-67.64,30.83,-5124</coordinates></Point></Placemark>
<Placemark><name>1_7</name><Point><coordinates>-68.29,30.13,-5182</coordinates></Point></Placemark>
<Placemark><name>4_25</name><Point><coordinates>-39.24,-0.51,-1916</coordinates></Point></Placemark>
<Placemark><name>4_26A</name><Point><coordinates>-44.04,10.89,-5169</coordinates></Point></Placemark>
<Placemark><name>4_27</name><Point><coordinates>-56.87,15.85,-5251</coordinates></Point></Placemark>
<Placemark><name>4_28</name><Point><coordinates>-65.62,20.58,-5251</coordinates></Point></Placemark>
<Placemark><name>105_647A</name><Point><coordinates>-45.26,53.33,-2695</coordinates></Point></Placemark>
<Placemark><name>11_100</name><Point><coordinates>-73.79,24.68,-5325</coordinates></Point></Placemark>
<Placemark><name>11_101A</name><Point><coordinates>-74.43,25.19,-4868</coordinates></Point></Placemark>
<Placemark><name>13_125</name><Point><coordinates>20.42,34.62,-2782</coordinates></Point></Placemark>
<Placemark><name>14_137</name><Point><coordinates>-27.06,25.92,-5361</coordinates></Point></Placemark>
<Placemark><name>14_141</name><Point><coordinates>-23.99,19.41,-4148</coordinates></Point></Placemark>
<Placemark><name>150_905A</name><Point><coordinates>-72.28,38.61,-2698</coordinates></Point></Placemark>
<Placemark><name>151_910A</name><Point><coordinates>6.59,80.26,-556</coordinates></Point></Placemark>
<Placemark><name>151_911A</name><Point><coordinates>8.22,80.47,-902</coordinates></Point></Placemark>
<Placemark><name>152_915A</name><Point><coordinates>-39.78,63.47,-533</coordinates></Point></Placemark>
<Placemark><name>152_918A</name><Point><coordinates>-38.63,63.09,-1869</coordinates></Point></Placemark>
<Placemark><name>38_338</name><Point><coordinates>5.38,67.78,-1297</coordinates></Point></Placemark>
<Placemark><name>39_354</name><Point><coordinates>-44.19,5.89,-4045</coordinates></Point></Placemark>
<Placemark><name>41_367</name><Point><coordinates>-20.04,12.48,-4748</coordinates></Point></Placemark>
<Placemark><name>41_370</name><Point><coordinates>-10.77,32.83,-4214</coordinates></Point></Placemark>
<Placemark><name>44_390A</name><Point><coordinates>-76.11,30.14,-2665</coordinates></Point></Placemark>
<Placemark><name>47_398D</name><Point><coordinates>-10.71,40.96,-3910</coordinates></Point></Placemark>
<Placemark><name>49_407</name><Point><coordinates>-30.57,63.93,-2472</coordinates></Point></Placemark>
<Placemark><name>49_408</name><Point><coordinates>-28.91,63.37,-1624</coordinates></Point></Placemark>
<Placemark><name>49_410</name><Point><coordinates>-29.47,45.5,-2975</coordinates></Point></Placemark>
<Placemark><name>76_534A</name><Point><coordinates>-75.38,28.34,-4971</coordinates></Point></Placemark>
<Placemark><name>77_537</name><Point><coordinates>-85.46,23.93,-3123</coordinates></Point></Placemark>
<Placemark><name>77_538A</name><Point><coordinates>-85.16,23.84,-2742</coordinates></Point></Placemark>
<Placemark><name>77_540</name><Point><coordinates>-84.37,23.82,-2926</coordinates></Point></Placemark>
<Placemark><name>79_545</name><Point><coordinates>-9.36,33.66,-3142</coordinates></Point></Placemark>
<Placemark><name>79_547A</name><Point><coordinates>-9.34,33.78,-3938</coordinates></Point></Placemark>
<Placemark><name>80_548</name><Point><coordinates>-12.16,48.91,-1251</coordinates></Point></Placemark>
<Placemark><name>80_549A</name><Point><coordinates>-13.09,49.08,-2513</coordinates></Point></Placemark>
<Placemark><name>82_558</name><Point><coordinates>-37.34,37.77,-3754</coordinates></Point></Placemark>
<Placemark><name>82_563</name><Point><coordinates>-43.76,33.64,-3786</coordinates></Point></Placemark>
<Placemark><name>93_603</name><Point><coordinates>-70.02,35.49,-4633</coordinates></Point></Placemark>
<Placemark><name>93_603C</name><Point><coordinates>-70.03,35.49,-4633</coordinates></Point></Placemark>
<Placemark><name>93_605</name><Point><coordinates>-72.6,38.74,-2194</coordinates></Point></Placemark>
<Placemark><name>94_606</name><Point><coordinates>-35.49,37.33,-3007</coordinates></Point></Placemark>
<Placemark><name>94_607</name><Point><coordinates>-32.95,41,-3427</coordinates></Point></Placemark>
<Placemark><name>94_608</name><Point><coordinates>-23.08,42.83,-3526</coordinates></Point></Placemark>
<Placemark><name>94_609</name><Point><coordinates>-24.23,49.87,-3884</coordinates></Point></Placemark>
<Placemark><name>94_610</name><Point><coordinates>-18.88,53.22,-2417</coordinates></Point></Placemark>
<Placemark><name>95_612</name><Point><coordinates>-72.77,38.82,-1386</coordinates></Point></Placemark>
<Placemark><name>210_1276A</name><Point><coordinates>-44.78,45.4,-4549</coordinates></Point></Placemark>
<Placemark><name>173_1067A</name><Point><coordinates>-11.59,40.68,-5021</coordinates></Point></Placemark>
<Placemark><name>2_8A</name><Point><coordinates>-67.55,35.38,-5184</coordinates></Point></Placemark>
<Placemark><name>2_9</name><Point><coordinates>-59.19,32.77,-4973</coordinates></Point></Placemark>
<Placemark><name>2_10</name><Point><coordinates>-52.21,32.86,-4712</coordinates></Point></Placemark>
<Placemark><name>2_11</name><Point><coordinates>-44.74,29.94,-3571</coordinates></Point></Placemark>
<Placemark><name>2_12C</name><Point><coordinates>-26,19.69,-4557</coordinates></Point></Placemark>
<Placemark><name>173_1068A</name><Point><coordinates>-11.61,40.68,-5044</coordinates></Point></Placemark>
<Placemark><name>3_13</name><Point><coordinates>-18.22,6.04,-4585</coordinates></Point></Placemark>
<Placemark><name>4_23</name><Point><coordinates>-31.04,-6.14,-5079</coordinates></Point></Placemark>
<Placemark><name>4_24</name><Point><coordinates>-30.89,-6.27,-5148</coordinates></Point></Placemark>
<Placemark><name>4_29</name><Point><coordinates>-69.32,14.78,-4247</coordinates></Point></Placemark>
<Placemark><name>4_30</name><Point><coordinates>-63.38,12.88,-1218</coordinates></Point></Placemark>
<Placemark><name>4_31</name><Point><coordinates>-72.02,14.94,-3369</coordinates></Point></Placemark>
<Placemark><name>173_1069A</name><Point><coordinates>-11.77,40.72,-5075</coordinates></Point></Placemark>
<Placemark><name>101_631A</name><Point><coordinates>-75.7,23.6,-1092</coordinates></Point></Placemark>
<Placemark><name>101_632A</name><Point><coordinates>-75.4,23.8,-1997</coordinates></Point></Placemark>
<Placemark><name>101_633A</name><Point><coordinates>-75.6,23.7,-1679</coordinates></Point></Placemark>
<Placemark><name>151_908A</name><Point><coordinates>1.36,78.38,-1274</coordinates></Point></Placemark>
<Placemark><name>151_909A</name><Point><coordinates>3.07,78.58,-2519</coordinates></Point></Placemark>
<Placemark><name>151_912A</name><Point><coordinates>5.45,79.95,-1037</coordinates></Point></Placemark>
<Placemark><name>151_913A</name><Point><coordinates>6.94,75.48,-3319</coordinates></Point></Placemark>
<Placemark><name>152_916A</name><Point><coordinates>-39.8,63.48,-514</coordinates></Point></Placemark>
<Placemark><name>154_925A</name><Point><coordinates>-43.48,4.2,-3042</coordinates></Point></Placemark>
<Placemark><name>154_929E</name><Point><coordinates>-43.74,5.97,-4356</coordinates></Point></Placemark>
<Placemark><name>157_953A</name><Point><coordinates>-15.14,28.65,-3578</coordinates></Point></Placemark>
<Placemark><name>157_954B</name><Point><coordinates>-15.53,28.43,-3485</coordinates></Point></Placemark>
</Document>
</kml>

Wednesday, August 05, 2009

For your procrastinating pleasure

Here's what I've been wasting my internet time on this past few weeks.

Photography

I've always wanted to know how to photograph fireworks, especially when you can get results like this awesome picture.

Animals

I tend to come across lots of dinosaur stuff, including useful pointers on why you really should keep your T. rex off crack, a case of some dinosaur revisionism and this, frankly confusing, t-shirt. I also find this simple joke quite amusing.

Entertainment

If you haven't already come across it, I really like the idea of this wedding entrance. Some more creativity comes into play in a performance of 80's classic Africa and finally there was this darkly comic animated feature, Billy's balloon. I also recommend checking out the art of this guy.

Science

First up is this cool toilet paper experiment. That nice chap Bill Gates has also purchased and made freely available these Richard Feynman lectures. Then you can make friends with your glands.

Humour

Despite being a throwback to the early part of the internet age animated gifs still seem to be going strong, my favourite being this one. One wonders what the elephant makes of it. I enjoyed several of these workplace training videos. Ten is probably the funniest, number four is just wrong (who says such things?) and two is perhaps painfully true. However, I found this collection of 1950's propaganda to be more disturbing than funny. For those with a non-PC sense of humour this garage door opener should appeal, although I much preferred the Wayne's World echoing twist to this fast food folk song. Finally this "remix" of an NWA classic is just awesome.

Geekdom

One of the joys of this internet age is that the powerbase of the world is shifting ever more towards the geeks of this world. I found this short talk by the guy who brought you captcha (you'll know what it is when you see it) to be really interesting. Although this vision of the future of dating may be less encouraging. Finally, this really appealed to my sense of humour.

About Me

My photo
Currently I am founding member, president elect and entire membership of SWEMP (the Society of Wonky-Eyed Macroevolutionary Palaeobiologists). In my spare time I get paid to do research on very dead organisms and think about the really big questions in life, such as: What is the ultimate nature of reality? Why is there no room for free will in science? and What are the implications of having a wardrobe that consists entirely of hotpants?