How to use the pykml.factory.KML_ElementMaker.name 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 NCPP / ocgis / ocgis_merge / src / openclimategis / util / ncconv / experimental / ocg_converter / kml.py View on Github external
end=meta.temporal[-1],
            operation=meta.operation,
            url=url,
            url_kmz=url.replace('.kml', '.kmz'),
            url_shz=url.replace('.kml', '.shz'),
            url_csv=url.replace('.kml', '.csv'),
            url_json=url.replace('.kml', '.geojson'),
        )
        ##### TODO: build linked urls on the fly
        #from piston.emitters import Emitter
        #Emitter.EMITTERS.keys()
        #['xml', 'sqlite', 'nc', 'shz', 'kml', 'kcsv', 'django', 'json', 'html', 'meta', 'lshz', 'csv', 'pickle', 'kmz']

        doc = KML.kml(
          KML.Document(
            KML.name('Climate Simulation Output'),
            KML.open(1),
            KML.description(description),
            KML.snippet(
                '<i>Click for metadata!</i>',
                maxLines="2",
            ),
            KML.StyleMap(
              KML.Pair(
                KML.key('normal'),
                KML.styleUrl('#style-normal'),
              ),
              KML.Pair(
                KML.key('highlight'),
                KML.styleUrl('#style-highlight'),
              ),
              id="smap",
github NCPP / ocgis / src / openclimategis / util / ncconv / experimental / ocg_converter.py View on Github external
),
        )
        
        try:
            s = db.Session()
            for time in s.query(db.Time).all():
                # create a folder for the time
                timefld = KML.Folder(
#                    KML.Style(
#                      KML.ListStyle(
#                        KML.listItemType('checkHideChildren'),
#                        KML.bgColor('00ffffff'),
#                        KML.maxSnippetLines('2'),
#                      ),
#                    ),
                    KML.name(time.as_xml_date()),
                    # placemarks will be appended here
                )
                for val in time.value:
                    poly_desc = (
                        ''
                          ''
                            ''
                            ''
                            ''
                          ''
                        '<table border="1"><tbody><tr><th>Variable</th><td>{variable}</td></tr><tr><th>Date/Time (UTC)</th><td>{time}</td></tr><tr><th>Value</th><td>{value:.{digits}f} {units}</td></tr></tbody></table>'
                    ).format(
                        variable=meta.variable.name,
                        time=val.time_ref.as_xml_date(),
                        value=val.value,
                        digits=3,
github clawpack / visclaw / src / python / visclaw / plotpages.py View on Github external
print("KML ===&gt; Building colorbar for figure %s" % plotfigure.name)
            cb_img = "images"
            cb_dir = os.path.join(fig_dir,cb_img)
            shutil.rmtree(cb_dir,True)
            os.mkdir(cb_dir)
            cb_filename = "colorbarfig%s.png" % figno
            try:
                plotfigure.kml_colorbar(cb_filename)
                shutil.move(cb_filename,cb_dir)
            except:
                print("KML ===&gt; Warning : Something went wrong when creating colorbar")

            # add link to KML file, even if colorbar didn't get created.
            cb_str = os.path.join(cb_img,cb_filename)
            colorbar = KML.ScreenOverlay(
                KML.name("Colorbar"),
                KML.Icon(KML.href(cb_str)),
                KML.overlayXY(x="0.025", y="0.05", xunits="fraction", yunits="fraction"),
                KML.screenXY(x="0.025", y="0.05",xunits="fraction", yunits="fraction"))

            doc_fig.Document.append(colorbar)
            # -----  Done with colorbar ------

        # ------------------ done with fig/doc.kml file ------------------
        fig_file = open(os.path.join(fig_dir,"doc.kml"),'wt')
        fig_file.write('\n')

        # In case we used CDATA in any snippets or descriptions.  For some reason
        #  get converted to &gt;tags&lt;, which balloons don't translate.
        kml_text = etree.tostring(etree.ElementTree(doc_fig),pretty_print=True).decode()
        kml_text = kml_text.replace('&gt;','&gt;')
        kml_text = kml_text.replace('&lt;','&lt;')
github insarlab / MintPy / mintpy / save_kmz_timeseries.py View on Github external
kml_root_doc.append(cbar_overlay)

    # 2 Generate the placemark for the Reference Pixel
    ref_point = create_reference_point_element(inps, lats, lons, ts_obj)
    print('add reference point.')
    ref_folder = KML.Folder(KML.name("ReferencePoint"))
    ref_folder.append(ref_point)
    kml_root_doc.append(ref_folder)

    # 3 Create data folder to contain actual data elements
    net_link1 = generate_network_link(inps, ts_obj, step=inps.steps[0], lod=(0, inps.lods[0]))
    net_link2 = generate_network_link(inps, ts_obj, step=inps.steps[1], lod=(inps.lods[0], inps.lods[1]))
    net_link3 = generate_network_link(inps, ts_obj, step=inps.steps[2], lod=(inps.lods[1], inps.lods[2]))

    # 3.3 Append network links to data folder
    data_folder = KML.Folder(KML.name("Data"))
    data_folder.append(net_link1)
    data_folder.append(net_link2)
    data_folder.append(net_link3)
    kml_root_doc.append(data_folder)


    ##---------------------------- Write root KML file ------------------------------##
    print('-'*30)
    print('writing ' + kml_root_file)
    kml_root = KML.kml()
    kml_root.append(kml_root_doc)
    with open(kml_root_file, 'w') as f:
        f.write(etree.tostring(kml_root, pretty_print=True).decode('utf-8'))

    ## Copy auxiliary files
    res_dir = os.path.join(os.path.dirname(__file__), "../docs/resources")
github PIC-IRIS / PH5 / ph5 / clients / 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)
                        has_data = True
github pykml / pykml / src / examples / data_conversion / example_csv_to_kml.py View on Github external
KML.hotSpot(x="0.5",y="0",xunits="fraction",yunits="fraction"),
            ),
            balloonstyle,
            id="earthquake-style-{threshold}".format(threshold=threshold),
        )
    )

