Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

It loads as an absolute everytime so terrain must be turned off to see the lines. Any idea how to get it so they default to clamped to ground? Using newest version of GE.

share|improve this question

1 Answer 1

The Google Earth help discusses the different options for toggling this setting within Google Earth, however none have the permanence that you need.

If you just have a small number of KML files to alter you could simply edit them in a text editor using search and replace to replace the line <altitudeMode>absolute</altitudeMode> with <altitudeMode>clampToGround</altitudeMode> for each geometry. This will permanently alter the files so they always load with the desired altitude settings. Full details on this tag are listed in the KML reference.

If you have many files to do, or will perform the operation many times you may find it better to modify your KML files using python to perform the find and replace across may files automatically. I recently wrote a simple regular expression to perform a similar task which I have modified for this problem:

import re

#load file into memory
with open('input_file.kml','r') as kml:
    lines = kml.readlines()

#search and replace throughout the file in memory
for i,line in enumerate(lines):
    if re.search(r'<altitudeMode>.*?</altitudeMode>',line):
        lines[i] = '<altitudeMode>absolute</altitudeMode>\n'

#write file from memory
with open('input_file.kml','w') as kml:
    for line in lines:
        kml.write(line)

This will replace any altitude settings with your desired settings, and could be nested within a loop to iterate though a folder full of KML files, if needed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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