Escaping to the country

Recreating TV maps effortlessly in TileMill – Part One

Over the past few years there has been much interest in themed maps and texture maps – pirate maps and the like, e.g. Yarr Maps, Anita Graser’s vintage map design, and so on.

This combined with the recent OS blog post ‘Maps on screen’ gave me the idea to replicate some of the maps I have seen on the TV to show how easily data can be transformed in appearance and to show how easy a ‘similar style’ can be created.

To keep things easy and to avoid having to find and load too much data into a GIS, I have tried to replicate all of the maps in Mapbox’s TileMill to start with (with the full CartoCSS code for you to copy). Although I have also explained how graphics packages would allow you to take each one further.

I guess this is the cartographic equivalent of women’s magazines showing you how to replicate the red carpet Versace-look with George at ASDA – although hopefully with better results!

So for the first post, may I present my take on the BBC’s Escape To The Country.

1. Escape To The Country

This popular BBC property show has seen its title and map style tinkered with almost every series, but in general the concept has remained the same; whether it be the title image, the overview map (on the left, below) or the more detailed regional map (on the right, below); the graphics are always clean and simple with a slight 2.5 or 3D effect over a themed and/or textured base. It always looks to me to very polished despite its simplicity. The best way I can describe it is ‘glass-like’.

Screencapture by Christopher Wesson
Original © BBC

So I decided to recreate the overview map on the left, with a point marker and label similar to that for Salisbury on the right-hand map (of the image above) but in white. I am pretty sure I remember that from the show. Sadly images were hard to come by so the above screenshot I took myself and apologies for the scan or moiré banding on the left-hand side.

TileMill comes with data from Natural Earth so all we need to do is open a project and load the relevant layers of data.

Assuming you already have TileMill downloaded and installed (which is a straightforward process), then create a new project without loading in any data (your window should look like the one below). Then simply find your new project on the list and click to open.

createTileMill

TileMill will by default give you a background tint for your map. The code section on the right (style.mss) should contain some CartoCSS code similar to this:

Map {
     background-color: #b8dee6;
}

Please delete this first because you won’t need it and it will just get in the way of our blending later on, then click Save. Next, we will add the new data layers by clicking on the layers button in the bottom left corner.

Click on + Add layer, then enter an ID of land (this will be the layer’s name) and next to Datasource click Browse. Change the tab in the second tab bar to MapBox and choose natural-earth-1.4.0/physical/10m-land.zip and click Done and then Save.

Repeat this process for ocean (http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/physical/10m-ocean.zip).

In the code panel we can call and style the two new layers, for example:

#land {
     polygon-fill: #ae8;
}
#ocean {
     polygon-fill: #b9e5fb;
}

The opacity values are 1 by default so the extra lines in my screenshot are not required. Enlarge screenshots by clicking on them.

© Christopher Wesson 2014
© Christopher Wesson 2014

So this is basic styling of polygons. As previously mentioned in the post on my newspaper map, we can apply an image to a polygon as a pattern. So let us start by applying an image of water to the ocean polygon.

The simplest way to achieve this is by replacing the polygon-fill with a polygon-pattern-file. Patterns can be called from filepaths or URLs. If you plan to use a lot of rasters then Mapbox advise that you create an images folder within your project folder (on Windows this is typically found at C:\Users\USERNAME\Documents\MapBox\project\PROJECTNAME). It is tidier but it also means you can use relative paths rather than full urls.

So first we need our image of water. The problem I had with my newspaper map is that TileMill loads images at a set size of 512 by 512 pixels: So the image often repeats and looks pretty ugly. For effects and textures this can be resolved by creating seamless raster tiles. There are various methods of creation but there are also many already in existance for which Google Images can be our friend but beware of copyright and use restrictions. So try searching for seamless water raster or similar. There are also some on Flickr.

The image I chose is called BlueWater.jpg and I placed it in a folder called images within the project folder as previously discussed.

So back to the code panel in TileMill. We can replace all of the ocean paragraph with our new code:

#ocean {
     polygon-pattern-file: url(“images/BlueWater.jpg”);
}

© Christopher Wesson 2014
© Christopher Wesson 2014

I have added an opacity to mine simply to lighten it up a little.

Now we could do the same steps to fill the land polygons with our chosen land image. However there is another method, which is more useful for overlapping polygons, that uses blend modes or compositing operations as they are known in CartoCSS.

So let us do it using this second method.

First we again need an image. To match the style of the map on the TV show I chose to use a seamless raster tile created from a photograph of grass, again via a Google Images search. I once again placed it in the images folder within the project folder. This file was named GreenGrass.jpg.

Now, rather than restyle the green land polygons, we are instead going to create a new layer with the grass image and project that onto the polygons beneath using the composite operation src-in.

So click on the layers button (bottom left of the map window), choose + Add Layers and once again add the land polygons from Natural Earth (http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/physical/10m-land.zip). This time name the layer land2. I will explain why we have chosen land in a moment.

So this time, rather than delete the land paragraph of code, leave it as it is and after it enter a new paragraph containing the following code to style the new layer:

#land2 {
     polygon-pattern-file: url(“images/GreenGrass.jpg”);
     opacity: 1;
     comp-op: src-in;
}

Note that for composite operations, as you experiment further opacity is something you are likely to play with, so I would suggest that it is a good habit to add that line to your code as I have.

© Christopher Wesson 2014
© Christopher Wesson 2014

Now I shall explain what we have done and why:

Firstly there was no real need to use composite operations here but I felt it useful to show how they are structured in the overall code. Mapbox has excellent documentation but they sometimes assume you know more than you perhaps do (and the crash course doesn’t always plug the gaps).

