How to use the pykml.factory.KML_ElementMaker.coordinates 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 / uscabdry.py View on Github external
)

for ls in lineStrings:
  print 'coordinates=[%s ... %s] (%d)' % (ls[0], ls[len(ls)-1], len(ls))
  print 'Have latitude %s' % ls[0].split(',')[1]
  if float(ls[0].split(',')[1]) > 50:
    geo_name = 'AK-CA Boundary'
  else:
    geo_name = 'CONUS-CA Boundary'
  pm = KML.Placemark(
    KML.name('%s' % geo_name),
    KML.styleUrl('#stl'),
    KML.LineString(
      KML.extrude(1),
      KML.altitudeMode('clampToGround'),
      KML.coordinates(' '.join(ls))
    )
  )
  doc.Document.append(pm)

# For debugging: optionally include the paths of the original source data.
#ns = 100
#for ls in coordx:
#  print 'x coordinates=[%s ... %s] (%d)' % (ls[0], ls[len(ls)-1], len(ls))
#  pm = KML.Placemark(
#    KML.name('%d' % ns),
#    KML.styleUrl('#stlx'),
#    KML.LineString(
#      KML.extrude(1),
#      KML.altitudeMode('clampToGround'),
#      KML.coordinates(' '.join(ls))
#    )
github PIC-IRIS / PH5 / ph5 / clients / ph5toexml.py View on Github external
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:
                    target = sys.stdout
github PX4 / Firmware / Tools / sdlog2 / geo_tag_images.py View on Github external
KML.altitudeMode('absolute'),
                            KML.coordinates(
                                "{},{},{}".format(gps.lon, gps.lat, gps.alt))
                        ),
                        KML.name(
                            str(ii)) if ii % 5 == 0 or ii == 1 else KML.name()
                    )
                )

        # create the path
        doc.Document.append(
            KML.Placemark(
                KML.styleUrl('#{0}'.format(style_path)),
                KML.LineString(
                    KML.altitudeMode('absolute'),
                    KML.coordinates(
                        ' '.join(["{},{},{}".format(gps.lon, gps.lat, gps.alt)
                                 for gps in self.tagged_gps])
                    )
                )
            )
        )

        s = etree.tostring(doc)

        file_path = self.output + 'GoogleEarth_points.kml'
        f = open(file_path, 'w')
        f.write(s)
        f.close()

        print '[INFO] KML file generated on:', file_path
github insarlab / MintPy / mintpy / save_kmz_timeseries.py View on Github external
ref_point = KML.Placemark(
        KML.Style(
            KML.IconStyle(
                KML.color(get_hex_color(0.0, colormap, norm)),
                KML.scale(1.),
                KML.Icon(
                    KML.href("{}".format(os.path.basename(inps.star_file)))
                )
            )
        ),
        KML.description("Reference point <br> \n <br> \n" +
                        get_description_string(ref_lalo, ref_yx, 0.00, 0.00, 0.00, 1.00)
                        ),
        KML.Point(
            KML.coordinates("{}, {}".format(ref_lalo[1], ref_lalo[0]))
        )
    )

    return ref_point
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)
  coords = []
github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / resample_uscabdry.py View on Github external
return '%s,%s,0' % (('%.14f' % lon).rstrip('0').rstrip('.'),
                        ('%.14f' % lat).rstrip('0').rstrip('.'))


for name, ls in uscabdry_fine.items():
  lons, lats = ls.xy
  print '%s: coordinates=[(%.5f,%.5f) ... (%.5f,%.5f)] (num=%d)' % (
      name, lons[0], lats[0], lons[-1], lats[-1], len(lons))

  pm = KML.Placemark(
    KML.name('%s' % name),
    KML.styleUrl('#stl'),
    KML.LineString(
      KML.extrude(1),
      KML.altitudeMode('clampToGround'),
      KML.coordinates(' '.join(['%s' % FormatLonLat(lon, lat)
                                for lon, lat in zip(lons, lats)]))
    )
  )
  doc.Document.append(pm)

# Save the output KML and KMZ
kml_str = etree.tostring(doc, pretty_print=True)
with open(os.path.join(data_dir, output_kml), 'w') as output_file:
  output_file.write(kml_str)

with zipfile.ZipFile(os.path.join(data_dir, output_kml), 'w') as output_file:
  output_file.writestr(output_kml, kml_str)
github pykml / pykml / src / examples / misc / base_jump / virtual_base_jump.py View on Github external
tour_doc = kml.kml(
    kml.Folder(
        gx.Tour(
          kml.name("Play me!"),
          gx.Playlist(),
        )
    )
)

tstep = 0.1
for t in drange(0,15,tstep):
    pm = kml.Placemark(
        kml.name(str(t)),
        kml.Point(
            kml.altitudeMode("absolute"),
            kml.coordinates("{lon},{lat},{alt}".format(
                lon=loc0['longitude'] + vx*t,
                lat=loc0['latitude'] + vy*t,
                alt=loc0['altitude'] + vz*t + 0.5*g*t**2,
            )),
            
        )
    )
    tour_doc.Folder.append(pm)
    
    flyto = gx.FlyTo(
        gx.duration(tstep),
        gx.flyToMode("smooth"),
        kml.Camera(
          kml.longitude(loc0['longitude'] + vx*t),
          kml.latitude(loc0['latitude'] + vy*t),
          kml.altitude(loc0['altitude'] + vz*t + 0.5*g*t**2),
github pykml / pykml / src / pykml / util.py View on Github external
pm.append(
                KML.description(clean_xml_string(row[description_field]))
            )
        else:
            desc = '
github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / protection_zones.py View on Github external
KML.styleUrl('#stl'),
      KML.MultiGeometry(
      )
    )

    for zone in zones[name]:
      coords = zone.exterior.coords
      exteriorCoords = []
      for c in coords:
        exteriorCoords.append('%s,%s,0' % (c[0], c[1]))
      p = KML.Polygon(
        KML.extrude(1),
        KML.altitudeMode('clampToGround'),
        KML.outerBoundaryIs(
          KML.LinearRing(
            KML.coordinates(' '.join(exteriorCoords))
          )
        )
      )
      pm.MultiGeometry.append(p)
      # TODO: make a better shapely->KML transformer and
      # call that. Support interiors. For now, this case
      # doesn't use them so skip it.

  doc.Document.append(pm)


outputFile = open(os.path.join(ntiaDir, 'protection_zones.kml'), 'w+')
outputFile.write(etree.tostring(doc, pretty_print=True))
outputFile.close()