当前位置: 首页>>代码示例>>Python>>正文


Python simplekml.Kml方法代码示例

本文整理汇总了Python中simplekml.Kml方法的典型用法代码示例。如果您正苦于以下问题:Python simplekml.Kml方法的具体用法?Python simplekml.Kml怎么用?Python simplekml.Kml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simplekml的用法示例。


在下文中一共展示了simplekml.Kml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: coordListsToKml

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def coordListsToKml(resultFeatureInfo, cloudFeatureInfo, kmlPath, floodInfo):
    '''Converts a local coordinate list to KML'''
       
    # Initialize kml document
    kml = simplekml.Kml()
    kml.document.name = 'ASP CMT flood detections - DATE'
    kml.document.description = writeKmlDescription(floodInfo)
    kml.hint = 'target=earth'

    WATER_COLOR = 'FFF0E614' # Solid teal
    CLOUD_COLOR = 'FFFFFFFF' # Solid white
    addFeatureSet(kml, cloudFeatureInfo,  CLOUD_COLOR)
    addFeatureSet(kml, resultFeatureInfo, WATER_COLOR)
    
    # Save kml document
    print 'Saving: ' + kmlPath
    kml.save(kmlPath) 
开发者ID:nasa,项目名称:CrisisMappingToolkit,代码行数:19,代码来源:detect_flood_cmd.py

示例2: kml_export

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def kml_export(self, _):
        kml = simplekml.Kml()
                
        for node in self.network.nodes.values():
            point = kml.newpoint(name=node.name, description=node.description)
            point.coords = [(node.longitude, node.latitude)]
            point.style = self.styles[node.subtype]
            point.style.labelstyle.scale = float(self.node_size.text())
            
        for link in self.network.all_links():
            line = kml.newlinestring(name=link.name, description=link.description) 
            line.coords = [(link.source.longitude, link.source.latitude),
                        (link.destination.longitude, link.destination.latitude)]
            line.style = self.styles[link.subtype]
            line.style.linestyle.width = self.line_width.text() 
            
        filepath = QFileDialog.getSaveFileName(
                                               self, 
                                               'KML export', 
                                               'project', 
                                               '.kml'
                                               )
        selected_file = ''.join(filepath)
        kml.save(selected_file)
        self.close() 
开发者ID:afourmy,项目名称:pyNMS,代码行数:27,代码来源:export_to_google_earth_window.py

示例3: document

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def document(self):
        """
        The top level item in the kml document.

        0 or 1 top level document is required for a kml document, the default is an
        instance of :class:`simplekml.Document`. This property can be set to an
        instance of :class:`simplekml.Document` or :class:`simplekml.Folder` or to
        remove it completely set it to None

        Example::

            import simplekml
            kml = simplekml.Kml()
            kml.document = simplekml.Folder(name = "Top Level Folder")
            kml.save('Document Replacement.kml')
        """
        if self._feature is None:
            self._feature = Document()
        return self._feature 
开发者ID:unhcfreg,项目名称:DROP,代码行数:21,代码来源:kml.py

示例4: save

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def save(self, path, format=True):
        """Save the kml to the given file supplied by `path`.

        The KML is saved to a file in one long string if `format=False` else it
        gets saved "prettyprinted" (as formatted xml). This works the same as :func:`simplekml.Kml.kml`

        Usage::

            import simplekml
            kml = simplekml.Kml()
            kml.save("Saving.kml")
            #kml.save("Saving.kml", False)  # or this
        """
        Kmlable._setkmz(False)
        out = self._genkml(format)
        f = codecs.open(path, 'wb', 'utf-8')
        try:
            f.write(out)
        finally:
            f.close() 
开发者ID:unhcfreg,项目名称:DROP,代码行数:22,代码来源:kml.py

示例5: addfile

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def addfile(self, path):
        """Adds an file to a KMZ and returns the path contained inside of the KMZ (files/...)

        This is useful for including images in a KMZ that are referenced from description balloons, as these files
        are not automatically included in a KMZ.

        Usage::

            import simplekml
            kml = simplekml.Kml()
            path = kml.addfile("a/path/to/somefile.file")
            pnt = pnt.newpoint()
            pnt.description = '<img src="' + path +'" alt="picture" width="400" height="300" align="left" />'

        *New in version 1.2.0*
        """
        Kmlable._addimage(path)
        return os.path.join('files', os.path.split(path)[1]).replace("\\", "/") 
开发者ID:unhcfreg,项目名称:DROP,代码行数:20,代码来源:kml.py