Secondly, (in #land2) we have used the shape of the land to cut the image and then we have used the src-in blend operation to ‘project’ this image onto the polygons beneath (in #land) which are already ‘cut’ to the exact same shape; hence why composite operations were not necessary. We could have just applied the image as a pattern to the land layer (#land) in the same way as we did for the ocean layer (#ocean) and not bothered with a duplicate layer.

Had we applied the grass image to the whole map area (you can easily achieve this by loading in the Natural Earth bounding box and applying the same style as we did to #land2), then src-in would have forced the grass image onto the whole map, i.e. to all polygons on all layers which in our case would mean both the land and the ocean layers. In some instances this may be useful, especially when used in conjunction with the opacity value and overlapping polygons. Mapbox give an excellent written and illustrated example of this and of the other composite operations on offer in TileMill and CartoCSS.

The next process is to add the location marker and label. In TileMill you will need to add another new layer. This one I called location and the file I added is 10m-populated-places (http://mapbox-geodata.s3.amazonaws.com/natural-earth-1.4.0/cultural/10m-populated-places.zip). Once again Save without styling to return to the main project window.

We will select the English town of Oxford from this data by putting a selection expression immediately after the layer name, then as normal we will place the style definition between the curly brackets:

#location [NAME = ‘Oxford’] {
     marker-width: 10;
     marker-line-color: #fff;
     marker-fill: #fff;
}

So here we have specified that where a record has a value of Oxford in the NAME field, then place a marker (a point symbol) of width 10pt, with a white outline and a white fill.

To label this we can simply add the text map elements after the marker ones. Map elements are the style variables that appear before each colon in the code. A full list of available map elements in CartoCSS can be found on the Mapbox website here.

#location [NAME = ‘Oxford’] {
     marker-width: 10;
     marker-line-color: #fff;
     marker-fill: #fff;
     text-name: ‘[NAMEASCII]’;
     text-face-name: “Myriad Pro Semibold”;
     text-size: 16;
     text-fill: #fff;
     text-halo-radius: 1;
     text-halo-fill: rgba(180, 180, 180, 0.5);
     text-dx: 10;
}

Note the extra lines of code for the text-halo. This, as the name would suggest, adds a halo around the text but using the rgba colour format I have also applied a 50% opacity to the RGB grey colour value. The final element, text-dx, is an offset of the label from the original point.

© Christopher Wesson 2014
© Christopher Wesson 2014

To give the map a bit more television appeal, we can add an effect. This is an area that is slightly limited in TileMill/CartoCSS but we shall give the land a drop shadow.

The easiest way to apply a second style to an existing styled layer is by using a double colon. We will use the #land 2 layer and the shadow effect is simply added as an outline with opacity: Simply adjust the values until it looks like a drop shadow.

#land2::shadow {
     line-color: #333;
     line-opacity: 0.25;
     line-width: 2;
}

Note that shadow here is not a recognised name, you could use anything. I am not a big fan of code snippets in beginner tutorials, so let us view the code above and all the other snippets in the context of the full CartoCSS for our map:

#land {
     polygon-opacity:1;
     polygon-fill:#ae8;
}

#land2 {
     polygon-pattern-file: url(“images/GreenGrass.jpg”);
     opacity: 1;
     comp-op: src-in;
}

#land2::shadow {
     line-color: #333;
     line-opacity: 0.25;
     line-width: 2;
}

#ocean {
     polygon-pattern-file: url(“images/BlueWater.jpg”);
     opacity: 0.5;
}

#location [NAME = ‘Oxford’] {
     marker-width: 10;
     marker-line-color: #b4b4b4;
     marker-line-opacity: 0.5;
     marker-line-width: 1.5;
     marker-fill: #fff;
     text-name: ‘[NAMEASCII]';
     text-face-name: “Myriad Pro Semibold”;
     text-size: 16;
     text-fill: #fff;
     text-halo-radius: 1;
     text-halo-fill: rgba(180, 180, 180, 0.5);
     text-dx: 10;
}

And here is the end result in TileMill:

© Christopher Wesson 2014
© Christopher Wesson 2014

Aside from the special effects, the other thing that we cannot really do is add a background image with any sense of perspective, due to the tiling issue. Whilst the land looks nice as a textured pattern of grass as if viewed from above, the original image seems to benefit from having a more natural background of water with photographic perspective.

So to remedy the above, I took the map one stage further and into Adobe Creative Suite.

I simplified my map back down to the parts shown in the screenshot below:

© Christopher Wesson 2014
© Christopher Wesson 2014

I saved the above map out as a PNG which from TileMill will honour the transparent background. I then opened this in Adobe Illustrator where I created a new layer and added the white symbol and text for Oxford as a 3D button with outer glow and text with both drop shadow and outer glow.

I deleted the original map layer and saved just the new layer (the white point and text) as a PDF.

I reopened the map image (PNG) in Adobe Photoshop where I added a more photographic background behind it and then placed the Oxford overlay (PDF) on top of it.

The final result being the simple overview location map below:

© Christopher Wesson 2014
© Christopher Wesson 2014

So there you have it, TileMill can be used to make static maps just as easily as a GIS, perhaps even more so. But then you always have the added bonus of Mapbox integration and that you can make it interactive should you choose to do so. Although there is definitely still a place for dedicated graphics software such as Adobe Creative Suite in a cartographer’s toolkit.

I hope to look at a different map from the TV in the next post that will probably involve the use of scalable vector graphics (SVGs) in TileMill and if necessary further exploration in other software packages.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: