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


Python KML_ElementMaker.color方法代码示例

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


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

示例1: initDocument

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def initDocument():
	doc = KML.kml(
		KML.Document(
			KML.Name("Sun Position"),
			KML.Style(
				KML.IconStyle(
					KML.scale(1.2),
					KML.Icon(
						KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
					),
				),
				id="truc"
			),
			KML.Style(
				KML.LineStyle(
					KML.color("ff0000ff"),
					KML.width(1)
				),
				KML.PolyStyle(
					KML.color("ffff0000")
				),
				id="redLineBluePoly"
			)
		)
	)
	return doc
开发者ID:will421,项目名称:PROJET_VM,代码行数:28,代码来源:kmlwriter.py

示例2: TranslateShpFileToKML

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def TranslateShpFileToKML(file):
  print 'Translating file %s' % file
  basename = os.path.splitext(os.path.basename(file))[0]
  doc = KML.kml(
    KML.Document(
      KML.name('US Census Tracts ' + basename),
      KML.Style(
        KML.LineStyle(
          KML.color('ff00ff00'),
          KML.width(2)
        ),
        KML.PolyStyle(
          KML.color('66006600')
        ),
        id="ts"
      )
    )
  )
  ProcessShpFile(file, basename, doc)

  kmlFilename = os.path.join(os.path.dirname(file), basename + '.kml')
  print 'Writing output file %s' % kmlFilename
  outputFile = open(kmlFilename, 'w+')
  outputFile.write(etree.tostring(doc, pretty_print=True))
  outputFile.close()
开发者ID:Wireless-Innovation-Forum,项目名称:Spectrum-Access-System,代码行数:27,代码来源:census_tracts_kml.py

示例3: colourStyle

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
 def colourStyle(self,
                doc,
                colourID,
                colour_normal,
                width_normal,
                colour_highlight,
                width_highlight):
     """
     Append line style elements to a KML document.
     Arguments:
     doc: KML document to hold the new styles
     colourID: the base ID for the styles
     colour_normal: normal colour for the line
     width_normal: normal width for the line
     colour_highlight: highlighted colour for the line
     width_highlight: highlighted width for the line
     """
     doc.append(
         KML.Style(
             KML.IconStyle(
                 KML.Icon(),
                 id="no_icon_n"
             ),
             KML.LineStyle(
                 KML.color(colour_normal),
                 KML.width(width_normal)
             ),
             id=(colourID + '_n')
         )
     )
     doc.append(
         KML.Style(
             KML.IconStyle(
                 KML.Icon(),
                 id="no_icon_h"
             ),
             KML.LineStyle(
                 KML.color(colour_highlight),
                 KML.width(width_highlight)
             ),
             id=(colourID + '_h')
         )
     )
     doc.append(
         KML.StyleMap(
             KML.Pair(
                 KML.key('normal'),
                 KML.styleUrl('#' + colourID + '_n')
             ),
             KML.Pair(
                 KML.key('highlight'),
                 KML.styleUrl('#' + colourID + '_h')
             ),
             id=colourID
         )
     )
开发者ID:redmanr,项目名称:jpggps2kml,代码行数:58,代码来源:jpggps2kml.py

示例4: run

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
 def run(self):
     self.counter = self.counter + 1
     self.origin = osr.SpatialReference ()
     self.origin.ImportFromEPSG(self.EPSG)
     stylename = "export_dm"
     
     doc = KML.kml()
     document = KML.Document()
     docname = KML.Name("DynaMind Export")
     document.append(docname)
     doc.append(document)
     document.append(
     KML.Style(
         KML.LineStyle(
             KML.width(3),
             KML.color(self.rgb_to_hex( 0,255,255,255)),
         ),
         KML.PolyStyle(
                     KML.color(self.rgb_to_hex( 0,255,255,255)),
                     ),
                     id="#SWMM",
         )
     )
     
     fld = KML.Folder()
     
     
     city = self.getData("City")   
     uuids = city.getUUIDs(View(self.ViewName, COMPONENT, READ))
     objectid_total = 0
     
     
     
     for uuid in uuids:
         #getLinks
         building = city.getComponent(uuid)
         objects = []
         if self.Type == "COMPONENT":
             center = Node(building.getAttribute("centroid_x").getDouble(), building.getAttribute("centroid_y").getDouble(),0.0)
             LinkAttributes = building.getAttribute("Geometry").getLinks()
             for attribute in LinkAttributes:
                 objects.append(attribute.uuid)
             self.createPlacemarkForSelection(city.getComponent(uuid), uuid, center, fld)
         if self.Type == "FACE":
                 objects.append(uuid)        
                 self.createPlacemarkAsLineRing(city, objects, fld)                    
                 document.append(self.create_syles(city, uuid))
         if self.Type == "EDGE":
                 objects.append(uuid)
                 self.createPlacemarkAsLineString(city, objects, fld)
             
     doc.Document.append(fld)
     text_file = open(self.Filename+"_"+str(self.counter)+str(".kml"), "w")
     text_file.write(etree.tostring(doc, pretty_print=True))
     text_file.close()
开发者ID:iut-ibk,项目名称:PowerVIBe,代码行数:57,代码来源:exportkml.py

示例5: finish

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
    def finish(self, kmlFilename):
        rospy.loginfo("[KMLTourGenerator] finish()")
        if (self.hasFinished):
            return

        self.path_fld.append(KML.Placemark(
            KML.name('plan-path'),
            KML.extrude("1"),
            KML.tessellate("1"),
            KML.altitudeMode("absolute"),
            KML.Style(
                KML.LineStyle(
                    KML.color('7FFF0000'),
                    KML.width(5)
                ),
                KML.PolyStyle(
                    KML.color('7FFFFF00')
                )
            ),
            KML.LineString(
                KML.tessellate("1"),
                KML.altitudeMode("absolute"),
                KML.coordinates(self.planCoordListStr)
            )
        ))

        self.path_fld.append(KML.Placemark(
            KML.name('exec-path'),
            KML.altitudeMode("absolute"),
            KML.Style(
                KML.LineStyle(
                    KML.color('7F0000FF'),
                    KML.width(5)
                ),
                KML.PolyStyle(
                    KML.color('7FFFFFFF')
                )
            ),
            KML.LineString(
                KML.extrude("1"),
                KML.tessellate("1"),
                KML.altitudeMode("absolute"),
                KML.coordinates(self.execCoordListStr)
            )
        ))
        
        # check that the KML document is valid using the Google Extension XML Schema
        #assert(Schema("kml22gx.xsd").validate(self.tour_doc))

        #print etree.tostring(self.tour_doc, pretty_print=True)

        # output a KML file (named based on the Python script)
        outfile = file(kmlFilename,'w')
        outfile.write(etree.tostring(self.tour_doc, pretty_print=True))            
        self.hasFinished = True
开发者ID:silviomaeta,项目名称:kml_util,代码行数:57,代码来源:generate_kml.py

示例6: add_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def add_style(doc, color, highlight):

    # Add the normal style for the KML
    doc.append(KML.Style(
        KML.IconStyle(
            KML.color(color),
            KML.scale(1.1),
            KML.Icon(
                KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
            ),
            KML.hotspot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
        ),

        KML.LabelStyle(
            KML.scale(1.1)
        ),

        id='icon-503-{}-normal'.format(color)))

    # Add the highlight style for the KML
    doc.append(KML.Style(
        KML.IconStyle(
            KML.color(highlight),
            KML.scale(1.1),
            KML.Icon(
                KML.href('http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png')
            ),
            KML.hotSpot('', x='16', y='31', xunits='pixels', yunits='insetPixels'),
        ),

        KML.LabelStyle(
            KML.scale(1.1)
        ),

        id='icon-503-{}-highlight'.format(highlight)))

    # Set the style map
    doc.append(KML.StyleMap(
        KML.Pair(
            KML.key('normal'),
            KML.styleUrl('#icon-503-{}-normal'.format(color))
        ),

        KML.Pair(
            KML.key('highlight'),
            KML.styleUrl('#icon-503-{}-highlight'.format(highlight))
        ),

        id='icon-503-{}'.format(color)))

    return doc
开发者ID:mlockwood,项目名称:go_transit_src,代码行数:53,代码来源:stop_kml.py

示例7: create_kml_placemarks_for_tracks_and_waypoints

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def create_kml_placemarks_for_tracks_and_waypoints(tracks, waypoints, sample=1, description=None, color=None, name=None):
    placemarks = []
    tracks = tracks or []
    waypoints = waypoints or []

    for track in tracks:
        coordinates = ["%s,%s" % (p.longitude, p.latitude) for i, p in enumerate(track.points) if
                       i % sample == 0 or len(track.points) < 100]
        placemarks.append(
            KML.Placemark(
                KML.name(name or track.name),
                KML.description(description or track.description or ""),
                KML.Style(
                    KML.LineStyle(
                        KML.color(color) if color else get_random_color(),
                        KML.width(3)
                    )
                ),
                KML.MultiGeometry(
                    KML.LineString(
                        KML.coordinates(" ".join(coordinates))
                    )
                )
            )
        )

    for waypoint in waypoints:
        coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
        placemarks.append(
            KML.Placemark(
                KML.name(name or waypoint.name),
                KML.description(description or waypoint.description or ""),
                KML.Style(
                    KML.IconStyle(
                        KML.color("ffffffff"),
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href(
                                "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
                        ),
                    ),
                    KML.LabelStyle(
                        KML.scale(0.0)
                    )
                ),
                KML.Point(
                    KML.coordinates(coordinates)
                )
            )
        )
    return placemarks
开发者ID:lbosson,项目名称:geoblogger,代码行数:53,代码来源:kml_helpers.py

示例8: write_boundary_grid_kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
  def write_boundary_grid_kml(self, boundary, datetime, boundary_grids):
    if self.logger:
      self.logger.info("Start write_boundary_grid_kml for boundary: %s Date: %s" % (boundary, datetime))
    kml_doc = KML.kml(KML.Document(
                        KML.Name("Boundary: %s" % (boundary)),
                        KML.Style(
                          KML.LineStyle(
                            KML.color('ffff0000'),
                            KML.width(3),
                          ),
                          KML.PolyStyle(
                            KML.color('800080ff'),
                          ),
                          id='grid_style'
                        )
                      )
    )

    #doc = etree.SubElement(kml_doc, 'Document')
    try:
      for polygon, val in boundary_grids:
        coords = " ".join("%s,%s,0" % (tup[0],tup[1]) for tup in polygon.exterior.coords[:])
        kml_doc.Document.append(KML.Placemark(KML.name('%f' % val),
                                              KML.styleUrl('grid_style'),
                                               KML.Polygon(
                                                 KML.outerBoundaryIs(
                                                   KML.LinearRing(
                                                    KML.coordinates(coords)
                                                   )
                                                 )
                                               ))
        )
    except (TypeError,Exception) as e:
      if self.logger:
        self.logger.exception(e)
    else:
      try:
        kml_outfile = "%s%s_%s.kml" % (self.KMLDir, boundary, datetime.replace(':', '_'))
        if self.logger:
          self.logger.debug("write_boundary_grid_kml KML outfile: %s" % (kml_outfile))
        kml_file = open(kml_outfile, "w")
        kml_file.write(etree.tostring(kml_doc, pretty_print=True))
        kml_file.close()
      except (IOError,Exception) as e:
        if self.logger:
          self.logger.exception(e)

    if self.logger:
      self.logger.info("End write_boundary_grid_kml for boundary: %s Date: %s" % (boundary, datetime))
    return
开发者ID:DanRamage,项目名称:commonfiles,代码行数:52,代码来源:wqXMRGProcessing.py

