How to use the pykml.factory.KML_ElementMaker.Placemark 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 pykml / pykml / src / examples / Tours / circle_around_landmarks.py View on Github external
targetId=feature['name'].replace(' ','_')
              )
            )
          )
        )
    )
    
    tour_doc.Document[gxns+"Tour"].Playlist.append(GX.Wait(GX.duration(2.0)))
    
    tour_doc.Document[gxns+"Tour"].Playlist.append(
        GX.AnimatedUpdate(
          GX.duration(2.0),
          KML.Update(
            KML.targetHref(),
            KML.Change(
              KML.Placemark(
                GX.balloonVisibility(0),
                targetId=feature['name'].replace(' ','_')
              )
            )
          )
        )
    )
    # fly to a space viewpoint
    tour_doc.Document[gxns+"Tour"].Playlist.append(
      GX.FlyTo(
        GX.duration(5),
        GX.flyToMode("bounce"),
        KML.LookAt(
          KML.longitude(feature['lon']),
          KML.latitude(feature['lat']),
          KML.altitude(0),
github bonzanini / Book-SocialMediaMiningPython / Chap09 / micro_geo2kml.py View on Github external
except (IndexError, KeyError):
            pass
    return coords


if __name__ == '__main__':
    parser = get_parser()
    args = parser.parse_args()

    doc = mf2py.parse(url=args.url)
    coords = get_geo(doc)
    folder = KML.Folder()
    for item in coords[:args.n]:
        lat, lon = item['geo'].split('; ')
        place_coords = ','.join([lon, lat])
        place = KML.Placemark(
            KML.name(item['name']),
            KML.Point(KML.coordinates(place_coords))
        )
        folder.append(place)

    with open(args.output, 'w') as fout:
        xml = etree.tostring(folder, pretty_print=True).decode('utf8')
        fout.write(xml)
github pykml / pykml / src / examples / Tours / example_spline_camera.py View on Github external
def create_camera_model_placemark(location):
    
    pm = KML.Placemark(
        KML.description(
            ''
            ''
            ''
            ''
            ''
            ''
            ''
            '<table border="1"><tbody><tr><th>latitude</th><td>{lat}</td></tr><tr><th>longitude</th><td>{lon}</td></tr><tr><th>altitude</th><td>{alt}</td></tr><tr><th>heading</th><td>{head}</td></tr><tr><th>tilt</th><td>{tilt}</td></tr><tr><th>roll</th><td>{roll}</td></tr></tbody></table>'.format(
                lat=location['loc'].latitude,
                lon=location['loc'].longitude,
                alt=location['loc'].altitude,
                head=location['loc'].heading,
                tilt=location['loc'].tilt,
                roll=location['loc'].roll,
            )
github PIC-IRIS / PH5 / webservices / ph5toexml.py View on Github external
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:
                    folder = KML.Folder(KML.name("ShotLine "+str(shot_line.name[-3:])))
                    for shot in shot_line.shots:
                        place_marker=(KML.Placemark(
                            KML.styleUrl("#star"),
                            KML.name(network.code+'.'+str(shot.shot_id)),
                            KML.description('Shot size: '+str(shot.mag)+' '+shot.mag_units+'\n Shot Time: '+shot.start_time+'\n\n'+shot.description),
                            KML.Point(
                                KML.coordinates(str(shot.lon)+','+str(shot.lat)+','+str(shot.elev))
                                )
                        ))
                        folder.append(place_marker)
                    network_folder.append(folder)
                doc.append(network_folder)
            
            target = open(outfile, 'w')    
            target.write(etree.tostring(etree.ElementTree(doc),pretty_print=True))
            return
github pykml / pykml / src / examples / KmlReference / animatedupdate_example.py View on Github external
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)
      ),
      id="mountainpin1"
    ),
    GX.Tour(
      KML.name("Play me!"),
      GX.Playlist(
        GX.FlyTo(
          GX.duration(3),
          GX.flyToMode("bounce"),
          KML.Camera(
            KML.longitude(170.157),
            KML.latitude(-43.671),
github NCPP / ocgis / ocgis_merge / src / openclimategis / util / ncconv / experimental / ocg_converter / kml.py View on Github external
coord_list = geom.as_kml_coords()
                multigeom_args = [
                    KML.Polygon(
                      KML.tessellate('1'),
                      KML.outerBoundaryIs(
                        KML.LinearRing(
                          KML.coordinates(coords.text),
                        ),
                      ),
                    ) for coords in coord_list
                ]
                
                # TODO: sort values by time to speed loading
                values = ['{0},{1}'.format(datetime.strftime(val.time, "%Y-%m-%d %H:%M:%S"),val.value) for val in geom.values]
                pm = KML.Placemark(
                    KML.name('Geometry'),
                    
                    KML.ExtendedData(
                        KML.Data(
                            KML.value('"Date,{param}\\n{data}"'.format(
                                    param=meta.variable.name,
                                    data='\\n'.join(values))
                            ),
                            name="csv_data",
                        ),
                    ),
                    KML.description(''),
                    KML.styleUrl('#smap'),
                    KML.MultiGeometry(*multigeom_args),
                )
                geom_fld.append(pm)
github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / legacy / 3650_3700_radar_sites.py View on Github external
def AddPlacemarkAndZone(doc, site):
  name = site[0]
  lat = float(site[1]) + float(site[2])/60.0 + float(site[3])/3600.0;
  if site[4] == 'S':
    lat = -lat
  lng = float(site[5]) + float(site[6])/60.0 + float(site[7])/3600.0;
  if site[8] == 'W':
    lng = -lng
  print 'Adding placemark for %s at (%f, %f)' % (name, lat, lng)

  pm = KML.Placemark(
    KML.name(name),
    KML.styleUrl('#pm'),
    KML.Point(
      KML.coordinates('%f,%f,0' % (lng, lat))
    )
  )
  doc.append(pm)

  zone = KML.Placemark(
    KML.name('%s zone' % name),
    KML.styleUrl('#ts'),
    KML.Polygon(
      KML.extrude(0),
      KML.altitudeMode('clampToGround')
    )
  )
github PIC-IRIS / PH5 / ph5 / clients / ph5toexml.py View on Github external
'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:
                    folder = KML.Folder(
                        KML.name("ShotLine " + str(shot_line.name[-3:])))
                    for shot in shot_line.shots:
                        place_marker = (KML.Placemark(
                            KML.styleUrl("#star"),
                            KML.name(network.code + '.' + str(shot.shot_id)),
                            KML.description('Shot size: ' +
                                            str(shot.mag) +
                                            ' ' +
                                            shot.mag_units +
                                            '\n Shot Time: ' +
                                            shot.start_time +
                                            '\n\n' +
                                            shot.description),
                            KML.Point(
                                KML.coordinates(
                                    str(shot.lon) + ',' + str(shot.lat) + ',' +
                                    str(shot.elev))
                            )
                        ))
github NCPP / ocgis / src / openclimategis / util / ncconv / experimental / ocg_converter.py View on Github external
'Variable{variable}'
                            'Date/Time (UTC){time}'
                            'Value{value:.{digits}f} {units}'
                          ''
                        ''
                    ).format(
                        variable=meta.variable.name,
                        time=val.time_ref.as_xml_date(),
                        value=val.value,
                        digits=3,
                        units=meta.variable.units,
                    )
                    
                    coords = val.geometry.as_kml_coords()
                    timefld.append(
                      KML.Placemark(
                        KML.name('Geometry'),
                        KML.description(poly_desc),
                        KML.styleUrl('#smap'),
                        KML.Polygon(
                          KML.tessellate('1'),
                          KML.outerBoundaryIs(
                            KML.LinearRing(
                              KML.coordinates(coords),
                            ),
                          ),
                        ),
                      )
                    )
                doc.Document.append(timefld)
            pass
        finally: