The problem
I want to create a vector layer in QGIS 3.26 with a varying number of features. The number of features should be the same as the number of raster layers open in the project. So if I have 12 raster layers, I want a point layer with 12 features; if 30 rasters are open in the project, I want to get a layer with 30 points and so on.
Hint (see at the bottom): I need this as coverage layer for an atlas that outputs each raster layer separately.
What I tried
I created a point layer called
count_layer
with one feature and a virtual field namedno_of_rasters
with an expression based on the variable@layers
that returns the number of raster layers opened in the project.The idea now is to create a virtual layer with the query
select make_point (47,15)
.
The question
Up to this point, everything works. I am now stuck as to how to create not one point at coordinates (47,15)
, but several points - the number of points should correspond to the number created above in step 1: the value in the field no_of_rasters
.
How to do that?
Context (not necessary to understand the question)
Just to make clear why I want to do that: I want to use the virtual layer as coverage layer for an atlas. I want to output each raster separately, so in the virtual layer, I want to create a virtual field containing for each feature one of the names of the raster layers (using @layers
and selecting from the resulting array one element corresponding to @row_number
).
This field (name of raster layer) can than be used in the atlas in the Lock layers
setting to just output one raster layer per feature of the coverage layer so that in the end, I have an output with each raster layer separately printed.