doc.append(KML.Folder())

# read in a csv file, and create a placemark for each record
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
github pykml / pykml / src / examples / KmlReference / animatedupdate_example.py View on Github external
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),
          )
        ),
        GX.AnimatedUpdate(
          GX.duration(5),
          KML.Update(
            KML.targetHref(),
github pykml / pykml / src / examples / Tours / example_spline_camera.py View on Github external
known_positions,
        number_of_positions=100,
        #horizontal_interp_method='linear',
    )
    # create a folder of original placemarks
    fld1 = KML.Folder(KML.name('original'))
    for loc in known_positions:
        fld1.append(create_placemarks(loc))
    
    # create a folder of interpolated placemarks
    fld2 = KML.Folder(KML.name('interpolated'))
    for loc in interp_positions:
        fld2.append(create_placemarks(loc))
    
    # create a folder of models showing camera positions/orientations
    fld3 = KML.Folder(KML.name('cameras'))
    for loc in interp_positions:
        fld3.append(create_camera_model_placemark(loc))
    
    # create a tour of camera positions
    playlist = GX.Playlist()
    for loc in interp_positions:
        playlist.append(create_flyto_camera(loc))
    
    fld = KML.Folder(
        fld1,
        fld2,
        fld3,
        GX.Tour(playlist),
    )
    
    print etree.tostring(fld, pretty_print=True)
github Wireless-Innovation-Forum / Spectrum-Access-System / src / data / uscabdry.py View on Github external
coordinateLists = []
for seg in segments:
  lineString = ConvertSegmentToLineString(seg)
  coordinateLists.append(lineString)

# Note: this deep copy is for debugging purposes: to add the source data
# to the output KML file for comparison to the derived data.
coordx = copy.deepcopy(coordinateLists)

consolidatedStrings = ConsolidateLists(coordinateLists)
lineStrings = SpliceLists(consolidatedStrings)


doc = KML.kml(
  KML.Document(
    KML.name('US-Canada Border'),
    KML.Style(
      KML.LineStyle(
        KML.color('ff0000ff'),
        KML.width(5)
      ),
      id="stl"
    ),
    KML.Style(
      KML.LineStyle(
        KML.color('0000ffff'),
        KML.width(15)
      ),
      id="stlx"
    ),
  )
)