Map Books in QGIS
Have you ever wanted to automate the creation of a mapbook? Well, QGIS
has a great plugin called EasyPrint that does just that! It makes the process simple and quick once you know how it works. I’ll try to explain exactly that below!
EasyPrint is written by Stefan Ziegler, who we all owe a big thanks! You can install the plugin from the “Fetch Python Plugins” menu. If you don’t see it there, you may need to add the CatAIS Repository. To do so, go to “Plugins > Fetch Python Plugins” and click the “Repositories” tab. At the bottom, click “Add 3rd party repositories,” then “OK.” Then switch back to the “Plugins” tab, and type”EasyPrint” in the search. You should have one result, which you should select before clicking “Install plugin.”
EasyPrint in the Plugin Installer
Once the plugin is installed, you can enable it under the “Plugins > Manage Plugins” menu if it is not already enabled. If the install was successful, you can access “EasyPrint” in your plugins menu, or via the toolbar icon that looks like this:
If you already have the plugin installed, you may want to see if there’s an updated version–the new version seems to increase stability quite a bit!
EasyPrint has several functions. When you click the icon, you’ll get a three-tabbed interface that looks like this:
The first tab, “SimpleMap” allows you to create a one-page map, very similar to the standard QGIS Composer window. It uses layouts that come with EasyPrint or one that you can customize (more about that later.) In fact, this option even opens the EasyPrint layout in the composer window. To me, this tab seems unneccessary, because this process is more difficult than using the standard composer. Thus, I don’t see a real need for the SimpleMap option at all, except that it lets you quickly turn on or off things like the grid, copyright, etc. via checkbox rather than adding or removing them from a layout. However, it’s important to note that the next two tabs will use some of the settings from this first tab, so make sure you note them and set them appropriately.
Where EasyPrint really shines is in the ability to automate the creation of multi-page map books, rather than just simple maps. The second tab, “Mapbook by grid” allows you to print one page per ’tile’ based on a grid it will create. Make sure to set the scale you want your maps to be created at by choosing it on the first tab. EasyPrint will use the extent of the layer you choose under “Map layer” when creating the grid. I found this a bit confusing, and it took me a while to figure it out. You can also tell EasyPrint if you want to print all grid tiles (Regular Grid,) or only tiles that actually contain features on your chosen map layer (Regular Grid w/o empty grids option). If you select the ‘w/o empty grid’ option, EasyPrint will check if there is a feature present in “Map Layer” you have selected, and if so, create a page for that map tile. If not, it will skip it and move to the next tile. Once you’ve set these options appropriately, hit “Create.” You’ll see a new layer called “Mapbook Grid” appear in the layer legend as EasyPrint creates the grid. Note that this is where EasyPrint often crashes for me, throwing a fun Python Error. Save your work before hitting ‘Create’ and just try try it again. It almost always works the second time! Once the grid is created, it’s as simple as selecting any of the optional parameters, and telling EasyPrint where to export your file(s). Then hit “OK” and wait for your .pdf(s) to be created!
Here’s a quick example of a mapbook created using the “Regular Grid” function. Note that tile 2.1 is empty, and would have been skipped if I had selected “Regular Grid w/o empty grid”)
The third tab, “Mapbook by feature” is the one that drew me to the tool in the first place. It works similarly to the “Mapbook by Grid” tab, but rather than creating tiles at a fixed scale in a grid pattern, it creates a sheet for each individual feature in a layer. The scale will vary based on the size of the feature, and you can set the amount of ‘buffer’ space around each feature to give some context to each map. You can also choose attributes from the table to use as titles and subtitles, and these will change on every page. Sweet!
Here’s an example of the same dataset shown above, but using the “Mapbook by feature” tab this time. Note that it only creates a page for each of the three features, and the scale varies depending on the feature size. Also note the titles, which change on each page based on data in the attribute table. In my case, they are the very useful (“One,” “Two,” and “Three”) Pretty slick!
By default, EasyPrint comes with three layouts. Unfortunately, they are not very useful for anyone except the person who created them! Thus, you’ll very likely want to create and use your own. Because this post is getting long, and because I’m still playing with the layout customization, I will leave that topic for a new post! It’s (unfortunately) not a super user friendly process, so I’ll try to break it down in the next post. Stay tuned! (If you want to get started earlier than that, take a poke at layouts.xml in your \user\.qgis\python\plugins\easyprint\layouts\ folder!)
This is a fantastic plugin! Despite crashing occasionally (save your Project often!) it does a great job when it works.
My wish list for this one is pretty short right now. Basically, I’d love to see this map book creation functionality built into the core Composer window in QGIS, or at the very least have the EasyPrint plugin extended to include support for templates created via the composer. Some modifications to ‘intuitiveness’ (like not using settings from the first tab on subsequent tabs) would be nice, but not critical. It all works once you get the hang of it!
November 22nd, 2011 under GIS