New answers tagged

4

Turn on the 3D Graphics toolbar, adjust some of the default text graphics properties before you add a label so that it is added large enough to see/find. Select the 3D Text tool Use the 3D Text tool to click on the feature you want to label, and type in the label you wish to display. Adjust the label properties for orientation and size. I've created ...


1

This should do the trick: def FindLabel ( [field1], [field2] ): if long([field2]) >= 1: return [field1] + "\n" + "(" + [field2] + ")" else: return [field1]


2

If I understand you, You need this


9

If 'Scaleable Vector Graphics' (.SVG) symbol is also an option, then yes you can use it for labeling objects (polygon in your case). Right click on the layer and navigate to Properties > Labels > Background. From the Shape dropdown select SVG and browse for the appropriate symbol as shown in the screen shot. As a result it will draw graphic symbols in the ...


1

I answer me myself. I don't like, but I only found this solution: I have used conditional function in label expression. "if" has 3 arguments (condition, label if true, label if not) This is the correct code from PyQt4.QtGui import QColor layer = iface.activeLayer() palyr = QgsPalLayerSettings() palyr.readFromLayer(layer) palyr.enabled = True ...


6

You need to set the "show label" expression (under Rendering) to "name" is not null and the label to "name".


2

For me in a simple: mc = self.iface.mapCanvas() lr = mc.labelingResults() extent = mc.extent() labellayer.startEditing() for lrl in lr.labelsWithinRect(extent): if lrl.layerID == labellayer.id(): angle = 90 - QgsPoint(lrl.cornerPoints[0]).azimuth(QgsPoint(lrl.cornerPoints[1])) fieldIdx = labellayerpr.fields().indexFromName('xpos') ...


4

You could to use an expression for labeling. You not must to label the "Street" Field directly: exemple: wordwrap("Street", 14)


3

Not sure if this will help in your situation but you can try using the following expression for the Wrap on character option which checks the length of characters: CASE WHEN length("Street") > 15 THEN ' ' END This checks that if the total number of characters for a feature in the field "Street" is over 15, the wrap character becomes a space. So: ...


0

You can remove the labels with removeLayer(label) when the popup appears and add them to map again when it closes.


0

I think this is done using the WikiProject Geographical coordinates: WikiProject Geographical coordinates aims to better organize location information in articles containing a set of numbers that identifies location on and relative to the Earth.


6

I believe the answer by @iant is the best method to use (when you get it working, you should accept his answer). Just want to add that you can use the following expressions in your filter for your 3 individual rules (you can add rules by clicking the + as shown in the image, set the expression filter and the svg symbol): "myfield" < 1300 "myfield" > ...


5

I think your best option would be to use Rule Based classification - there are a number of tutorials available - I like this one from Linfiniti.


5

As an alternative to using code in the label parser, you can filter labels and have different label styles for different labels, by using Label Classes instead of changing the label parser: In your layer properties Label Tab, select "Define classes of features and label each class differently" from the Method drop-down. Click on the "Add" button to add a ...


5

Please follow the python syntax-Just check if hike is in the Name. Below should work def FindLabel ([Name]): if 'hike' in [Name]: return [Name] But if you need to label only Name does not contain hike use below- def FindLabel ([Name]): if 'hike' not in [Name]: return [Name] 'LIKE' is an SQL operator that may be used with ...


1

Just make separate label classes and query what you want for each class. Your first class would be for Rec IS NOT NULL and then the second class would be for Rec IS NULL. Edit your expression accordingly.


2

There is an option where you use a feature as an obstacle to discourage labeling other features if they are overlapping each other. But as far as I know, it just shift the labels of one layer if they are overlapped by another layer. For example in your case you want to prevent contour lines to be labeled when they are covered by "New scratch layer". So you ...


0

Your problem seems to be this line: TextSymbolizer text = sb.createTextSymbolizer(null, fonts, sb.createHalo(), sb.attributeExpression("Location"), pointPlacement, "Location"); Where you use Location for the text but I suspect it is your geometry. I use code like this as I have a label attribute with the text I require, see this blog post for a longer ...



Top 50 recent answers are included