本文整理汇总了Python中qgis.core.QgsMarkerSymbolV2类的典型用法代码示例。如果您正苦于以下问题:Python QgsMarkerSymbolV2类的具体用法?Python QgsMarkerSymbolV2怎么用?Python QgsMarkerSymbolV2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsMarkerSymbolV2类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_syms
def update_syms(self, catalogue):
self.syms = {}
for flag in set(catalogue.data['Cluster_Flag'].tolist()):
for index in set(catalogue.data['Cluster_Index'].tolist()):
# main shock
point = QgsMarkerSymbolV2.createSimple(
{'color': 'blue', 'name': 'square'})
if index: # belongs to a cluster
color = self.catalogue_model.cluster_color(index)
# non poissonian
if flag:
point = QgsMarkerSymbolV2.createSimple(
{'color': 'blue', 'name': 'triangle'})
color.setAlpha(125 + 125 * abs(flag))
point.setSize(3)
point.setColor(color)
else:
point = QgsSymbolV2.defaultSymbol(QGis.Point)
point.setColor(QtGui.QColor("0,0,0,125"))
point.setSize(1.5)
self.syms[self.Cluster(index, flag)] = point
示例2: legend_test
def legend_test(self):
self.mAtlasMap.setAtlasDriven(True)
self.mAtlasMap.setAtlasScalingMode(QgsComposerMap.Auto)
self.mAtlasMap.setAtlasMargin(0.10)
# add a point layer
ptLayer = QgsVectorLayer("Point?crs=epsg:4326&field=attr:int(1)&field=label:string(20)", "points", "memory")
pr = ptLayer.dataProvider()
f1 = QgsFeature(1)
f1.initAttributes(2)
f1.setAttribute(0, 1)
f1.setAttribute(1, "Test label 1")
f1.setGeometry(QgsGeometry.fromPoint(QgsPoint(-0.638, 48.954)))
f2 = QgsFeature(2)
f2.initAttributes(2)
f2.setAttribute(0, 2)
f2.setAttribute(1, "Test label 2")
f2.setGeometry(QgsGeometry.fromPoint(QgsPoint(-1.682, 48.550)))
pr.addFeatures([f1, f2])
# categorized symbology
r = QgsCategorizedSymbolRendererV2("attr", [QgsRendererCategoryV2(1, QgsMarkerSymbolV2.createSimple({"color": "255,0,0"}), "red"),
QgsRendererCategoryV2(2, QgsMarkerSymbolV2.createSimple({"color": "0,0,255"}), "blue")])
ptLayer.setRendererV2(r)
QgsMapLayerRegistry.instance().addMapLayer(ptLayer)
# add the point layer to the map settings
layers = self.mapSettings.layers()
layers = [ptLayer.id()] + layers
self.mapSettings.setLayers(layers)
# add a legend
legend = QgsComposerLegend(self.mComposition)
legend.moveBy(200, 100)
# sets the legend filter parameter
legend.setComposerMap(self.mAtlasMap)
legend.setLegendFilterOutAtlas(True)
self.mComposition.addComposerLegend(legend)
self.mAtlas.beginRender()
self.mAtlas.prepareForFeature(0)
self.mLabel1.adjustSizeToText()
checker = QgsCompositionChecker('atlas_legend', self.mComposition)
myTestResult, myMessage = checker.testComposition()
assert myTestResult
self.mAtlas.endRender()
# restore state
self.mapSettings.setLayers([layers[1]])
self.mComposition.removeComposerItem(legend)
QgsMapLayerRegistry.instance().removeMapLayer(ptLayer.id())
示例3: createMarkerSymbol
def createMarkerSymbol():
symbol = QgsMarkerSymbolV2.createSimple({
"color": "100,150,50",
"name": "square",
"size": "3.0"
})
return symbol
示例4: setUp
def setUp(self):
self.iface = get_iface()
polys_shp = os.path.join(TEST_DATA_DIR, 'polys.shp')
points_shp = os.path.join(TEST_DATA_DIR, 'points.shp')
lines_shp = os.path.join(TEST_DATA_DIR, 'lines.shp')
self.polys_layer = QgsVectorLayer(polys_shp, 'Polygons', 'ogr')
self.points_layer = QgsVectorLayer(points_shp, 'Points', 'ogr')
self.lines_layer = QgsVectorLayer(lines_shp, 'Lines', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(self.polys_layer)
QgsMapLayerRegistry.instance().addMapLayer(self.lines_layer)
QgsMapLayerRegistry.instance().addMapLayer(self.points_layer)
# Create style
sym1 = QgsFillSymbolV2.createSimple({'color': '#fdbf6f'})
sym2 = QgsLineSymbolV2.createSimple({'color': '#fdbf6f'})
sym3 = QgsMarkerSymbolV2.createSimple({'color': '#fdbf6f'})
self.polys_layer.setRendererV2(QgsSingleSymbolRendererV2(sym1))
self.lines_layer.setRendererV2(QgsSingleSymbolRendererV2(sym2))
self.points_layer.setRendererV2(QgsSingleSymbolRendererV2(sym3))
self.mapsettings = self.iface.mapCanvas().mapSettings()
self.mapsettings.setOutputSize(QSize(400, 400))
self.mapsettings.setOutputDpi(96)
self.mapsettings.setExtent(QgsRectangle(-133, 22, -70, 52))
示例5: getmap
def getmap(self):
if self.canvas:
settings = self.canvas.mapSettings()
layers = settings.layers()
if GPS.isConnected:
try:
gpslayer = QgsMapLayerRegistry.instance().mapLayersByName("__gps_layer")[0]
except IndexError:
gpslayer = QgsVectorLayer("Point", "__gps_layer", "memory")
symbol = QgsMarkerSymbolV2.createSimple({'name': 'circle', 'color': 'blue', "size": '5'})
gpslayer.rendererV2().setSymbol(symbol)
QgsMapLayerRegistry.instance().addMapLayer(gpslayer, False)
layers.append(gpslayer.id())
settings.setLayers(layers)
map_pos = QgsPoint(GPS.gpsinfo("longitude"), GPS.gpsinfo("latitude"))
# map_pos = QgsPoint(115.72589,-32.29597)
geom = QgsGeometry.fromPoint(map_pos)
feature = QgsFeature()
feature.setGeometry(geom)
gpslayer.startEditing()
gpslayer.addFeature(feature)
# gpslayer.commitChanges()
self.renderjob = QgsMapRendererParallelJob(settings)
self.renderjob.finished.connect(self.rendermap)
self.renderjob.start()
示例6: __init__
def __init__(self):
QgsFeatureRendererV2.__init__(self, "CatalogueCompletenessRenderer")
complete = QgsSymbolV2.defaultSymbol(QGis.Point)
uncomplete = QgsMarkerSymbolV2.createSimple(
{'color': 'blue', 'name': 'triangle'})
uncomplete.setSize(3)
complete.setSize(1.5)
complete.setColor(QtGui.QColor(255, 0, 0, 125))
self.syms = [complete, uncomplete]
示例7: create_qlayer
def create_qlayer(self):
layer= QgsVectorLayer("Point"+self.crs, self.prefix+"-nodes", "memory")
# nice clean black dot
symbol = QgsMarkerSymbolV2.createSimple({'outline_style':'no',
'name': 'circle',
'size_unit':'MM',
'size':'1',
'color': 'black'})
layer.rendererV2().setSymbol(symbol)
return layer
示例8: addLayer
def addLayer(self):
uri = QgsDataSourceURI()
# set host name, port, database name, username and password
#uri.setConnection("localhost", "5432", "jguelat", "jguelat", "")
uri.setConnection("local_jguelat", "", "", "")
# set database schema, table name, geometry column and optionally subset (WHERE clause)
uri.setDataSource("public", self.tableCombo.currentText(), "geom", "species_id = " + self.speciesCombo.currentText())
#vlayer = self.iface.addVectorLayer(uri.uri(), "Species " + self.speciesCombo.currentText(), "postgres")
vlayer = QgsVectorLayer(uri.uri(), "Species " + self.speciesCombo.currentText(), "postgres")
props = vlayer.rendererV2().symbol().symbolLayer(0).properties()
props['size'] = '3'
props['color'] = 'blue'
vlayer.rendererV2().setSymbol(QgsMarkerSymbolV2.createSimple(props))
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
QgsMessageLog.logMessage("Tout est OK", 'BirdChooser', QgsMessageLog.INFO)
示例9: test_point_ordered_symbol_bound_offset
def test_point_ordered_symbol_bound_offset(self):
# Test ordered placements for point using symbol bounds offset
self.layer = TestQgsPalLabeling.loadFeatureLayer('point_ordered_placement')
# Make a big symbol
symbol = QgsMarkerSymbolV2.createSimple({u'color': u'31,120,180,255',
u'outline_color': u'0,0,0,0',
u'outline_style': u'solid',
u'size': u'10',
u'name': u'rectangle',
u'size_unit': u'MM'})
renderer = QgsSingleSymbolRendererV2(symbol)
self.layer.setRendererV2(renderer)
self._TestMapSettings = self.cloneMapSettings(self._MapSettings)
self.lyr.placement = QgsPalLayerSettings.OrderedPositionsAroundPoint
self.lyr.dist = 2
self.lyr.offsetType = QgsPalLayerSettings.FromSymbolBounds
self.checkTest()
self.removeMapLayer(self.layer)
self.layer = None
示例10: testInitialSizeSymbolMapUnits
def testInitialSizeSymbolMapUnits(self):
"""Test initial size of legend with a symbol size in map units"""
point_path = os.path.join(TEST_DATA_DIR, 'points.shp')
point_layer = QgsVectorLayer(point_path, 'points', 'ogr')
QgsMapLayerRegistry.instance().addMapLayers([point_layer])
marker_symbol = QgsMarkerSymbolV2.createSimple({'color': '#ff0000', 'outline_style': 'no', 'size': '5', 'size_unit': 'MapUnit'})
point_layer.setRendererV2(QgsSingleSymbolRendererV2(marker_symbol))
s = QgsMapSettings()
s.setLayers([point_layer.id()])
s.setCrsTransformEnabled(False)
composition = QgsComposition(s)
composition.setPaperSize(297, 210)
composer_map = QgsComposerMap(composition, 20, 20, 80, 80)
composer_map.setFrameEnabled(True)
composition.addComposerMap(composer_map)
composer_map.setNewExtent(point_layer.extent())
legend = QgsComposerLegend(composition)
legend.setSceneRect(QRectF(120, 20, 80, 80))
legend.setFrameEnabled(True)
legend.setFrameOutlineWidth(2)
legend.setBackgroundColor(QColor(200, 200, 200))
legend.setTitle('')
composition.addComposerLegend(legend)
legend.setComposerMap(composer_map)
checker = QgsCompositionChecker(
'composer_legend_mapunits', composition)
checker.setControlPathPrefix("composer_legend")
result, message = checker.testComposition()
self.assertTrue(result, message)
QgsMapLayerRegistry.instance().removeMapLayers([point_layer.id()])
示例11: setUp
def setUp(self):
# Create some simple symbols
self.fill_symbol = QgsFillSymbolV2.createSimple({"color": "#ffffff"})
self.line_symbol = QgsLineSymbolV2.createSimple({"color": "#ffffff", "line_width": "3"})
self.marker_symbol = QgsMarkerSymbolV2.createSimple({"color": "#ffffff", "size": "3"})
self.report = "<h1>Python QgsSymbolV2 Tests</h1>\n"
示例12: QgsSizeScaleWidget
# coding: utf-8
from qgis.core import QgsMarkerSymbolV2
from qgis.gui import QgsSizeScaleWidget
from qgis.utils import iface
layer = iface.activeLayer()
canvas = iface.mapCanvas()
marker_symbol_v2 = QgsMarkerSymbolV2.createSimple({"color": "blue", "name": "triangle"})
size_scale_widget = QgsSizeScaleWidget(layer, marker_symbol_v2)
size_scale_widget.setMapCanvas(canvas)
size_scale_widget.show()
示例13: apply
def apply(self, layer):
symbol = QgsMarkerSymbolV2.createSimple({'name': self.shape,
'color': self.color})
self.renderer = QgsSingleSymbolRendererV2(symbol)
super(SimpleSymbology, self).apply(layer)