I can only give you a partial answer here without Python, but if most of your geometries are regular then the following might work.
1. Rule-based Labeling
Firstly, to independently manage two separate labels, use Rule-based labeling.
This lets you have separate labels for the same feature with settings independent of each other. Below I have two separate ...
You can do this with rule-based labeling
Select the layer properties of the layer that you are labeling and select the Labels tab. At the top, select Rule-based labeling and add a rule for each label (location, time, people). If you want to display a label for every item in the table, just don't add a filter to the rule.
You will need to play with the ...
You could use refFunctions plugin together with the expression geomwithin('polygon','$geometry') is NULL for that:
Replace 'polygon' with the name of your polygonlayer.
Just set the expression as filter and lables of points covered by the polygon will no longer be shown.
You can get the label text for each feature this way in QGIS 3:
layer = iface.activeLayer()
labeling = layer.labeling()
palyr = labeling.settings()
expression = QgsExpression(palyr.fieldName)
context = QgsExpressionContext()
for feature in layer.getFeatures():
The easiest way to do this is to duplicate the layer and then set the brush and pen styles to none.
You can then have two sets of labels,and use data defined Coordinates to control the placement of them.
I used x_min( $geometry) and y_max( $geometry) for one and the centroid for the other.
If it is not already a separate layer, separate Current Inventory from Previous Inventory using definition queries to create 2 layers. Use the Labeling toolbar, Label weights button to give the Current Inventory layer weights of a big number like 1000. That should push the other label away, however, it may have trouble placing it. It is hard to duplicate ...
You can find the quadrant position by using QgsPalLayerSettings::quadOffset():
This returns an enum integer reflecting the QuadrantPosition (e.g. 0 = QuadrantAboveLeft, 1 = QuadrantAbove etc.). We can create a dictionary to contain these values and then get the quadrant position name using something like:
layer = ...
You need to use the QgsProperty() and QgsPropertyCollection() classes to set the data defined properties. The enum property value 58 is for the background colour (see here for a list of data definable properties):
layer = iface.activeLayer()
background_color = QgsTextBackgroundSettings()
# Set up the data-defined ...
The pixelation is replicable - it is caused when there is a non-zero rotation applied to the SVG label background, or to the label as a whole via Placement. However, on export to PDF the background symbol is sharp.
The resizing behaviour is not replicable. I made a new label from scratch using the same settings and SVG, and it works as ...
I'm not sure what's going wrong with your SVG symbol, but it's pretty simple to re-create a similar symbol using simple marker symbol levels. With simple markers, you can control the symbol size and stroke width using millimeters, points, pixels, meters at scale, map units, or inches.
Add three symbol levels:
Simple marker - line, 45 degree rotation. Shown ...
Frame Challenge: This is not a good method for what you're trying to achieve. Labels are always rendered on top of all the features on the map. So you'll never be able cover up the labels with a polygon.
Instead, try replacing the labels with a font marker symbol. When you put a polygon on top of a point, all parts of the point symbol that fall underneath ...
You may want to create a qml stlye file.
After you have set appropriate label style in the layer properties dialogue window:
Click on [Style] button and open a small context menu.
Select Save Style... which opens a new Save Layer Style window.
Make sure Labels option is ticked.
Save the style as a QML style file.
Next time when you need the style back, ...
You can use the full XPath as context if they have a different one for each element. For example
<element name="gmd:codeSpace" context="/gmd:MD_Metadata/gmd:referenceSystemInfo/gmd:MD_ReferenceSystem/gmd:referenceSystemIdentifier/gmd:RS_Identifier/gmd:codeSpace">