How to calculate statistics from the visible part of a map layout and dynamically update it in single map layouts or atlases. Using QGIS 3.10 from qgis.org
Thank you very much Klaus, your videos are really clear and enlighting! I'm having trouble with something and I wanted to know if I could as for your help. The first thing is that I want to make summary statistics based on layers different from the one I'm using as a filter variable in my Atlas (or my Report). For instance, I want the Atlas to cycle through all the States within a country, and to count the number of schools within each district (with schools being a point shapefile different from the State polygon shapefile). My first attempt looks a bit like this: format_number(aggregate( 'Schools_in_South_Sudan_031520fd_7038_4377_8c53_6d07c3c27dad', 'count', 'name', // This is the unique identifier for each school within the 'Schools in South Sudan' point shapefile. "ADM1_EN" = @atlas_pagename // "ADM1_EN" is the name of each State in South Sudan, this being also the variable used on the Atlas. ), 0) I know this doesn't work because the expression is looking for the variable "ADM1_EN" within the 'Schools in South Sudan' shapefile, which is not there. My guess is that it might have something to do with the refFunctions plugin, particularly with the geomwithin('targetLayer','targetField'), but I wouldn't know how to code it. Perhaps there's another way around it. My second issue, closely related, is that I don't know if an equivalent for Reports exists for @atlas_pagename. How could I go around doing this same thing with reports? I want to work mostly with Reports, since I find them much more powerful, but they're a bit more tricky. Do you have any tips or reference material with examples that I could use to orient myself in how to use Dynamically updated expressions within QGIS reports? Forever grateful!
Good afternoon, Congratulations and thank you for the excellent work! I really liked this video. I would like to suggest / request some video along the same lines, but with dynamic symbology on the canvas. It could be a dynamic heat map (kernel). Thank you! Hug!
Excellent tutorial, it has helped me a lot. But I have run into a problem this time. I'm creating an atlas and calculating certain land cover areas within an atlas item. But since some atlas items are quite close by, the function calculates areas of both items. How can I limit the calculation to a single atlas cover layer item, per atlas page? Thanks if someone can suggest a solution.
Thank you very much for your video! How do you calculate the area of your base map in a static QGIS map layout? (i.e., the area of the layout map). Thanks!
You need to create a geometry generator to place the labels. You combine the layers in the generator with the "aggregate" function. Not really easy, but possible.
Hi, great tutorial! But I run into a problem. Apparently 'map_extent' doesn't work for me. I can calculate the sum for the entire shapefile but the intersects filter option doesn't work. If I use map_scale for map_get as a key I get a value but 'map_extent' does not give out anything. Is there a way to work around? Another thing I noticed is with the attribute table at the end of your video. I used basically the same data but when I sort the lakes in descending order based on the area, the largest lakes sometimes won't be listed. If you zoom in and there is only one large lake and some minor ones everything is alright but as soon as I zoom out the larger lakes won't show up in the table.
If you get a value when using 'map_scale' the function should work also with 'map_extent'. Try only: map_get( item_variables( 'your_map_name'),'map_extent') in an expression builder. It should return a in the preview area in the dialogue. If you use 'map_scale' you will get the scale at the same preview location.
If you please point me in the right direction: Imagine one wants to create an Atlas with a given fixed scale (1:5000 for example), so that for each page Qgis picks & auto changes to the correct paper size to exactly fit the map Atlas index layer in the space. What expressions could one use to achieve this?
If you want to FIX the scale of a map, you have to go to map/item properties/scale then EDIT it, you can input your self or pick the number from an attribute table.
Please help me..I am from Iraq and I want to draw a map of Iraq in the Qgis program, and the latitude and longitude coordinates were not real, how can they be set to become the same as the coordinates of Iraq?