示例6: write_overlay

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def write_overlay(tiles, outdir, m, M, key):
    print("Rescale the input pixels values")
    print("from the range %f to %f to the range 0 to 255" % (m, M))
    print("Create ground overlay...")
    kml = simplekml.Kml()
    add = 1
    add_tot = len(tiles)
    for tile in tiles:
        sys.stdout.write("\r%d/%d"% (add, add_tot))
        sys.stdout.flush()
        add += 1
        dsm = os.path.join(tile, 'dsm.tif')
        gdal_to_ground_overlay(dsm, "_".join(dsm.split(os.sep)[-3:-1]),
                               kml, outdir, M, m)
    kml.save(os.path.join(outdir, "%s_ground_overlay.kml" % key))
    print()
    print("kml saved") 
开发者ID:cmla,项目名称:s2p,代码行数:19,代码来源:kml_tilemap.py

示例7: dump_flight_to_kml

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def dump_flight_to_kml(flight, kml_filename_local):
    """Dumps the flight to KML format.

    Args:
        flight: an igc_lib.Flight, the flight to be saved
        kml_filename_local: a string, the name of the output file
    """
    assert flight.valid
    kml = simplekml.Kml()

    def add_point(name, fix):
        kml.newpoint(name=name, coords=[(fix.lon, fix.lat)])

    coords = []
    for fix in flight.fixes:
        coords.append((fix.lon, fix.lat))
    kml.newlinestring(coords=coords)

    add_point(name="Takeoff", fix=flight.takeoff_fix)
    add_point(name="Landing", fix=flight.landing_fix)

    for i, thermal in enumerate(flight.thermals):
        add_point(name="thermal_%02d" % i, fix=thermal.enter_fix)
        add_point(name="thermal_%02d_END" % i, fix=thermal.exit_fix)
        kml_filename = Path(kml_filename_local).expanduser().absolute()
    kml.save(kml_filename.as_posix()) 
开发者ID:xiadz,项目名称:igc_lib,代码行数:28,代码来源:dumpers.py

示例8: kml_export

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def kml_export(self):
        kml = simplekml.Kml()
        
        point_style = simplekml.Style()
        point_style.labelstyle.color = simplekml.Color.blue
        point_style.labelstyle.scale = float(self.node_size.text())
        point_style.iconstyle.icon.href = self.path_edit.text()
        
        for node in self.controller.view.nodes.values():
            point = kml.newpoint(name=node.name, description=node.description)
            point.coords = node.coords
            point.style = point_style
            
        line_style = simplekml.Style()
        line_style.linestyle.color = simplekml.Color.red
        line_style.linestyle.width = self.line_width.text()
            
        for link in self.controller.view.links.values():
            line = kml.newlinestring(name=link.name, description=link.description) 
            line.coords = link.coords
            line.style = line_style
            
        filepath = QFileDialog.getSaveFileName(
                                               self, 
                                               'KML export', 
                                               'project', 
                                               '.kml'
                                               )
        selected_file = ''.join(filepath)
        kml.save(selected_file)
        self.close() 
开发者ID:afourmy,项目名称:pyEarth,代码行数:33,代码来源:extended_pyEarth.py

示例9: __init__

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def __init__(self, meta, kmlFile=None, kmlScale=1):
        #self.fieldnames = ['messageid'] + GPSPayload.fields + MotorPayload.fields + HPPayload.fields + RCPayload.fields + TabletLocPayload.fields + BatteryPayload.fields + GimbalPayload.fields + FlightStatPayload.fields + AdvBatteryPayload.fields
        self.tickNo = None
        self.row_out = {}
        self.packetNum = 0
        self.packets = []
        self.addedData = False
        self.meta = meta
        self.gps_fr_dict = {}
        
        self.kmlFile = kmlFile
        self.kmlWriter = None
        if self.kmlFile != None:
            self.kmlWriter = simplekml.Kml()
            self.kml_res = kmlScale
        # *********************************************
        # **** WARNING: THIS IS NOT THE PREFERED METHOD TO OBTAIN THE START TIME
        # ctime is the time the meta data (permissions) were last changed
        # THIS IS NOT THE CREATION TIME
        # We are assuming here that the last time the permissions were
        # touched was when the file was created. This may not be true.
        # If you do not wish to use this, just comment it out. It won't break anything ;)
        # *********************************************
        self.startUNIXTime = int(meta.st_ctime)
        # *********************************************
        # ********************************************* 
开发者ID:unhcfreg,项目名称:DROP,代码行数:28,代码来源:Message.py

示例10: hint

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def hint(self):
        """Assign a hint attribute to the KML tag.

        Possible values to use are:
          * target=moon
          * target=sky
          * target=mars

        Usage::

            from simplekml import Kml
            kml = Kml()
            kml.hint = 'target=moon'
            print kml.kml()

        Result:

        .. code-block:: xml

            <?xml version="1.0" encoding="UTF-8"?>
            <kml hint="target=moon" xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
                <Document id="feat_1"/>
            </kml>

        *New in version 1.1.0*
        """
        return self._hint 
开发者ID:unhcfreg,项目名称:DROP,代码行数:29,代码来源:kml.py

示例11: writer

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def writer(output, output_name, output_data):
    """
    The writer function writes JPEG and TIFF EXIF GPS data to a
    Google Earth KML file. This file can be opened in Google
    Earth and will use the GPS coordinates to create 'pins' on
    the map of the taken photo's location.
    :param output: The output directory to write the KML file.
    :param output_name: The name of the output KML file.
    :param output_data: The embedded EXIF metadata to be written
    :return:
    """

    kml = simplekml.Kml(name=output_name)
    for exif in output_data:
        if('Latitude' in exif.keys() and
        'Latitude Reference' in exif.keys() and
        'Longitude Reference' in exif.keys() and
        'Longitude' in exif.keys()):

            if 'Original Date' in exif.keys():
                dt = exif['Original Date']
            else:
                dt = 'N/A'

            if exif['Latitude Reference'] == 'S':
                latitude = '-' + exif['Latitude']
            else:
                latitude = exif['Latitude']

            if exif['Longitude Reference'] == 'W':
                longitude = '-' + exif['Longitude']
            else:
                longitude = exif['Longitude']

            kml.newpoint(name=exif['Name'],
            description='Originally Created: ' + dt,
            coords=[(longitude, latitude)])
        else:
            pass
    kml.save(os.path.join(output, output_name)) 
开发者ID:PacktPublishing,项目名称:Learning-Python-for-Forensics-Second-Edition,代码行数:42,代码来源:kml_writer.py

示例12: __init__

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def __init__(self):
        self.kml = simplekml.Kml() 
开发者ID:AtsushiSakai,项目名称:googleearthplot,代码行数:4,代码来源:googleearthplot.py

示例13: read_tiles

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def read_tiles(tile_files, outdir, m, M, key):
    tiles = []
    tile_file_dir = os.path.dirname(tile_files)
    err_log = os.path.join(outdir, "%s_invalid_tiles.txt" % key)
    kml = simplekml.Kml()

    with open(tile_files, 'r') as f:
        readlines = list(map(str.strip,
                             f.readlines()))
        with open(err_log, 'w') as ferr:
            for el in readlines:
                t = os.path.dirname(os.path.join(tile_file_dir, el))
                dsm = os.path.join(t, 'dsm.tif')
                message = "ok"
                if os.path.exists(dsm) is False:
                    message = "no dsm"

                if message != "ok":
                    ferr.write(t)
                    ferr.write('\n')
                    write_tiles_polygon(t, kml, m, M, message, True)
                    continue
                if message == "ok":
                    tiles.append(t)

    kml.save(os.path.join(outdir, "%s_error.kml" % key))

    return tiles 
开发者ID:cmla,项目名称:s2p,代码行数:30,代码来源:kml_tilemap.py

示例14: write_tiles_info

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def write_tiles_info(tiles, outdir, key):
    print("Create tiles info...")
    add = 1
    add_tot = len(tiles)

    kml = simplekml.Kml()
    for tile in tiles:
        sys.stdout.write("\r%d/%d"% (add, add_tot))
        sys.stdout.flush()
        add += 1
        write_tiles_polygon(tile, kml)

    kml.save(os.path.join(outdir, "%s_info.kml" % key))
    print()
    print("kml saved") 
开发者ID:cmla,项目名称:s2p,代码行数:17,代码来源:kml_tilemap.py

示例15: save_kml

# 需要导入模块: import simplekml [as 别名]
# 或者: from simplekml import Kml [as 别名]
def save_kml(self):
        import simplekml
        import scipy
        kml = simplekml.Kml()
        
        # markers
        for m in self.markers:
            ned = m['ned']
            lla = self.ned2lla( ned[0], ned[1], ned[2] )
            name = "%s%03d" % (self.id_prefix, m['id'])
            kml.newpoint(name=name,
                         coords=[(lla[1], lla[0], lla[2])],
                         description=m['comment'])  # lon, lat, elevation
        # area
        points = []
        for i in self.proj.image_list:
            ned, ypr, quat = i.get_camera_pose(opt=True)
            lla = self.ned2lla( ned[0], ned[1], ned[2] )
            points.append([lla[1], lla[0]])
        hull = scipy.spatial.ConvexHull(points)
        poly = hull.points[hull.vertices].tolist()
        poly.append(poly[0])    # close the loop
        ls = kml.newlinestring(name=pathlib.Path(self.proj.project_dir).name,
                               coords=poly)
        ls.style.linestyle.color = simplekml.Color.blue
            
        kmlname = os.path.join(self.proj.analysis_dir, 'annotations.kml')
        print('Saving annotations.kml:', kmlname)
        kml.save(kmlname) 
开发者ID:UASLab,项目名称:ImageAnalysis,代码行数:31,代码来源:annotations.py


注:本文中的simplekml.Kml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。