1

Is it possible to set the extent of each page in a QGIS atlas to the bounding box extent of the visible features in a second (non-coverage) layer?

In my case, the SCHOOLS layer is the coverage layer, which I believe the variable @atlas_geometry is pointing to.

I have a second layer of STUDENTS of which the visibility of the features is driven by the attribute / sort ID of the coverage feature - which works just fine.

I'd like to be able to set the page extents (xmin, ymin, etc.) using the bounding box of those visible STUDENTS, so as to use a dynamic scale in order to see all the students who attend the SCHOOL / current atlas feature.

But as far as I can see, there is no variable to control the features visible on the map.

3
  • 2
    Could you not just create a bounding box or convex hull around the students who attend each school, and use that layer as your coverage layer instead of your schools layer (I'm assuming that this is a point layer)? It won't centre each atlas page on the school though - is that a requirement?
    – Steven Kay
    Commented Sep 13, 2016 at 21:29
  • @StevenKay not necessarily a requirement... but that is a good idea if all else fails... stay tuned, as that might turn into the answer...! Thanks! Commented Sep 13, 2016 at 21:54
  • @StevenKay might as well put that in as an answer... I'm going to use it for the next set of atlas maps we'll be making... I'll update your answer with my method from PostGIS if that's ok... Commented Sep 29, 2016 at 14:32

1 Answer 1

2

I ended up using the advice from @StevenKay to create bounding boxes around the extent of - in my case - all the students that attend a particular school.

Using PostGIS, the query is similar to this:

create table public.temp_oct_bbox as (
select 
ST_Envelope(ST_Collect(oct.geom)) as geom
, oct.schnum
, sch.abbreviation

from dpsdata."OctoberCount_Archive" as oct

join dpsdata."Schools_Current" as sch on oct.schnum = sch.schnum

where oct.ressch != '0' --only draw a box around students living in-district
and oct.year = '2016' - specify the year of students i'm interested in

group by oct.schnum, sch.abbreviation
)

This creates a set polygons around the set of students from each school which can be used as the coverage layer (hidden) in QGIS:

enter image description here

By including the School Name (abbreviation) and School Num (schnum) I can display them on the atlas pages:

****cartography NOT complete****

enter image description here

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.