Care and Feeding of Polygons
We look at different editing tools for working with vector polygons in this post.
Digitising (creating and editing vector features) is a key GIS skill. Most find that it’s also one that can be more than a bit frustrating.
Yes, we’ve all been there…
At the risk of damage to your machine (and psyche), we’ll look at a couple of the editing options for some polygon data in this post. Specifically, we’ll look at the following editing tools:
- Create Features > Polygon
- Edit Vertices
- Autocomplete Polygon
In a previous post, we looked at creating a catchment boundary at Mt Grand and we saw how to create a line feature (and wasn’t that fun…). The three catchments of interest are Lagoon Creek, an unnamed tributary to the south, and further north, Cameron Gully.
That was the precursor to the main event of creating a land cover layer based on some drone imagery. We’ve been trying some image classification approaches which are taking a bit longer than hoped, so in the interests of time, we opted to create our own layer based on visual interpretation of the imagery, balanced by some on-the-ground knowledge. The best land cover data we had going into this was, of course, the Landcover Database (v5). As you can see in the image below, the resolution is pretty coarse, being mapped at a scale of 1:50,000.
We aimed to do something a bit better, along the lines of 1:5,000. How did we decide on this scale? Well, it meant a lot of back and forth and thinking about what’s the smallest feature that needs to be mapped for the research. Are we wanting individual plants? Or collections of plants? Or rough groupings of plants? What it gets down to is what level of detail is needed in the output? This is a critical question as it sets the scope for digitising and 1:5,000 seemed to fit all the criteria. With that set, we also needed to think about how we could keep it consistent across the catchments of interest.
For this post, I’ll focus on Cameron Creek as it’s the simplest of the three. Now I’m no expert on land cover at Mt Grand. Heck, I’ve never even been there! What do I know? For this to work, I needed input from those closest to the source: Shaym Provost, PhD candidate, and Tom Maxwell, el supremo of grassland management. As a first cut, I asked Shyam and Tom to draw what they were thinking on a printed out image:
The accompanying legend told me that orange = Riparian, green = Mixed scrub, purple = Kanuka and everything else is Mixed Pasture. (NB: there ended up being more classes than these, as we’ll see later.)
This gave me a starting point. I could look at the areas marked out on the printed image and match them against what I can see on the image itself and get a better sense of what the different land covers look like. Where to start then? The aim here is to end up with a polygon layer showing the different land covers. I started by creating a new polygon feature class in the project geodatabase, using New Zealand Transverse Mercator as the layer’s coordinate system. This gives me an empty canvas to work with. I want to come up with a bit of a plan so I’ll start with looking at the whole catchment and decide where to start:
I’m thinking I’ll start at the outlet ofthe catchment that looks like it’s in cropping. Not a class that Shyam’s provided but I’m adding it as I can see it’s there. With that new, empty polygon layer on the map, I can go to the Edit tab and pick Create Features. In the pane that opens to the right, all the editable layers are shown, plus some different digitising tools for each editable layer:
The simplest tool to use is the Polygon tool, which does just what it says it does – creates polygons. With this tool selected, a polygon is started with a click, then every subsequent click draws a line, changing direction as needed. Finish off the polygon by double-clicking. My plan is to start rough, knowing that later on I can clip the land cover layer to the catchment boundary to keep everything inside:
This is referred to as a sketch – if I’m unhappy with it I can just click the and start over. When I’m satisfied, clicking finishes the sketch, followed by a Save from the Edit tab:
This makes it permanent. Note that we’ve now got two different kinds of saves available – this one saves any editing changes while the Save Project, , saves changes to the whole project – but not necessarily the edits. Okay, so I’ve got a rough start, but on close inspection, I’m not 100% happy so I’d like to reshape it a bit around the stream. Clicking Edit tab > Modify brings up a whole suite of editing tools:
For this job I’ll use Reshape > Edit Vertices. Each time I clicked, I created a vertex and the line that joins the new vertex to the previous one is an edge (remember that for later). This tool allows me to rearrange, or add or delete vertices once the feature is selected – they are visible below as green boxes with one red one, that being the final vertex of the polygon.
Now I can grab a vertex and reposition it to tidy up my first attempt – I’m just going by what I can see on the image and interpreting as I go. I can just see a fence line running west and then angling to the southeast:
Once I finish the sketch and save the edits, it’s saved to the layer:
If I right-click on a vertex I can delete it or, by clicking on an edge I can add additional vertices.
Polygons on the map is one thing, but labelling each with the correct landcover is another. By adding a text field to the layer, called LandCover, I can use this to classify each polygon. But as you can imagine, there’s extra effort involved in always typing things exactly and consistently. As far as Pro is concerned, “Mixed Scrub” is different from “mixed scrub”, let alone “Mixed scrub” or “Nixed Shrub”. I’m going to do something a little tricky and set up a drop down list of pre-baked options to choose from for Land Cover so I take my potential mistyping out of the equation. (I can already see the shape of the next blog post…). Here’s how that looks:
Now I can assign a class for each polygon by selecting one of the pre-baked options, thus avoiding my inevitable misspellings.
Next, up Shyams hand drawn map shows me that there’s some kanuka just next to this polygon. I could use the Polygon tool to create this one but there’s always an issue when creating a new polygon that shares an existing boundaries. With this area, it’s small enough that I could probably create an edge that matches the existing one, especially if I use snapping. But there’s a far easier way: Autocomplete Polygon, . With this tool I start digitising inside the exiting polygon, then do all the vertices, finishing again inside the existing polygon.
Pro then automatically finishes with an exact, shared boundary, giving me a nice result:
Using this tool becomes essential when you’re working with lots of polgyons with different shapes. If you try and match borders by hand you often end up with either “sliver polygons” (worse than a paper cut!) or overlaps that will mess up your area calculations.
Looking back a Shyam’s map, most of the catchment is classed as Mixed Pasture, so I next create a big polygon to cover this area with Autocomplete Polygon and then I can later chop it up into smaller bits of Mixed Scrub and Riparian.
Might as well Clip these polygons to the catchment boundary to tidy things up:
I’ve used the pre-cooked LandCover classes for my symbology here (that’s why there are so many shown) so you can see that 1) the extent matches my catchment boundary, and 2) we’re getting there.
According to Shyam’s map, there are smaller patches within the Mixed Pasture area that need to carved out for both Mixed Scrub and Riparian. Surprisingly, it’s rather difficult using the Modify Features tools to add new polygons into an existing one. It’s easy enough to create new ones on top of an existing one, but then I won’t have a true representation of the areas when I go to tally up hectares of land cover. So I’ll use one of the less often used boundary operations: Update. With this tool, I intend to create the rats and mice polygons for Riparian and Mixed Scrub areas and then essentially force them in to the existing poly. That means creating a new layer with these polgyons in them and then joining that to the existing layer. It’s a simple tool to use – you just have to be mindful about which layer is which:
With this result:
Please note that I’m being really rough here to demonstrate things for this post – in the final version I paid a lot more attention to exact shapes and extents of areas.
I’m not all that happy with the patch of Mixed Scrub at the top of the Riparian area – I haven’t quite gotten the right boundary when I look at the satellite image, so I want to adjust that polygon a bit. Edit Vertices seems like a good way to go — but when I use this, I notice something a bit odd:
I’ve added a new vertex (with a right-click) and moved it to the south – but in the process, the adjoining Mixed Pasture polygon hasn’t shifted, so I’m left with a hole! What to do? Fear not, there’s a way to address this. First, on the Edit tab, set the map to use Map Topology:
Topology is all about how features are spatially related to each other in space, especially those that are connected in some way, as in our polygons sharing boundaries. Once set, the Edit Vertices tool now gives us a choice between Features and Edges:
Clicking over to Edges means I can now move the vertices around and maintain the contiguity (after I add in a new vertex):
So we’re getting there – one last thing I want to show. Chatting with Shyam some more it was clear that we need to also highlight areas of Snow Tussock high in the catchment. The rough guidance from DOC was that tussocks come in above roughly 1000 m in elevation, so I added in the 20 m contours and selected the 1000 m one to give me an indication of where it is:
The easiest way to add this dividing line in is to use the Split tool from Modify Features. I’ve got two options to use this tool – Interactive, whereby I draw a line where I want to split the polygon, or By Feature, where I get to use an existing feature to do the splitting. Interactive is just another instance of digitising, so let’s try By Feature. With this tool open I need to explicitly say which are the input features (the ones used to do the splitting – the 1000 m contour) by selecting them (it) and which are the ones that will be split (the Target Features):
Running this tool gives me some new polygons (turned on some labels here to help):
Ah, well, I thought I was mostly done, but now I see I’ve created a bit of untidiness…the contour line has nicely split things but I’ve got two polygons for Snow Tussock when I should really have just one. The contour crossing over the Mixed Scrub poly has given me that extra little bit. No worries – last step is to use Modify Features > Construct > Merge. First I select both polys, and then click Merge:
Job mostly done. There were a few refinements from here, including adding a transition zone from to the Snow Tussock line, modifying existing polygons and also adding High and Low Producing Pasture classes, but the steps outlined here were used to get us to our final results for Cameron Gully:
And just to finish off, the other two:
Aside: another option for this effort could have been to make a copy of the catchment boundary polygons and start carving them up with Split and Update. Six of one, half dozen of the other, I say.
There was quite a lot of back-and-forth between me and the experts to get this right. Quite a lot. We now have an essentially bespoke land cover classification at a roughly 1:5,000 scale, just right (hopefully) for Shyam’s analysis. Along the way, I hope you’ve gotten a taste for the wide range of editing tools that are available (and can see why people might opt for image classification to do this sort of thing). It’s a painstaking process and I think I may now need to visit my optometrist (and psychiatrist for that matter), but that’s the cost of trying to get things right.