How to use the pykml.factory.KML_ElementMaker.Document function in pykml

To help you get started, we’ve selected a few pykml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / usborder.py View on Github external
print 'Reversing non-CCW ring'
    r = list(reversed(ls))
    lineStrings[k] = r

# Cleanup the coordinates to be rounded correctly with 9 precision numbers
# (ie about 0.1mm)
for k, ls in enumerate(lineStrings):
  new_ls = []
  for c in ls:
    xy = c.split(',')
    new_ls.append('%.9f,%.9f,0' % (float(xy[0]), float(xy[1])))
  lineStrings[k] = new_ls

# Create output KML  
doc = KML.kml(
  KML.Document(
    KML.name('US Area'),
    KML.Style(
      KML.LineStyle(
        KML.color('ff0000ff'),
        KML.width(2)
      ),
      KML.PolyStyle(
        KML.color('66000066')
      ),
      id="stl"
    ),
    KML.Style(
      KML.LineStyle(
        KML.color('ff00ffff'),
        KML.width(4)
      ),
github PIC-IRIS / PH5 / webservices / ph5toexml.py View on Github external
def write_kml(list_of_networks):
            
            doc=KML.Document(
                KML.name("PH5 Events"),
                KML.Style(
                    KML.IconStyle(
                        KML.color('FF1400FF'),
                        KML.scale('1.25'),
                        KML.Icon(
                                KML.href('http://maps.google.com/mapfiles/kml/shapes/open-diamond.png')
                                )
                            ),
                                id = 'star'
                        ),                
                )
            
            for network in list_of_networks:
                network_folder=KML.Folder(KML.name("Network Code: "+str(network.code)+" reportnum: "+network.reportnum))
                for shot_line in network.shot_lines:
github clawpack / visclaw / src / python / visclaw / sample.py View on Github external
from lxml import etree
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import ATOM_ElementMaker as ATOM
from pykml.factory import GX_ElementMaker as GX

fileout = open('googleearth.kml','w')
fileout.write('\n')
framenos = 10

midnight = datetime.datetime.combine( datetime.date.today(), datetime.time() )
seconds = datetime.timedelta( seconds=234 )
time = midnight + seconds
time.strftime( '%H:%M:%S' )

doc = KML.kml(
KML.Document(
KML.Folder()))

for i in range(1,framenos+1):
    doc.Document.Folder.append(
        KML.GroundOverlay(
            KML.TimeSpan(
                KML.begin('2013-10-02T00:00:00Z', time),
                KML.end('2013-10-02T00:01:00Z', time),
            ),
            KML.drawOrder(i)
        )
    )

fileout.write(etree.tostring(etree.ElementTree(doc),pretty_print=True))
#print etree.tostring(etree.ElementTree(doc),pretty_print=True)
fileout.close()
github PX4 / Firmware / Tools / sdlog2 / geo_tag_images.py View on Github external
def gen_kml(self):
        """
        Generate a KML file with keypoints on the locations of the pictures, including height
        :return:
        """
        style_dot = "sn_shaded_dot"
        style_path = "red_path"

        doc = KML.kml(
            KML.Document(
                KML.Name("GPS of the images"),
                KML.Style(
                    KML.IconStyle(
                        KML.scale(0.4),
                        KML.Icon(
                            KML.href(
                                "http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
                        ),
                    ),
                    id=style_dot,
                ),
                KML.Style(
                    KML.LineStyle(
                        KML.color('7f0000ff'),
                        KML.width(6),
                        GX.labelVisibility('1'),
github pykml / pykml / src / examples / KmlReference / animatedupdate_example.py View on Github external
http://code.google.com/apis/kml/documentation/kmlreference.html#gxanimatedupdate
http://code.google.com/apis/kml/documentation/kmlfiles/animatedupdate_example.kml

Note that as of 12/1/2010, the KML code displayed beneath the animatedupdate_example.kml link
is not valid.
* The  element should not be a subelement of .
* The  element should be the first subelement of 
'''

from lxml import etree
from pykml.parser import Schema
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX

doc = KML.kml(
  KML.Document(
    KML.name("gx:AnimatedUpdate example"),
    KML.Style(
      KML.IconStyle(
        KML.scale(1.0),
        KML.Icon(
          KML.href("http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png"),
        ),
        id="mystyle"
      ),
      id="pushpin"
    ),
    KML.Placemark(
      KML.name("Pin on a mountaintop"),
      KML.styleUrl("#pushpin"),
      KML.Point(
        KML.coordinates(170.1435558771009,-43.60505741890396,0)
github PIC-IRIS / PH5 / ph5 / clients / ph5toexml.py View on Github external
def write_kml(list_of_networks):
            has_data = False

            doc = KML.Document(
                KML.name("PH5 Events"),
                KML.Style(
                    KML.IconStyle(
                        KML.color('FF1400FF'),
                        KML.scale('1.25'),
                        KML.Icon(
                            KML.href(
                                'http://maps.google.com/mapfiles/' +
                                'kml/shapes/open-diamond.png')
                        )
                    ),
                    id='star'
                ),
            )

            for network in list_of_networks:
github clawpack / visclaw / src / python / visclaw / plotpages.py View on Github external
# effect is desired. In any case, the time span can't be empty or the
                # last figure won't show up.
                dt = (frametimes[framenos[numframes-1]] - frametimes[framenos[0]])/numframes
                t2 = t1 + dt   # Add enough time for looping through animations
                print("Final time in Google Earth slider set to {:6.2f}".format(t2))

            sbegin, send = kmltools.kml_timespan(t1,t2,event_time,tz,tscale=tscale)

            TS.append(KML.TimeSpan(
                KML.begin(sbegin),
                KML.end(send)))


    # Top level doc.kml file
    doc = KML.kml(
        KML.Document(
            KML.name(plotdata.kml_name),
            KML.open(1)))

    # Open main zip file
    zip = zipfile.ZipFile(plotdata.kml_index_fname + ".kmz",'w',allowZip64=True)

    # --------------------- Set initial view --------------------------
    first_found = False
    for i,figname in enumerate(plotdata._fignames):
        plotfigure = plotdata.plotfigure_dict[figname]
        figno = plotfigure.figno

        if not figno in fignos:
            continue

        if not plotfigure.use_for_kml:
github pykml / pykml / src / pykml / util.py View on Github external
fileObj,
        latitude_field='latitude',
        longitude_field='longitude',
        altitude_field='altitude',
        name_field='name',
        description_field='description',
        snippet_field='snippet',
    ):
    '''Reads a CSV document from a file-like object and converts it to KML'''
    
    import csv
    #import urllib2
    from pykml.factory import KML_ElementMaker as KML
    
    # create a basic KML document
    kmldoc = KML.kml(KML.Document(
        KML.Folder(
            KML.name("KmlFile"))
        )
    )
    
    csvdoc = csv.DictReader(fileObj)
    
    # if field is not found, check for other common field names
    if latitude_field not in csvdoc.fieldnames:
        match_field = None
        for name in ['latitude','lat']:
            try:
                match_field = csvdoc.fieldnames[[s.lower() for s in csvdoc.fieldnames].index(name)]
                break
            except:
                pass
github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / resample_uscabdry.py View on Github external
# Read input KML as dict of LineString
input_file = os.path.join(data_dir, input_kml)
uscabdry = zones._ReadKmlBorder(input_file)

# Resample the LineStrings
uscabdry_fine = {}
for name, ls in uscabdry.items():
  uscabdry_fine[name] = ResampleUsCanadaBorderLineString(ls, step_meters)
  print '  segment %s: Before %d After %d' % (
      name, len(ls.xy[0]), len(uscabdry_fine[name].xy[0]))


# Build the output KML
doc = KML.kml(
  KML.Document(
    KML.name('US-Canada Border'),
    KML.Style(
      KML.LineStyle(
        KML.color('ffff00ff'),
        KML.width(3)
      ),
      id="stl"
    ),
    KML.Style(
      KML.LineStyle(
        KML.color('00ffff00'),
        KML.width(15)
      ),
      id="stlx"
    ),
  )