Site menu:

Cyclocross For Roadies: How and Why to Get Started - Buy Now!

Site search

Categories

QGIS Can Now Delete Columns In Shapefiles!

How many times have you opened a shapefile in QGIS, and found yourself wanting to be able to modify its schema? If you’re like me, it happens on a very regular basis! One of my major frustrations with QGIS is that I couldn’t do this without creating another copy of the shapefile. This seemed rather unnecessary, and added to my already large data management challenge! This limitation was one of the (now very few) reasons I had to bump over to Kosmo GIS in my normal workflow.

I’m happy to say that the 0.3.9 version of QGIS’ “Table Manager” Plugin by Borys Jurgiel now allows you to change a shapefile schema without having to save the output to a new file!

You can install the plugin via the Plugin Installer – look for “Table Manager.” Once it’s installed, find it under “Plugins > Table > Table Manager.” It’ll operate on the feature you have selected in the legend, and open up a simple window that looks like this:

Table Manager

Table Manager

You can then reorder columns, rename columns, insert columns, clone (copy) columns, change data types, and delete columns! To be fair, you could do all of this before. The difference is that now you can just hit “Save” down at the bottom, and carry on! Before, you would have to “Save As,” browse to a folder, and create a whole new file. Then add this new file to your map, theme it appropriately, and remove the old layer. Annoying. Now, it’s a super simple one-step process!

A nice touch is that the old .dbf file is archived in case of a mishap. The archive is stored alongside the rest of the shapefile, but has the extension .dbf~

Thanks Borys!

Now, if only this was built in to the “Properties > Fields” tab! ;)

Tour de Brew – Part VI

This entry is part 6 of 6 in the series Tour de Brew

The long awaited Tour de Brew – Part VI is finally here! It’s the wrap-up edition, and I’ll try to keep it short and sweet!

Monday morning was warm again, but not super hot, with a misty rain that left the roads wet. Matt and I were up for one final ride before leaving, so we kitted up and rolled out the gravel road from the cabin back to the pavement. We then went down to Jeffersonville, so we could say we officially started the ride at the bottom of the climb :)

We repeated the climb up Smuggler’s Notch that we did the first day. Despite the miles and elevation gain I’d put in my legs the last few days, I was feeling quite good, and was no longer intimidated by the mountains. We had a solid ride up, and reveled in the scenery and pain. Outstanding! At the top, I debated continuing down the other side, but the wet roads and lack of confidence on the tight switchback made me unsure. Matt decided he didn’t want to do another climb, and since I was on the fence, decided not to descend alone. We turned around and started to fly down. However, near the start of the descent, Matt pulled over, so naturally I followed suit to see what was up. He had a ‘knocking’ sound on every rotation of his rear wheel, and it was a bit disconcerting, especially at those speeds! We looked it over, but couldn’t see anything obviously wrong, so decided to continue! Closer to the bottom of the descent, Matt had a bit of a scare as some idiot driver turned left in front of him as he was descending at 80+km/hr. He had to slow, but not too much, and luckily stayed in control. What inspired the driver to turn when he could have waited a few more seconds and had the entire road is beyond me. Sometimes, drivers need to realize how easily they can kill cyclists! I was far enough behind the action to get a good view, but didn’t have to slow.

We rode back to the cabin, but then decided to check out the rest of the resort and cabins that we hadn’t seen yet. Of the roads at the resort are all gravel… and you know what that means! The final little descent, just several hundred meters from our own cabin, I got a flat. And since I decided not to bother changing it just then (we were heading home after all…) I shouldered the bike to walk it in the last few hundred meters. Of course somewhere in that time I managed to step in dog shit, which packed into my cleat and vent holes in the bottom of my shoe sole. Nice! What a way to end the trip! (I will use the ‘never a dull moment’ excuse to make that one into a positive!)

Overall, Monday’s ride was short, but great! 32.54 km in 1:18:31. We climbed 673m, at an average speed of 18.26km/hr on an average gradient of 5%, with a max of 11%. After the ride, we cleaned up, packed up, and headed back to Perth. It was a fairly uneventful trip back, and we were all exhausted!

