How to use the pykml.factory.KML_ElementMaker.Point 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 bonzanini / Book-SocialMediaMiningPython / Chap09 / micro_geo2kml.py View on Github external
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 / data_conversion / example_csv_to_kml.py View on Github external
url="http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt"
fileobject = urllib2.urlopen(url)
for row in csv.DictReader(fileobject):
    timestamp = datetime.strptime(row["Datetime"], "%A, %B %d, %Y %H:%M:%S %Z")
    pm = KML.Placemark(
        KML.name("Magnitude={0}".format(row['Magnitude'])),
        KML.TimeStamp(
            KML.when(timestamp.strftime('%Y-%m-%dT%H:%M:%SZ')),
        ),
        KML.styleUrl(
            "#earthquake-style-{thresh}".format(
                thresh=int(float(row['Magnitude']))
            )
        ),
        makeExtendedDataElements(row),
        KML.Point(
            KML.coordinates("{0},{1}".format(row["Lon"],row["Lat"]))
        )
    )
    doc.Folder.append(pm)

# check if the schema is valid
from pykml.parser import Schema
schema_gx = Schema("kml22gx.xsd")
schema_gx.assertValid(doc)

print etree.tostring(doc, pretty_print=True)
github arthur-e / unmixing / unmixing / lsma.py View on Github external
if data_dict is None:
            data_dict = {
                'wavelength': range(1, len(coords) + 1),
                'wavelength units': 'MNF Component',
                'z plot titles': ['', '']
            }

        ico = 'http://maps.google.com/mapfiles/kml/paddle/%i.png'
        pmarks = []
        for i, pair in enumerate(coords):
            pmarks.append(KML.Placemark(
                KML.Style(
                    KML.IconStyle(
                        KML.Icon(KML.href(ico % (i + 1))))),
                KML.name(data_dict['wavelength units'] + ' %d' % (i + 1)),
                KML.Point(KML.coordinates('%f,%f' % pair))))

        doc = KML.kml(KML.Folder(*pmarks))
        with open(path, 'wb') as source:
            source.write(etree.tostring(doc, pretty_print=True))
github pykml / pykml / src / examples / KmlReference / animatedupdate_example.py View on Github external
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),
            KML.altitude(9700),
            KML.heading(-6.333),
            KML.tilt(33.5),
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')
    )
  )
  poly = zone.Polygon

  d = float(zone_radius) / float(earth_radius)
github PIC-IRIS / PH5 / ph5 / clients / ph5toexml.py View on Github external
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)
                        has_data = True
                    network_folder.append(folder)
                doc.append(network_folder)

            if has_data:
                if outfile and hasattr(outfile, 'write'):
                    target = outfile
                elif outfile:
                    target = open(outfile, 'w')
                else:
github clawpack / visclaw / src / python / visclaw / plotpages.py View on Github external
snippet = "t1 = %g, t2 = %g\n" % (t1,t2) + \
                      "x1 = %g, y1 = %g\n" % (x1,y1)
            snippet_str = "<b>%s</b>]]&gt;" % snippet

            # ExtendedData is used in BalloonStyle.text() fields.
            placemark = KML.Placemark(
                KML.name("%s %d" % (plotfigure.kml_gauge_name,gaugeno)),
                KML.Snippet(snippet_str),
                KML.styleUrl(chr(35) + "gauge_style"),
                KML.ExtendedData(
                    KML.Data(KML.value(figname),name="pngfile"),
                    KML.Data(KML.value("%g" % t1),name="t1"),
                    KML.Data(KML.value("%g" % t2),name="t2"),
                    KML.Data(KML.value("%g" % x1),name="x1"),
                    KML.Data(KML.value("%g" % y1),name="y1")),
                KML.Point(
                    KML.coordinates(coords)))

            doc_gauges.Document.append(placemark)

        kml_file = open(gauge_kml_file,'wt')
        kml_file.write('\n')

        kml_text = etree.tostring(etree.ElementTree(doc_gauges),
                                  pretty_print=True).decode()
        kml_text = kml_text.replace('&gt;','&gt;')   # Needed for CDATA blocks
        kml_text = kml_text.replace('&lt;','&lt;')

        kml_file.write(kml_text)
        kml_file.close()

    # -------------- add gauge image and KML files -----------------
github pykml / pykml / src / pykml / util.py View on Github external
if row.has_key(description_field):
            pm.append(
                KML.description(clean_xml_string(row[description_field]))
            )
        else:
            desc = '
github PIC-IRIS / PH5 / webservices / ph5toexml.py View on Github external
)
                            ),
                                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