13

You don't need to consider the page name or number. Since the layer you are trying to dynamically style is the same as the coverage layer, you can use the following expression: $id = @atlas_featureid $id is a function that returns the id of each feature of the current layer. @atlas_featureid is a variable that stores the id of the current atlas feature. ...


12

Problem The <font> tag's size property is only defined for values of 1 through 7. MDN says about the <font> tag: Obsolete This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it. and later: [...] For any new web development, styling ...


12

The QGIS Atlas does not require that each page in the series be spatially distinct. In the map frame's Item Properties, ensure that the option Controlled by Atlas is not checked. It does seem, however, that you have a series of attribute values, as opposed to individual features, that you want an atlas for. This can still be accomplished using an atlas, but ...


8

This is what the Atlas feature in QGIS is designed to do. In the Layout view click the button at the top on the far right called Atlas Settings: Set the Coverage layer to the polygon layer that you want to iterate through, configure the rest of the options there as you see fit, sorting, filtering, etc if needed. Then go to the Map item in the Layout table of ...


8

you have to filter your table with the current atlas feature, for example for a column "fid" it could be: "fid" = attribute( @atlas_feature, 'fid' )


8

I was really interested by myself, if it's possible to use dynamic SVG creation to build these label circles and came up with this solution: Simply add a Geometry Generator with a SVG Marker to your layer symbology: And use the following Expression instead of selecting a SVG symbol: 'data:image/svg+xml;utf8,<svg width="30mm" height="30mm&...


7

This functionality is coming in QGIS 3.16. It's already available in the nightly releases for testing.


7

In QGIS 3.16.0 I did as described in the docs (in my case I applied a graduated rendering of the value "Tabell_Endring_Areal"): Click on the Symbol-button to the change it (I'm using circle) and then on the Data defined override-button and choose Assistant: Choose source (the value (field) you want its symbol to be proportional. This is another ...


7

You must set setUseLayerName() to False to name legend tree layers manually. # # previous lines # for i, layer in enumerate(layersToAdd): tree_layer = root.addLayer(layer) tree_layer.setUseLayerName(False) tree_layer.setName(names[i]) legend.updateLegend() ...


6

Hashed fillings for simple polygon symbologies tend to behave undesirable when exporting images. This is - at least I think - due to the fact that they are based on dots per inch. Anyway, there is a workaround. Have a look at the following (German) screenshot: First, use the green plus at the top right of your layers symbology dialogue (first red box) to ...


6

Here is short snippet of code to directly remove a layer node from a layout legend by getting a reference to the QgsMapLayer object by name: # You already have a reference to the project and layout objects map_layer_to_remove = project.mapLayersByName('Name_of_layer_to_exclude_from_layout_legend')[0] legend = [i for i in layout.items() if isinstance(i, ...


6

It seems you are using WGS84 geographic coordinate reference system (CRS) or any other CRS that uses degrees as a unit of measurement. Therefore, adding a scale bar has no meaning in your layout, as you already discovered when you added one to your map. The scale bar is useful with projected CRS, such as UTM that uses meter as a unit of measurement.


6

You can use geometry generator to have full controll of all settings. First make a circle with make_circle(centroid($geometry), "population_total") , replacing "population_total" with whatever attribute or value you like - you probably have to multiply or divide it by a coefficient to adapt the circles to a suitable size. In the second ...


6

You can use the following structure: # # previous lines # page_label = QgsLayoutItemLabel(layout) # # other label settings here # text = "[% 'Page: ' + to_string(@atlas_featurenumber ) + '/' + to_string(@atlas_totalfeatures)%]" page_label.setText(text) layout.addLayoutItem(page_label) myAtlas.beginRender() for page in range(myAtlas.count()): ...


5

In QGIS 3.14, we can customize the number format of the scale bar, including the thousand and the decimal separator:


5

You can rename layouts by going to Layout > Rename Layout in the layout window. But as a workaround to automate adding the date/time to your map filename... Try using a single feature as an atlas to take advantage of the ability to use expressions for atlas file names. Add to your project a layer with a single feature. It can be any geometry, anywhere, ...


5

I would create an atlas with a geom for each species (all geoms should be the same, a just a point in the same place or a boundary that defines the extent) and each geom should have an attribute with the species name. Set the atlas page name to be the atlas layer attribute. You can then use @atlas_pagename as the title and filename of the export of each page ...


5

A solution using PyQGIS would be like this: project = QgsProject.instance() manager = project.layoutManager() layout = manager.layoutByName("LAYOUT") # change layout name legend = layout.itemById("LEGEND") # change legend name overview = layout.itemById("OVERVIEW") # change overview name interval = 5 # set interval def ...


5

You can solve it quite simple: Just add a double quotation " to fields having a whitespace in its title: Plot Order --> "Plot Order". Then it recognizes the field correctly and sorts your attribute table correctly.


5

Obviously, you can not use a field in print composer legend. Only @symbol_id, @symbol_count and @symbol_label will work. And of course all normal expressions, we will come to them at the end of this answer. So the easiest solution seems to be to leave your print composer and go back to your main QGIS canvas. Open the layer properties, go to symbology and ...


4

The updated recipe for QGIS 3.x from qgis.core import QgsLayoutItemLegend, QgsLegendRenderer, QgsLegendStyle, QgsProject project = QgsProject.instance() manager = project.layoutManager() layout = manager.layoutByName('print1') # Your layout name # If only one legend within the layout layoutItemLegend = [i for i in layout.items() if isinstance(i, ...


4

As of QGIS 3.12, you can conditionally format row background and text colour in the attribute table in Layouts by setting the formatting in the Attribute Table for the layer in the main window. So if you set up conditional formatting in the Attribute Table to "field" = 'value' this will be reflected in the attribute table in the map layout if you check '...


4

The symbol layer that wasn't rendering had the fill style set to "diagonal X." Changing this setting to "solid" resolved the issue.


4

Update: there's now a better solution to this, see here: QGIS expression to access page-number of atlas for certain features Just an idea for a partial workaround so that you don't have to do everything manually: insert on your atlas sheet an attribute table and list there the names of the towns (no. 1 in the screenshot below).In the feature properties of ...


4

You can count the number of nodes in your legend using PyQGIS like below (standalone use) project = QgsProject.instance() manager = project.layoutManager() layout = manager.layoutByName('myLayout') # We consider only one legend itemLegend = [item for item in layout.items() if isinstance(item, QgsLayoutItemLegend)][0] # It's a tree, we should follow it ...


4

if you have the Auto update off - you should be able to right click on the legend title and hide it - but the name of the layer will be missing: and as etrimaille suggests - add layer to a group - and put the name of the layer as the group name:


4

You need to select the items from the layout itself and then go to the main menu -> Item -> Group, and it will group the items selected. The following animation will make it clear on how to group items:


4

You can calculate the height of the rectangle using the following expression: bounds_height( $geometry) This will calculate the maximum height of the bounding box of your geometry


4

With the documentation of QgsLayoutItemMap, you'll find the setScale method. setScale(self, scale: float, forceUpdate: bool = True) Sets new map `scale` and changes only the map extent. The `scale` value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. So, in your code, try: # [...] map.setExtent(mem_layer.extent()) map.setScale(8500000) # [....


4

Select the north arrow, and go to the Item properties tab. In this tab, there is a section with a name Search Directories, expand this tab and wait until the preview loads all the symbols. From there you can change the north arrow as you like. Update I recommend to update your question based on the information in your comments. If you want to change the ...


Only top voted, non community-wiki answers of a minimum length are eligible