Over the course of the entire trip, we managed to get in 245.44km of riding over 9.5hours. Total climbing was 3875m! For all of us, the trip contained the biggest, steepest, and longest climbs we’d ever done. A great learning experience and a whole lot of fun! Personally, it was the best riding experience I’ve ever had, and I’m fairly certain the other guys would agree! Naturally, plans are already being discussed for TdB 2012!

New “Control Rendering Order” Option in QGIS

I just downloaded the latest QGIS development build (1.9.90-9) and immediately noticed a significant change to the look of the layer legend pane. It now looks like this:

Control Rendering Order

Control Rendering Order

You’ll see that it is split into two panes, with one called “Layers” and one called “Layer order.”  Each now has a checkbox to “Control rendering order”

Essentially, the new functionality allows you to decouple the way layers are organized in the legend (“Layers” pane) from the order they are rendered (drawn) on the canvas (controlled via the “Layer order” pane.) This is really nice if you have complex maps with many layers and groups in the legend!

It still seems a bit buggy, but considering it just came out in last night’s nightly build, I’m not surprised! I’m looking forward to seeing this mature!

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!

Installation:

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

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:

EasyPrint Icon

EasyPrint Icon

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!

Functionality:

EasyPrint has several functions. When you click the icon, you’ll get a three-tabbed interface that looks like this:

EasyPrint GUI

EasyPrint GUI

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”)

Page 1

Page 1

Page 2

Page 2

Page 3

Page 3

Page 4

Page 4

Page 5

Page 5

 

Page 6

Page 6

Page 7

Page 7

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!

Page 1

Page 1

Page 2

Page 2

Page 3

Page 3

Page 4

Page 4

Layouts:

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!)

Conclusion:

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!

Tour de Brew – Part V

This entry is part 5 of 6 in the series Tour de Brew

While waiting for our Thai takeout in Burlington box mall hell on Saturday night, we took a visit to a book shop. In the book shop, we found a copy of the book Backroad Bicycling In Vermont which we flipped through. Despite some very odd advice (never make a left turn???) the book contained some interesting route ideas. One of them started in Jeffersonville, and went North, missing most of the big hills. This looked ideal for an ‘easy’ day on Sunday, so we noted the route and planned on riding it the next day.

Sunday morning, we took the quick drive from the cabin down to a car pool parking lot on the 104 near Cambridge. It was hot again, so we slathered on the sunscreen and loaded up with water. The ride started off with some excitement–very shortly after we left, we came across a ‘playful’ pitbull puppy. The owners were in their front yard raking or something, and the dog was off-leash. He immediately came after us–just a puppy, but still a pit bull! He wasn’t sure what to make of cyclists, so we were very cautious. He kept coming, baring teeth and heading for the heels as we pedaled. At one point, I even came to a stop and put my hand out to calm him down, but he only growled and backed off a bit, unsure. The owners, naturally, were not very smart, yelling “Scooter, come back” and “Don’t worry, he won’t hurt you”  Of course, they weren’t being  chased by a pit bull with bared teeth, so…

We eventually got by the dog without injury and got our nerves settled. This happened just in time for a vicious (short but steep) climb. It gained 127m in 3.62km, for an average grade of 7% and a max of 12%. The downhill was nasty–twisty and turny, with some sections where road construction had left loose gravel on the road. To add to the excitement, Luke got stung by a bee on the descent, and casually mentioned that his sister has major allergic reactions, and that he “wasn’t sure” if he did or not (luckily he didn’t!) Also, the wind had started to pick up–the forecasted thunderstorm appeared to be on its way! Since the sky was looking very dark and the wind was very strong, we made a call to take cover–you never know what can happen in that kind of weather! The forecast had even called for inch-and-a-half hail, and flash flooding, so we didn’t want to take a chance. Luckily, there was a farm close by, so we went there. After knocking on the door and getting no answer, we decided to just wait out the storm in front of the garage. The wind really picked up, and the rain started. It was wild!  The owners of the farm drove up part-way through our stay, and looked at us quizzically.  However, after explaining the situation, they gave us the OK to wait out the storm in the garage. Luckily the hail never did come, and the storm blew by almost as quickly as it formed. We were back on the road again!

The route took us to Fairfield, where we stopped for a chat. It was decided that Luke, Shawn and Trent would take the road through Fairfield and across to the 108, while Matt and I would go further north, turning at Sheldon and cutting across to the 108 there. We split, planning to meet up at the cars at the end of the ride.  Matt and I absolutely flew to Sheldon–the road was almost all downhill, and there was no traffic to speak of. Amazing! Matt and I stopped at a general store in Sheldon and filled up on Gatorade. It was pretty damn hot and humid!

Typical Scenery North of Jeffersonville

Typical Scenery North of Jeffersonville

The road across to the 108 was also very low traffic and nice–until it turned to gravel! We had not expected the gravel, and weren’t sure how long it would last. It was a bit rough, with some loose sections that were not ideal for skinny tires. We made it through, with some ‘back woods’ moments as we went by some trailers with cars up on blocks out front. Quite the place to be out in spandex and ‘ballet shoes!’ Once we hit the 108, we were back on pavement, and expecting a steady climb all the way back to the car (since the ride so far had been largely downhill.) Oddly enough, this was not the case, and the 108 had very few significant climbs. Unfortunately, however, the surface was not ideal–rough, with cracks and holes everywhere!

As Matt and I rode by a gas station, we noticed bikes leaning up against the wall–it was the guys! We quickly pulled in to the store. Turns out their route also had gravel (more than ours even) and Shawn had split a sidewall on a sharp piece. It took them some time to fix, and he was taking it easy since it was booted. Not nice! We went in the store for some water and a washroom key, and it turned out to be the coldest store in the universe. The air conditioning was cranked so cold that I could barely stand it long enough to get the key and get out! FREEZING!

We rode the rest of the way back as a group, and the road surface got worse as we went. I’ve never seen cracks like it in Ontario or even in Quebec–it was much worse than any road I’ve ridden, to the point of being very unsafe. Fortunately, we made it back without further incident! We ended up the day with a total of 82.2km in 3:02:44 (for an average of 26.91km/hr) and a gain of 942m.

Post ride, we went back to our favourite Vermont Liquor Depot in Jeffersonville to fill up on beer for the evening. While there, we asked a local their recommendation for pizza, and the pointed us the way to a local Jeffersonville shop, so Trent and Shawn went to put in an order. Beer and pizza in hand, we went back to the cabin to chill and eat. Then things got crazy–the second round of thunderstorms rolled in, and the mountains literally disappeared before our eyes as we watched the sheets of rain moving across the valley towards us. Storms in the mountains are intense!

Beer & Pizza

Beer & Pizza

Again, the storm passed pretty quickly and we resumed our beer and pizza. Luke was leaving to head back to Perth, so we said our goodbyes as he packed up. Then, just as Luke was leaving, the third round of storms rolled in. We hoped it would make it down the partly washed-out road from the cabin with no problems!  The porch sitting/pizza eating quickly turned into a scramble for shelter as the rain started hammering down again and the wind threatened to blow all of our hanging clothes away. Then, the power went out! This storm too passed quickly, but the power remained out save for a short blink to give us hope.

Beers for the day included one that turned out to be either my favourite or second favourite of the entire trip – Long Trail Double Bag. There was also a couple of the Trout River Chocolate Oatmeal Stout quaffed, and very much enjoyed. Shawn had the Shock Top Raspberry Wheat which turned out to be one of his favourites of the trip.

The night’s entertainment included a surprise award ceremony that Trent had created–modeled after the jerseys of the Tour de France. However, rather than jerseys, the awards were these guys:

The 2011 Tour de Brew Awards!

The 2011 Tour de Brew Awards!

For the first time in history, the ‘yellow jersey’ was awarded to two people–both Matt and Shawn shared the honours. I took home the polka dots, Luke the Best Young Rider, and Trent the Green. I’m not sure what the little elephant was even for, or who won it…perhaps the guys can refresh my memory?

Part VI will be coming soon and will likely finish off the story of the 2011 Tour de Brew – stay tuned!

 

Bookshelf 2.0 developed by revood.com