How I tried to overlay a mask over multiple layers except for a specific region in Tilemill (and left with a buffalo tint)(and I liked it)

One thing about designing maps, you want to draw people to what they see (yes, ultimately the viewer will have their own subjective interpretation, but I digress…).
So, when designing a map to highlight the locations of 125 items that were to be photographed in the 2012 CPS Cleveland Photo Scavenger hunt, I wanted to focus on the contest area while giving viewers (likely participants who may have forgotten the exact boundaries or may not have done the scavenger hunt but would be at least familiar with downtown Cleveland) a little context of the surroundings.

How to accomplish this ? Well, I’m guessing it can be accomplished through a couple different ways: one, by, fading the surrounding features (this known as the buffalo tint) as shown in this demo by Bill Morris, wboykinm (he does inspiring works using Tilemill, pushes it to its capabilities, and blogs about it who does this buffalo tint over a separate base map, or by laying a gray mask over the surrounding area outside the border, on the same map.

Either of these techniques – Decreasing the opacity of the outside area or giving it a gray mask to make it a bit harder to read, drawing the viewer to the easier part to read and having the non-grayed part pop-out.

So, I started experimented in my project (based off originally osm-bright written by mapbox)

with map {
background-color: #999;

which would provide the gray mask, and one of the polygon comp-op function that allows you to do different effects on features in tilemill (using the gray mask)

#border {
opacity: 0.5;
polygon-comp-op: hard-light;
line-width: 4;
line-opacity: .65;

Unfortunately, all of the polygon-comp-op options that I tried including dst-in which had no effect or colored inside of the border. I uad only been able to lay the mask over the rest of the features inside of my polygon, (labels, roads, water, land), but not outside – what I’m intending to do.

So, hours later, I stepped away and thought how else to tackle this,
I came back, noticed, silly me, that

map {
background-color @water;

was called again in base.mss to provide Lake Erie with its blue sheen. I figured that might have something to do with it but that was a red harring. I eliminated that line and it left me with a gray lake.

Meanwhile, I hadn’t figured out yet or found anyone else who had done anything like this – overlay a mask over multiple layers except for a specific region in Tilemill.

(written on Nov. 28, 2012)
Flash forward 24 hours. This is why I love Tilemill. Yes, it’s free, open-source, supports linux (as well as win and osx). What you see is what you get – allowing you to code on one side while showing what your map looks like on the other. I’ve been a fan for a while, and I’m finally starting to make progress learning its intracies and operations 15 months later as its capabilities increase. It’s getting kudos by cartographers (Dane Springmeyer, lead developer of Tilemill, had the most attended presentation, by far at this year’s NACIS, the biggest annual mapping conference in North America).

I was a bit frustrated, and after a day of trying to understand the comp-op and wondering why all of the comp-op operations that I was trying had no visible effect or achieved the opposite of what I was intending to do, coloring inside the polygon, as shown above.

Only a few hours after I posted my query in TM support, Dane clarified some new tools that became available in mapnik 2.1 (just released 2 months ago) and how to go about doing it in Tilemill.

As of now, my code ended up as:
#border {
::outline {
line-color: #999;
line-width: 4;
line-opacity: .47;
line-join: round;
line-opacity: .95;

(for future reference, note: In this code, as opacity gets closer to zero, you are able to see more and more of the area outside of the border.

Resulting in:

As of now, I didn’t use the gray mask that I first intended to do (nor have I figured it out yet) but I’m really liking the results and I’m encouraged by my progress, to be able to do something that I hadn’t before.

Work on this isn’t done (I’d like to customize the colors a little more, maybe add interactivity) and you can follow the progress at its github repo and view the map.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s