3

I have a layer of deforestation, and I need to create many layouts of each one polygon. I'm using Atlas to do it. See the model below:

enter image description here

Yellow polygon in raster is deforestation map layer and it is driver of atlas. Bottom wright we can see map with overview and when it change the box of map will be changed automatically change depend on where overview be.

The map in right and bottom place of paper, I would like that when change the atlas map, the feature (município) of map keep centralized where the overview is into. See the red overview into polygon and this is the geometry that I need to get in order adjust limits of map.

So, I create one expression to get geometry of feature from name of municipio. The layer that drive atlas (desforastation layer map) has column with name of municipio and as with it that I try to get municipio geometry from municipio map layer.

So, I did the expression in extents box data defined override:

enter image description here

See the expression that work to get feature: enter image description here

I make the expression from deforestation layer, which drive atlas. So, I try to get feature from municipio map layer with column attribute of deforestation map layer (that has the column name of municipio in order to join with municipio map layer). In expression, 'nome' came from municipio map layer and municipio (without '') came from atlas driver layer (deforestation map layer) which has column name of municipio.

But when I continue to get geometry, it doesn't work. It return NULL value as a result. Because of it, it is impossible to calc x_min, and another ones values of map box. enter image description here

The project to download: link to download

8
  • So in the last screenshot: did you try to add x_min (....)? and if so, what does the previes say? In case of error, what explanation does it give?
    – Babel
    Commented Nov 24, 2022 at 21:48
  • Can you share project data for testing? Otherwise, it's difficult to help. Re-building the whole project is quite time consuming
    – Babel
    Commented Nov 24, 2022 at 21:50
  • I edit the question and add the link with qgis project to became easier. Images won't apper. Only the vector. They will be enough to test and try to answer question. Commented Nov 25, 2022 at 15:52
  • I downloaded your project. I'm not sure where you try to apply this expression. I tried to use it in map layout, Item Properties of the overview map at the bottom right, chosse X min > Data driven override. As you see, it returns a result: i.sstatic.net/lqb2P.png
    – Babel
    Commented Nov 25, 2022 at 16:41
  • 1
    My gosh, I don't know why, but now it work. Jesus! Commented Nov 25, 2022 at 17:15

2 Answers 2

2

Answer

Add the function x_min() to your expression, than it should work:

x_min (geometry (get_feature ( ... )))

Explanation

Your problem is due to the context where you called the Expression string builder. As we can see on your screenshot, there is an Expected format: double. This means: here, you can't create a geometry as an output, as the output must be a number of format double.

You probably called the expression string builder in a place like data driven override - e.g. for line width or something similar where only a number makes sense.

enter image description here

2
  • Exactly I've done. But it doesn't work. I tried to creat a formula to put automatic square in location map. Commented Nov 24, 2022 at 15:00
  • Than you have to provide more information. In my case, it works perfectly-
    – Babel
    Commented Nov 24, 2022 at 15:31
1

Try updating your QGIS version. I think this is actually a bug with slightly older versions of the current LTR, I had the same issue in 3.22.11 where the feature would show up in the preview but no geometry (and not even if you wrapped it with x_min() or x()) - regardless of whether you're using a data defined override or field calculator.

However this was not an issue in 3.22.13

1
  • I update my qgis. The result is not what I expect. Maybe the logical is wrong Commented Nov 24, 2022 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.