示例9: create_reference_point_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def create_reference_point_element(inps, lats, lons, ts_obj):

    star_file = "star.png"

    colormap = mpl.cm.get_cmap(inps.colormap)  # set colormap
    norm = mpl.colors.Normalize(vmin=inps.vlim[0], vmax=inps.vlim[1])

    ref_yx = (int(ts_obj.metadata['REF_Y']), int(ts_obj.metadata['REF_X']))
    ref_lalo = (lats[ref_yx[0], ref_yx[1]], lons[ref_yx[0], ref_yx[1]])

    reference_point = KML.Placemark(
        KML.Style(
            KML.IconStyle(
                KML.color(get_color_for_velocity(0.0, colormap, norm)),
                KML.scale(1.),
                KML.Icon(KML.href("{}".format(star_file)))
            )
        ),
        KML.description("Reference point <br /> \n <br /> \n" +
                        generate_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 reference_point, star_file
开发者ID:hfattahi,项目名称:PySAR,代码行数:29,代码来源:save_kmz_timeseries.py

示例10: createKMLFromContainer

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def createKMLFromContainer(data, filename):
    iconColors = ["ff0000ff", "ff00ff00", "ffff0000", "ff00ffff", "ffff00ff", "ffffff00"]
    doc = KML.Document()
    for i, color in enumerate(iconColors):
        doc.append(
            KML.Style(
                KML.IconStyle(
                    KML.color(color),
                ),
                id="report-style-" + str(i)
            )
        )
    doc.append(KML.Folder("all"))
    colorIndex = 0
    for tIndex, task in enumerate(data):
        print task
        for hIndex, house in enumerate(task.info["houses"]):
            pm = KML.Placemark(
                KML.styleUrl("#report-style-" + str(colorIndex % len(iconColors))),
                KML.name(str(tIndex) + "-" + str(hIndex)),
                KML.Point(
                    KML.coordinates("{0},{1}".format(house["geometry"]["coordinates"][0],
                                                     house["geometry"]["coordinates"][1]))
                )
            )

            doc.Folder.append(pm)
        colorIndex += 1
    out = open(filename, "wb")
    out.write(etree.tostring(doc, pretty_print=True))
    out.close()
开发者ID:teleyinex,项目名称:app-rural-geolocator,代码行数:33,代码来源:createHouseKML.py

示例11: newKML

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def newKML():
    doc = KML.Document() 
    
    jet = plt.get_cmap('jet')
    
    colorList = {}
    for k in range(11):
        colorList[k] = matplotlib.colors.rgb2hex(jet(k/10.0))[1:]
    
    for (colorName, colorCode) in colorList.iteritems():
        style = KML.Style(
                    KML.IconStyle(
                        KML.color("FF{}".format(colorCode)),
                        KML.scale(0.6)
                    ),
                    KML.LabelStyle(KML.scale(0.5)),
                    id="house_{}".format(colorName)
                )
        styleMap = KML.StyleMap(
                    KML.Pair(
                        KML.key("normal"),
                        KML.styleUrl("house_{}".format(colorName))
                    ),
                    id="stylemap_house_{}".format(colorName))
                
        doc.append(style)
        doc.append(styleMap)    
    return doc
开发者ID:jyskwong,项目名称:houses,代码行数:30,代码来源:kmllib.py

示例12: create_kml_from_waypoint

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def create_kml_from_waypoint(waypoint):
    coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
    doc = KML.kml(
        KML.Document(
            KML.Placemark(
                KML.name(waypoint.name),
                KML.description(waypoint.description if waypoint.description else ""),
                KML.Style(
                    KML.IconStyle(
                        KML.color("ffffffff"),
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
                        ),
                    ),
                    KML.LabelStyle(
                        KML.scale(0.0)
                    )
                ),
                KML.Point(
                    KML.coordinates(coordinates)
                )
            )
        )
    )
    return doc
开发者ID:lbosson,项目名称:geoblogger,代码行数:28,代码来源:kml_helpers.py

示例13: kml_colors

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
 def kml_colors(self, alpha=1.0):
     '''Generates PyKML <Color> instances for each color in the ramp'''
     return map(lambda c: KML.color('{a}{b}{g}{r}'.format(**{
         'a': '{:02x}'.format(int(alpha * 255)),
         'r': c[1:3],
         'g': c[3:5],
         'b': c[5:7]
     })), self.hex_colors())
开发者ID:arthur-e,项目名称:flux-python-api,代码行数:10,代码来源:colors.py

示例14: create_style

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
 def create_style(id_, color, width, scale, icon):
   style = KML.Style(id=id_)
   if scale is not None:
     icon_style = KML.IconStyle(KML.scale(scale))
     if icon is not None:
       icon_style.append(KML.Icon(KML.href(icon)))
     style.append(icon_style)
   if (color is not None) and (width is not None):
     line_style = KML.LineStyle(KML.color(color), KML.width(width))
     style.append(line_style)
   return KmlStyle(id_, [style])
开发者ID:IoannisIn,项目名称:cellbots,代码行数:13,代码来源:earth.py

示例15: get_kml_for_queryset

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import color [as 别名]
def get_kml_for_queryset(queryset, filename=_('Geographical objects')):
    """
    :param queryset: GeoObject queryset
    :return: KML file from GeoObject queryset
    """
    kml = KML.kml(KML.Document(KML.open(1)))

    geo_objects = queryset.values_list('color', 'title', 'lat', 'lon', 'geometry', 'short_description')
    colors = set(items[0] for items in sorted(geo_objects))
    colors_dict = {color: convert_color_hex_to_kml(color) for color in colors}

    for line_color, polygon_color in colors_dict.values():
        kml.Document.append(KML.Style(
            KML.PolyStyle(KML.color(polygon_color)),
            KML.LineStyle(KML.color(line_color), KML.width(2)),
            id=line_color,
        ))
        print(line_color, polygon_color)

    for (color, title, lat, lon, polygon, short_description) in geo_objects:
            style_id = colors_dict[color][0]
            fld = KML.Folder(
                KML.name(title),
                KML.Placemark(
                    KML.name(title),
                    KML.styleUrl('#' + style_id),
                    KML.description(short_description),
                    KML.Point(KML.coordinates("{},{},0".format(lon, lat)))
                )
            )

            if polygon:
                polygon = parser.fromstring(polygon.kml)
                fld.append(KML.Placemark(KML.name(title), KML.styleUrl('#' + style_id),
                                         KML.description(short_description), polygon))

            kml.Document.append(fld)

    kml_str = '<?xml version="1.0" encoding="UTF-8"?>\n' + etree.tostring(kml, pretty_print=True).decode()
    return get_file_response(kml_str, filename)
开发者ID:,项目名称:,代码行数:42,代码来源:


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