2

I am using QGIS 2.14.2 and I have a map divided into different regions. Each piece have a number assigned (eg. 27). I have a page configured for printing the region (territory) along with 4 pieces of attribute tables filtered by a field related to the number (eg. 27) corresponding to the map to display information related to the area (eg. a territory street list with the 'territory' field equal to 27).

How to set up the easy way to print the other territories; for example, print the territory number 26, the 25, the 15, or another one? ...

... And allow the table data (eg. a street list of the territory) also present the information related to that territory?

I need to configure one by one or there is a better way?

enter image description here

3

In the map composer you can use the atlas settings. You can use your territories layer as the 'coverage layer', found under the "Atlas Generation" tab. Here you can also apply a filter to identify which territories you only want to show. It's probably best to also 'Sort by' the territory ID to keep the atlas in order.

Under the "Item Properties" tab, check 'Controlled by atlas' and you can apply a % margin which will change the scale to each individual map so all map sit nicely on the page, or apply a set scale if you want.

As for the tables changing with each map, insert an 'attribute table' to your map composition. Under the 'Item Properties' > 'Feature filtering' check "Filter with" and add the expression:

"ID" = @atlas_featurenumber

Where ID would relate to the territory ID in your street data you want to show in the attribute table, and 'atlas_featurenumber relates to the territory ID that was setup under the 'Atlas generation' tab. (this is a similar concept to a table join between street data and territory data)

EDIT:

For this answer to work (specifically for you Carlos)., your data really needs to be set up in a way similar to below:

Territories Layer

| Territory_ID | Territory_Name |
|       1      |       A        |
|       2      |       B        |   etc...

Streets Table

|   ID   | Territory_ID | Street Name | Boundary Street |
|   1    |      1       |   Street A  |                 |
|   2    |      1       |   Street B  |                 |
|   3    |      2       |   Road C    |                 |
|   4    |      2       |   Road D    |                 |
|   5    |      2       |   Street A  |        Yes      |   etc...

As you can see in the table, Territory A will have two streets associated with it and Territory B will have 3 streets associated with. It it will also identify a street that is linked with Territory A. I've included a Boundary Street column so that you can more easily identify those streets that are shared between territories. This table can be created using the Select By Location tool and then manually writing down the selected roads for each territory. This process could be much faster with python.

  • And how to show rows that have the number in the field with others numbers? If the field have, for instance 09, 10, 11? "id" like %@atlas_featurenumber%" don´t work!! – Carlos Pires Jan 5 '18 at 11:33
  • If you have several ID's in a single field then I'm your table has a fundamental flaw and should normalised like any database data. The only I can think of without seeing your data is to either start over, where each row is its own unique record. Or create a new ID column that then identifies all associated data to it. – Knightshound Jan 8 '18 at 8:17
  • I understand that, and I am considering that way. But is rather dificult to figure how to mount that info. The only way I see of doing this is to manually make a table that indicates the streets that belong to each territory. I have 98 territories, and each one has several streets. If a street can be shared by more than one territory, on one side or the other, or in the middle, it makes the task quite complicated. I'm thinking this can be done with SQL. But I had to pass the data to a different format, right? – Carlos Pires Jan 8 '18 at 12:24
  • 1
    I'm not sure if it would be faster in SQL sorry. But if your data overlaps in the way you say, then this method may not be the best solution. You may be better off having just the layer of the territories and a separate csv table of the street with a related column to the territory ID. That way you can still create an atlas of the territories, but the attribute table linked from the street table. It wouldn't take you too long to create using Select By Location (couple hours maybe), and faster still if you can do it in python. – Knightshound Jan 9 '18 at 7:52
  • 1
    Please the edit in my answer. You are essentially going to have to create a completely new table if I understand your data. – Knightshound Jan 10 '18 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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