We look at turning layers on and off at chosen scales to make for a better map.

Alas, poor Yorick! I knew him, Horatio: A fellow of infinite jest.

With all due respect to Hamlet and Willie the Shake, this time we’ll look at an oft underappreciated side of mapping: scale dependency for layer visibility.

In a previous post we looked at setting reference scales, so that features keep their dimensions as you zoom in and out. This can be handy under the right conditions, but layer visibility based on scale is a bit different. The short of it is that we can set a layer to only display within set maximum and/or minimum scales. You may be familiar with this when looking at Canterbury Maps – as you zoom in more and more layers become visible while others turn off. Google Maps does a similar thing. This is a nice way of controlling the busy-ness of a map by setting how much detail you want to display.

This came to mind when working with a student on her class project – she was looking at some analysis of crashes in the Selwyn District and had industriously gotten hold of the Crash Analysis System (CAS) from NZTA in the form of a spreadsheet:

Lots of attributes here – each record (there are 853.455 in total) relates to an accident and the columns give us different details about that event. From a GIS perspective, two of the most important are contained in the first two columns: X and Y. These will allow us to map these data, so long as we know what coordinate system they are in. These look to me like eastings and northings in New Zealand Transverse Mercator (NZTM) – we need to know this to map the points:

Before mapping, the data were filtered to just the Selwyn District (n = 6,123) and cover the period of 2000 – 2024. Of particular interest in this analysis are the fatal accidents, and the spreadsheet includes an attribute called “fatalCount”. A sad statistic, it holds the number of fatalities at each accident (and there are far too many). Having the points on the map is a good start but it would be more helpful to show how the fatalities are distributed; we have a lot of symbology options to show this – the simplest perhaps being either it was fatal or not, so two colours for two outcomes – I’ll choose red for fatalities and, blue for non-fatal crashes. (Green might too suggestive of it somehow being “okay”). Here’s what that looks like using graduated colours with two classes:

This works okay – I could refine things by maybe making the nonfatal crashes hollow so the reds stand out better, or play with point sizes, but suffice it to say there are a lot of options here. Let’s try something else – looking at my fatalCount attribute, it ranges from 0 to 3, so maybe I can take advantage of that and use the size of the point to also show how bad the crash was – I’ll use Proportional Symbols for this:

This is maybe an improvement (lots of ways I could tweak this) but I hope you see a problem – given the scale, it’s really difficult to take the different sizes of the points into account, so the wetware really can’t make the most of the data. For this to make more sense, I’d be much better zooming in to a scale where the differences are more apparent. The current scale of the map above is 1:650,094 (shown in the lower left-hand corner) but if I zoom in to, say 1:50,000 (and add roads, and change the symbol colour…), we can make better sense of these data:

Given the nature and the detail of the points, the symbology works better at larger scales, i.e. zoomed in (larger scale = smaller area, and vice-versa). So what are my options at smaller scales? Here’s where some scale dependency starts to come in. At smaller scales, it might be easier to get a sense of the data by attaching them to larger features, like the roads, or some kind of area. Since we’re doing this analysis for the Selwyn District it might not make much sense to attach the total number of fatal accidents to the district layer (but it might if we were analysing all the districts across the country) so I’m thinking about areas that subdivide the district. Statistical Areas 1 and 2 from the census come immediately to mind.

In a previous post we looked at a way to do this using Summarize Within. Here I can use Sum to add up all the fatalCount values that occur within each polygon and then symbolise off of that. I’ve done that with the SA2 areas (using Graduated Colors with four classes and Quantiles to set the class size):

And the same setup for the SA1 areas:

Something that the areas with the highest fatal count appear to have in common is the presence of a State Highway – not too suprising but we might need to do some more analysis to confirm that. We could try using more classes to tease this out but it’s an inference based on what we can see.

So now I’ve got three layers that are showing different versions of the same data. I can’t show all three at once so what can I do? One thing would be to set the scale at which each layer is visible, with SA2 showing at the smallest scales, then SA1 as we zoom in more, and then the points at the larger scales. The trick will be setting the right scales where they switch.

The scale visibility is set for each layer. By right-clicking on the layer name in Contents we can open the Properties > General and see how we can set this:

By default, the Visible Scale Range is set to “Show layer at all scales”. If we tick “Show layer between these scales only” we can control when it turns on and off by setting the Maximum and Minimum scales.

For the SA2 layer, I’ll leave the Minimum scale set to <None> so that it will always be displayed as you zoom further out. The Maximum scale should be set to when it’s helpful to switch over to the SA1 areas. With a bit of trial and error, I’m setting that to 1:150,000; now when I zoom in beyond 1:150K, this layer turns off – the layer is greyed out in the Contents pane:

Next, I’ll set the visibility scales for the SA1 areas – the Minimum scale here should match the Maximum scale in the SA2 layer and the Maximum I’ll set to 1:50K:

The points layer Minimum gets set to 1,50K and the Maximum stays blank. With all this set up, which layer gets displayed depends on what the scale the map is displaying. In this way I can show different levels of detail at different levels of zoom. (It’s a bit hard to show that in a static webpage, but I hope you see where it’s going.)

You may be asking about the roads – and fair enough. Given their importance, I’ve opted to display them at all scales. I do have the option of trying to attach the fatalCount data to each road segment, which might give me another scale to work with between points and SA1 areas. For this I’d probably use Summarize Nearby but it proved to be a little problematic. By its very nature, this tool creates an area (a buffer) around each feature and does its counting within that area. For the roads features this unfortunately means that points can get counted multiple times, thus overestimating things. The picture below hopefully illustrates this for the tangled mess that is Leeston – blue areas are the buffers around roads – you can see several instances where the same point is in multiple buffers:

I’ll need to think of another approach here – it’s tricky because some of the points are a distance away from a road, so finding the right size may be the issue. Didn’t get a chance to try this but a simple Joins and Relates > Add Spatial Join could work here – just thought of that.

You might also be tempted to say, what’s the point of doing this if my map reader needs to be sitting beside me to see all this happen? I can’t really convey this in an exported PDF of my map either. BUT, if I publish these layers to a webmap, then my reader will definitely see the effect in their browser, and I think that’s probably the best place for a map like this to end up.

So here’s one you can see for yourself with.

Scale dependency for layer visibility is yet another arrow in your quiver for displaying spatial data.

The rest is silence.

C