1

If you only have a height above ground level for the starting point of a polygon: Is there a way to create the polygon so that all the following points have the same height relative to sea level? i.e. the polygon will be flat on the horizontal plain regardless of the terrain.

Does anyone have a method of doing this without knowing/obtaining the height above sea level before generating the kml?

Any help would be greatly appreciated.

Kelvin_SA
  • 11
  • 2

2 Answers2

1

Create a polygon using relativeToGround altitudeMode, which interprets the altitude as a value in meters above the ground.

Note: you'll need to specify the altitude value for each point. Can't just specify altitude for one and have others use same altitude. If you omit altitude it defaults to "0".

Here's polygon with each point set at 10 meters above ground.

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
      <Placemark>
      <name>tennis-poly</name>
      <Polygon>
        <altitudeMode>relativeToGround</altitudeMode>
        <outerBoundaryIs>
          <LinearRing>
            <coordinates>
              -122.43193945401,37.801983684521,10
              -122.431564131101,37.8020327731402,10
              -122.431499536494,37.801715236748,10
              -122.43187136387,37.8016634915437,10
              -122.43193945401,37.801983684521,10
            </coordinates>
          </LinearRing>
        </outerBoundaryIs>        
      </Polygon>
    </Placemark>     
</kml>

If want the polygon to be flat on the horizontal plain regardless of the terrain then the altitudeMode must be absolute which is respect to mean sea level. You could skip defining the altitude in the coordinates and specify a single height using a <gx:altitudeOffset>.

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
      <Placemark>
      <name>tennis-poly</name>
      <Polygon>
        <altitudeMode>absolute</altitudeMode>              
        <outerBoundaryIs>
          <LinearRing>
            <gx:altitudeOffset>50</gx:altitudeOffset>
            <coordinates>
              -122.43193945401,37.801983684521
              -122.431564131101,37.8020327731402
              -122.431499536494,37.801715236748
              -122.43187136387,37.8016634915437
              -122.43193945401,37.801983684521
            </coordinates>
          </LinearRing>
        </outerBoundaryIs>        
      </Polygon>
    </Placemark>     
</kml>
CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
0

Your only possible woraround of this would be to get the sea level height of the first point and use that height on the other points as well: Get altitude by longitude and latitude in Android

Community
  • 1
  • 1
Sam
  • 1