More

Autofill format with atlas

Autofill format with atlas


I am trying to create an autofill format on QGIS, based on an atlas.

There will be some dynamic text fields and some boxes which should be checked with an "x" in case the atlas geometry intersects a group of other geometries. Something like "IF $atlasgeometry intersects layer X OR Y OR… OR Z, THEN check the box". Those layers are grouped, so it would be nice if i could call them all together in the script. The point is that i cannot find a single tutorial explaining how i should call map layers within the formulas, all the examples i see are about single geometries, and i have hundreds of them, so that would not work.

Could anyone explain me how that should work? And how the formula stucture should be?


Let me try to explain:

  1. We have a map layer on which there are some objects stored: they describe the geographic positions of some buildings. Each geometry is a building. Let's call the layer "Projects"
  2. We have some other layers containing the perimeters (=polygons) of the areas where some kind of jobs cannot be done or must have some features. Let's call them "Restraints A" "Restraints B"…
  3. I need a script which says "IF "projects" intersects Restraints A, then write X in a certain text box.

The goal is creating a format which describes in a single sheet all the restraints i must respect in the definition of the project.


Got it!

But first you must prepare the data a little cause you cant expect efficiency if you try to check upon every feature of every restraints layer for each target project.

So here are the steps:

  1. Dissolve all geometry of your restraint layer so the test is simplified because there will be only on unique feature to test for each restraint

  2. Merge all restraint layer into a new one lets call it "restraint_union" AND make sure it contain a new column name "col_restraint" which will store the name of the original restraint that generated each feature "restraint1","restraint2",…

  3. Add project layer and "restraint_union" to your QGis project

  4. Add as much virtual fields as you need in the project layer following using this expressionintersects( $geometry , geometry( get_feature( 'restraint_union', 'col_restraint', 'restraint1')))

    This will return a boolean 1 if the project intersect restraint1 and 0 if not Do that for all restraints. Lest call it "restraint1_test".

  5. Now you project layer contain all information information needed about whether it intersect each constraint. Make your atlas using this layer and use as many additional expression as needed to render the information. Example :

    attribute( $atlasfeature, 'restraint1_test' )


PS: Step 2 is optional but it can help you have a cleaner project. Alternatively you could also keep all dissolved restraint layer separate.