Search code examples
kmlgoogle-earth

KML for Google Earth: How to set Icon size to specific physical distance?


I have a collection of GPS data points with timestamps that I'm using to create an animation of a person's motion along a path. The GPS data also has an accuracy figure (in meters) that I'd like to represent on the map using the icon size. I'd like to have the Icon be a circle centered on the person's lat/long with a radius equal to the accuracy of the GPS measurement.

I've searched the forums/Google and can't find a way to specify icon in size in physical distance. Is there a way to do this? I've read about the <scale> attribute which allows you to resize an icon, but it's not obvious to me how you can calculate the right scale number to correspond to, say, 10 meters on the map. Does anyone have any experience creating icons of a specific physical size?


Solution

  • the icon sizing is to set the number of pixels.

    another method is to use a model in your kml

    https://developers.google.com/kml/documentation/kmlreference#model

    this will be less computational intense than calculating your lon lats for the circle

    create a simple size scale mode with Sketchup, a cylinder 1 meter in diameter

    and you can use

     <Scale> 
        <x>1</x>                
        <y>1</y>               
        <z>1</z>               
      </Scale>
    

    setting the x and y to the accuracy

    an example A screen capture from Google Earth

    the kml :

    <?xml version="1.0" encoding="utf-16"?>
    <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">
      <Document>
        <name>TestScaleSize</name> 
          <name>PathPoints</name> 
          <Placemark>
            <name>Point1</name>
            <TimeStamp> <when>2012-06-20T12:00</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26400</latitude> <altitude>0</altitude></Location>
               <Scale><x>8</x><y>8</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point2</name>
            <TimeStamp> <when>2012-06-20T12:01</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26405</latitude> <altitude>0</altitude></Location>
               <Scale><x>5</x><y>5</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point3</name>
            <TimeStamp> <when>2012-06-20T12:02</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26410</latitude> <altitude>0</altitude></Location>
               <Scale><x>4</x><y>4</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point4</name>
            <TimeStamp> <when>2012-06-20T12:03</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26415</latitude> <altitude>0</altitude></Location>
               <Scale><x>3</x><y>3</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point5</name>
            <TimeStamp> <when>2012-06-20T12:04</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26420</latitude> <altitude>0</altitude></Location>
               <Scale><x>2</x><y>2</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point6</name>
            <TimeStamp> <when>2012-06-20T12:05</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26425</latitude> <altitude>0</altitude></Location>
               <Scale><x>1</x><y>1</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
           <Placemark>
            <name>Point7</name>
            <TimeStamp> <when>2012-06-20T12:06</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26430</latitude> <altitude>0</altitude></Location>
               <Scale><x>1</x><y>1</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point8</name>
            <TimeStamp> <when>2012-06-20T12:07</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26435</latitude> <altitude>0</altitude></Location>
               <Scale><x>3</x><y>3</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point9</name>
            <TimeStamp> <when>2012-06-20T12:08</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26440</latitude> <altitude>0</altitude></Location>
               <Scale><x>1</x><y>1</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
          <Placemark>
            <name>Point10</name>
            <TimeStamp> <when>2012-06-20T12:09</when></TimeStamp>
            <Model>
              <altitudeMode>relativeToGround</altitudeMode>
              <Location><longitude>-123.145702</longitude><latitude> 49.26445</latitude> <altitude>0</altitude></Location>
               <Scale><x>1</x><y>1</y><z>1</z></Scale>
              <Link><href>scaleIcon.dae</href></Link>
            </Model>
          </Placemark>
      </Document>
    </kml>
    

    the xml for the model is as follows save it as "scaleIcon.dae" and have both in the same folder,

    ![<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
    <COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
        <asset>
            <contributor>
                <authoring_tool>Google SketchUp 8.0.11752</authoring_tool>
            </contributor>
            <created>2012-06-21T02:47:22Z</created>
            <modified>2012-06-21T02:47:22Z</modified>
            <unit meter="0.02539999969303608" name="inch" />
            <up_axis>Z_UP</up_axis>
        </asset>
        <library_visual_scenes>
            <visual_scene id="ID1">
                <node name="SketchUp">
                    <instance_geometry url="#ID2">
                        <bind_material>
                            <technique_common>
                                <instance_material symbol="Material2" target="#ID3">
                                    <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" />
                                </instance_material>
                            </technique_common>
                        </bind_material>
                    </instance_geometry>
                </node>
            </visual_scene>
        </library_visual_scenes>
        <library_geometries>
            <geometry id="ID2">
                <mesh>
                    <source id="ID5">
                        <float_array id="ID8" count="288">-38.02857583815229 10.18972618513862 0 -38.0285758381523 -10.1897261851386 0 -39.37007874015748 4.821444091131312e-015 0 -34.09548833797003 -19.68503937007873 0 -34.09548833797002 19.68503937007876 0 -27.8388496530137 -27.83884965301367 0 -27.83884965301368 27.83884965301369 0 -19.68503937007876 -34.09548833797002 0 -19.68503937007873 34.09548833797003 0 -10.18972618513864 -38.02857583815229 0 -10.18972618513861 38.0285758381523 0 -7.232166136696968e-015 -39.37007874015748 0 2.410722045565656e-015 39.37007874015748 0 10.1897261851386 -38.0285758381523 0 10.18972618513862 38.02857583815229 0 19.68503937007872 -34.09548833797004 0 19.68503937007874 34.09548833797003 0 27.83884965301368 -27.83884965301369 0 27.83884965301369 27.83884965301368 0 34.09548833797002 -19.68503937007876 0 34.09548833797003 19.68503937007874 0 38.02857583815229 -10.18972618513864 0 38.0285758381523 10.18972618513861 0 39.37007874015748 0 0 -27.83884965301368 27.83884965301369 39.37007874015748 -19.68503937007873 34.09548833797003 0 -27.83884965301368 27.83884965301369 0 -19.68503937007873 34.09548833797003 39.37007874015748 -10.18972618513861 38.0285758381523 0 -10.18972618513861 38.0285758381523 39.37007874015748 2.410722045565656e-015 39.37007874015748 0 2.410722045565656e-015 39.37007874015748 39.37007874015748 10.18972618513862 38.02857583815229 0 10.18972618513862 38.02857583815229 39.37007874015748 19.68503937007874 34.09548833797003 0 19.68503937007874 34.09548833797003 39.37007874015748 27.83884965301369 27.83884965301368 0 27.83884965301369 27.83884965301368 39.37007874015748 34.09548833797003 19.68503937007874 39.37007874015748 34.09548833797003 19.68503937007874 0 38.0285758381523 10.18972618513861 39.37007874015748 38.0285758381523 10.18972618513861 0 39.37007874015748 0 39.37007874015748 39.37007874015748 0 0 38.02857583815229 -10.18972618513864 39.37007874015748 38.02857583815229 -10.18972618513864 0 34.09548833797002 -19.68503937007876 39.37007874015748 34.09548833797002 -19.68503937007876 0 27.83884965301368 -27.83884965301369 39.37007874015748 27.83884965301368 -27.83884965301369 0 19.68503937007872 -34.09548833797004 0 19.68503937007872 -34.09548833797004 39.37007874015748 10.1897261851386 -38.0285758381523 0 10.1897261851386 -38.0285758381523 39.37007874015748 -7.232166136696968e-015 -39.37007874015748 0 -7.232166136696968e-015 -39.37007874015748 39.37007874015748 -10.18972618513864 -38.02857583815229 0 -10.18972618513864 -38.02857583815229 39.37007874015748 -19.68503937007876 -34.09548833797002 0 -19.68503937007876 -34.09548833797002 39.37007874015748 -27.8388496530137 -27.83884965301367 0 -27.8388496530137 -27.83884965301367 39.37007874015748 -34.09548833797003 -19.68503937007873 39.37007874015748 -34.09548833797003 -19.68503937007873 0 -38.0285758381523 -10.1897261851386 39.37007874015748 -38.0285758381523 -10.1897261851386 0 -39.37007874015748 4.821444091131312e-015 39.37007874015748 -39.37007874015748 4.821444091131312e-015 0 -38.02857583815229 10.18972618513862 39.37007874015748 -38.02857583815229 10.18972618513862 0 -34.09548833797002 19.68503937007876 39.37007874015748 -34.09548833797002 19.68503937007876 0 -38.0285758381523 -10.1897261851386 39.37007874015748 -38.02857583815229 10.18972618513862 39.37007874015748 -39.37007874015748 4.821444091131312e-015 39.37007874015748 -34.09548833797003 -19.68503937007873 39.37007874015748 -34.09548833797002 19.68503937007876 39.37007874015748 -27.8388496530137 -27.83884965301367 39.37007874015748 -27.83884965301368 27.83884965301369 39.37007874015748 -19.68503937007876 -34.09548833797002 39.37007874015748 -19.68503937007873 34.09548833797003 39.37007874015748 -10.18972618513864 -38.02857583815229 39.37007874015748 -10.18972618513861 38.0285758381523 39.37007874015748 -7.232166136696968e-015 -39.37007874015748 39.37007874015748 2.410722045565656e-015 39.37007874015748 39.37007874015748 10.1897261851386 -38.0285758381523 39.37007874015748 10.18972618513862 38.02857583815229 39.37007874015748 19.68503937007872 -34.09548833797004 39.37007874015748 19.68503937007874 34.09548833797003 39.37007874015748 27.83884965301368 -27.83884965301369 39.37007874015748 27.83884965301369 27.83884965301368 39.37007874015748 34.09548833797002 -19.68503937007876 39.37007874015748 34.09548833797003 19.68503937007874 39.37007874015748 38.02857583815229 -10.18972618513864 39.37007874015748 38.0285758381523 10.18972618513861 39.37007874015748 39.37007874015748 0 39.37007874015748</float_array>
                        <technique_common>
                            <accessor count="96" source="#ID8" stride="3">
                                <param name="X" type="float" />
                                <param name="Y" type="float" />
                                <param name="Z" type="float" />
                            </accessor>
                        </technique_common>
                    </source>
                    <source id="ID6">
                        <float_array id="ID9" count="288">0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 -0.7071067811865475 0.7071067811865476 0 -0.4999999999999999 0.8660254037844387 0 -0.7071067811865475 0.7071067811865476 0 -0.4999999999999999 0.8660254037844387 0 -0.2588190451025206 0.9659258262890684 0 -0.2588190451025206 0.9659258262890684 0 2.673332968694072e-016 1 0 2.673332968694072e-016 1 0 0.2588190451025209 0.9659258262890682 0 0.2588190451025209 0.9659258262890682 0 0.5 0.8660254037844386 0 0.5 0.8660254037844386 0 0.7071067811865475 0.7071067811865476 0 0.7071067811865475 0.7071067811865476 0 0.8660254037844387 0.5 0 0.8660254037844387 0.5 0 0.9659258262890684 0.2588190451025206 0 0.9659258262890684 0.2588190451025206 0 1 -4.901110442605798e-016 0 1 -4.901110442605798e-016 0 0.9659258262890682 -0.2588190451025212 0 0.9659258262890682 -0.2588190451025212 0 0.8660254037844384 -0.5000000000000004 0 0.8660254037844384 -0.5000000000000004 0 0.7071067811865471 -0.707106781186548 0 0.7071067811865471 -0.707106781186548 0 0.4999999999999995 -0.8660254037844389 0 0.4999999999999995 -0.8660254037844389 0 0.2588190451025204 -0.9659258262890684 0 0.2588190451025204 -0.9659258262890684 0 -4.72288824469286e-016 -1 0 -4.72288824469286e-016 -1 0 -0.2588190451025212 -0.9659258262890682 0 -0.2588190451025212 -0.9659258262890682 0 -0.5000000000000004 -0.8660254037844384 0 -0.5000000000000004 -0.8660254037844384 0 -0.7071067811865479 -0.7071067811865471 0 -0.7071067811865479 -0.7071067811865471 0 -0.8660254037844388 -0.4999999999999998 0 -0.8660254037844388 -0.4999999999999998 0 -0.9659258262890684 -0.2588190451025205 0 -0.9659258262890684 -0.2588190451025205 0 -1 2.316888572868195e-016 0 -1 2.316888572868195e-016 0 -0.9659258262890682 0.258819045102521 0 -0.9659258262890682 0.258819045102521 0 -0.8660254037844386 0.5000000000000001 0 -0.8660254037844386 0.5000000000000001 0 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1 -0 -0 1</float_array>
                        <technique_common>
                            <accessor count="96" source="#ID9" stride="3">
                                <param name="X" type="float" />
                                <param name="Y" type="float" />
                                <param name="Z" type="float" />
                            </accessor>
                        </technique_common>
                    </source>
                    <vertices id="ID7">
                        <input semantic="POSITION" source="#ID5" />
                        <input semantic="NORMAL" source="#ID6" />
                    </vertices>
                    <triangles count="92" material="Material2">
                        <input offset="0" semantic="VERTEX" source="#ID7" />
                        <p>0 1 2 1 0 3 3 0 4 3 4 5 5 4 6 5 6 7 7 6 8 7 8 9 9 8 10 9 10 11 11 10 12 11 12 13 13 12 14 13 14 15 15 14 16 15 16 17 17 16 18 17 18 19 19 18 20 19 20 21 21 20 22 21 22 23 24 25 26 25 24 27 27 28 25 28 27 29 29 30 28 30 29 31 31 32 30 32 31 33 33 34 32 34 33 35 35 36 34 36 35 37 36 38 39 38 36 37 39 40 41 40 39 38 41 42 43 42 41 40 43 44 45 44 43 42 45 46 47 46 45 44 47 48 49 48 47 46 48 50 49 50 48 51 51 52 50 52 51 53 53 54 52 54 53 55 55 56 54 56 55 57 57 58 56 58 57 59 59 60 58 60 59 61 62 60 61 60 62 63 64 63 62 63 64 65 66 65 64 65 66 67 68 67 66 67 68 69 70 69 68 69 70 71 24 71 70 71 24 26 72 73 74 73 72 75 73 75 76 76 75 77 76 77 78 78 77 79 78 79 80 80 79 81 80 81 82 82 81 83 82 83 84 84 83 85 84 85 86 86 85 87 86 87 88 88 87 89 88 89 90 90 89 91 90 91 92 92 91 93 92 93 94 94 93 95</p>
                    </triangles>
                </mesh>
            </geometry>
        </library_geometries>
        <library_materials>
            <material id="ID3" name="Color_A01_">
                <instance_effect url="#ID4" />
            </material>
        </library_materials>
        <library_effects>
            <effect id="ID4">
                <profile_COMMON>
                    <technique sid="COMMON">
                        <lambert>
                            <diffuse>
                                <color>1 0 0 1</color>
                            </diffuse>
                        </lambert>
                    </technique>
                </profile_COMMON>
            </effect>
        </library_effects>
        <scene>
            <instance_visual_scene url="#ID1" />
        </scene>
    </COLLADA>][1]