Friday, 2 November 2018

print composer - Printing map portions one by one in QGIS?


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



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...