Labelling related features

There hasn’t been much GIS on this blog recently, so I’m going to talk about an interesting problem I saw recently. A user was trying to add some road labels to a map, but wanted the label to show the name of the next town along the road, much like the John Ogilby strip maps below: “to Thorp”, etc.

Ogilby 1675  Ogilby Garstang-Carlisle

The house style he was working with showed districts, roads and cities, but only a single district of interest was shown at one time. No features were visible outside this district polygon. I tried to achieve the effect he was after, and I think I managed, although the method isn’t completely straightforward. I’m going to go through the required steps here, using one of my US datasets. Obviously, you’ll need to change some of the layer and attribute names if you want to follow the example with your own data.

Open Arcmap and add the data to the map. In my case, a point layer (Cities), a line layer (USHigh), and a polygon layer (States).We only need to show a single state of interest, so right-click States in the Table of Contents (TOC) > Properties > Definition Query tab and enter the query: Name = ‘Indiana’.

My data is showing too many cities, so I’ll thin them out in the same way, using a definition query to only show features with a population greater than 100,000.

Image 1

Now the highways need to be clipped so only the features within Indiana are showing. Open the Clip Geoprocessing (GP) tool and run with the following inputs:

Clip: States

Image 2

It gets a bit tricky here, as Maplex can only place labels at the beginning or the end of a line. Unfortunately, some of the lines will need labels at the beginning and some at the end, depending upon which direction they were digitised. You may be lucky and find that all the features were digitised starting at the centre of the state and moving towards the boundary (or vice versa), but it’s not very likely. Open the Label Manager and set the Label Field for USHigh_Indiana to OBJECTID, Label position should be Centered curved, and the properties in the Offset dialog should look like this to push the label off the end of the line:

Offset properties

It is also a good idea to go to the Label Density tab, uncheck Connect features, and make sure the combo is set to One label per feature. It’s likely that some roads will point to the same city, so we don’t want Maplex to “helpfully” connect up those features and remove some labels

Image 3

As you can see, some of the labels are placed at the end of the line features, outside the state boundary, but some are at the other end of the line, inside the state. These latter labels will need to be placed differently, using the After end of line option. Create two new label classes on the USHigh_Indiana layer, called Start and End, and change the label offset to After end of line for the End label class.  Then create SQL queries for each class to select the correct features (Label Manager > SQL Query button). Now you should have one label coming off the end of each highway.

Image 4

Now we need to relate each highway feature to the nearest city. We don’t want to consider the cities within Indiana, so we need to create a selection layer that only contains cities outside the state. There are two ways of doing this: select all then remove the features within the state, or select the features within the state, then switch the selection. I’m going to use the second method.

Go to Selection > Select by location. Selection method = select features from, Target layer = Cities, Source layer = States, Spatial selection method = intersect the source feature layer. Click OK.

Right-click Cities in the TOC > selection > switch selection

Right-click Cities in the TOC> selection > create layer from selected features

Now we can run the Near GP tool with the following inputs:

Input features: USHigh_Indiana
Near features: Cities selection

This creates a field called NEAR_FID on each highway feature, which can be used to create a join to the Cities layer.

Right-click USHigh_Indiana in the TOC > Properties > Joins & Relates tab > Joins > Add… 1. Layer join field = NEAR_FID, 2. Table = Cities selection, 3. Table join field = OBJECTID.

Now we can change the label field to Cities.CITY_NAME, or even better, a label expression of: “To “ & Cities.CITY_NAME. Also, the SQL queries will need to be updated so OBJECTID becomes USHigh_Indiana.OBJECTID. I find it easier to copy the whole query, paste into a text editor, such as Notepad++, do a find and replace, then copy and paste it back into the query window, rather than editing each clause in the query. [Note: some dialogs in Arcmap do have find and replace functionality, e.g. the Convert Labels to Annotation dialog. It’s not documented, but you can click on the Annotation Feature Class column and press ctrl-H to quickly change part of the class name for every layer at once.]

Image 5

This should give us the result we’re after, but something is not right. If you look at the western border of the state, the two higways that point to Springfield are actually labelled “To Cincinatti”, and the highway to the south is labelled “To Nashville-Davidson”, when it should be St. Louis. The problem is that the Near tool finds the nearest feature  to any part of the input feature – the eastern end of the highway is closer to Cincinatti than the western end is to Springfield.

To get round this, we could shorten the feature, so only the end near the border is used. To isolate part of the highway near the state boundary, we need to create a clip shape of the inner edge. First run the Feature to line GP tool with States as the input feature, then run the Buffer GP tool with a distance of 0.25 Degrees. Now Clip USHigh_Indiana, calling the output layer USHigh_Indiana_Labels. The state border (red), buffer (yellow), and clipped highways (green) are shown here.

Image 6

Rerun the steps above, using the USHigh_Indiana_Labels layer. Change the symbology to have no colour – we’ll leave the USHigh_Indiana layer on to show the location of the highways within the state (but make sure you turn off the labels for this layer).

Image 7

Now the highway labels are showing correctly, we need to declutter the map by removing the outside cities. Create another selection layer of just the cities within Indiana and label this instead. To copy the symbology from the Cities layer, go to Layer properties > Symbology tab > Import… and to copy the label properties over, go to the Label manager > right-click on Default label class of Cities layer > Copy parameters > right-click on Default label class of selection layer > Paste.

Image 8

As the highway labels are offset from the state boundary, you might get better results by clipping the portion of the highway that is immediately outside the state instead. I’ve done this here and left the longer highways showing, which may fit better with some house styles.

Image 9

So, in this blog post, I’ve shown how to label one feature layer using the attributes of nearby features from a different layer. Though the final setup needs to be done by hand, most of the steps in this process can be automated, using model builder or Python scripts. Maybe I should describe how to do that in a later post, though.

Parks and Restoration

One of the best things about Cardiff is that right in the middle of the city, there is a well-designed and beautifully maintained green space, which is free for everyone to experience. I often take a detour through Bute Park when I’m walking into town, just to enjoy the peace, quiet, and fresh air. The other day, I noticed there were fences up around Blackfriars’ Priory and stopped there to read the information signs; it turns out this is the latest stage of a restoration project that has been going on for almost a decade.

The project began with a detailed report (pdf) on the history of the park, its current usage, and future plans for development. It is a comprehensive document, bringing together for the first time many items from the city and national archives and gives an interesting account of how the park came to be as it is today. The history section of the report features a number of maps – I’m going to show some of them here, along with a summary of the evolution of this fabulous resource we have, at the centre of a busy city.

The Romans built four forts on the site of Cardiff Castle, the latest in the 1st century CE. A Norman motte and bailey timber fort replaced it in 1081; it was reconstructed in stone during the 12th century. Around this time, a number of mills were built on the banks of the River Taff – they were used for iron making, corn, and fulling. The first recorded mention of these mills was between 1118 and 1147; they were still in operation in 1530.

In 1256, the Black (Dominican) Friars established a friary, founded by Richard de Clare, son of Henry I. It was sacked by Owain Glwyndwr in 1404.

Domestic quarters were added to the castle in the 15th century, and a Shire Hall added in the 16th century, seen here in John Speed’s 1610 map (Figure 10).

Speed 1610

The castle and mills fell into disrepair, passing through the hands of various family owners until the Bute family took over the estate in the mid-18th century. In 1730, the mill stream was widened, upgraded by Richard Watkins of Bassaleg, and in 1778 Capability Brown and Henry Holland began work on the castle. (Brown has a more substantial web presence than your average 18th century chap, with his own website and blog, amongst other resources.) Figure 11 shows that most of the area to the north of the castle was farm land around this time.

Blackfriars 1779

In 1796, the title of First Marquess of Bute was created. He ordered a new bridge over the Taff to replace the existing medieval structure, which had needed many repairs over the years. Some reports talked of huge blocks of ice drifting downstream in the spring thaws, which caused a significant amount of damage. See plate 1 for Turner’s view of the bridge.

Turner Bridge 1795

Around this time, the Glamorganshire canal was built, transforming the fortunes of the area. A feeder for the canal was constructed (visible on figures 11 and 16), running to the east of the castle. Some old postcards of the canal at the North Road lock can be found here and here. The canal bridge is still there, but it is now a pedestrian subway under North Road (see photo below).

North Road subway

The Taff was still untamed at this time; the course of the river would often change and the whole area was prone to flooding. Figure 16 gives an idea of how convoluted the river was, though it’s not clear how many of the changes in figure 18 are present.

West of castle, 1813

The mills began to fall into disuse again, mostly due to disputes over mill stream. There were disputes over the actual course of the river too – in 1822, the owner of western bank built jetties and planted trees, resulting in more erosion on the east bank (see figure 18). The Marquess lost 12-20 acres of land.

Jetties and banks 1820

Figure 17 shows the Glamorgan estate in 1824. Note how the main roads, to Cowbridge and “Merthyr Tidvil” are turnpikes – a toll gate is visible to the north of the castle. It’s also interesting that the area to the West of the river is labelled “Place Sturton Farm”, clearly the derivation of streets that can be seen in Pontcanna nowadays, such as Plasturton Gardens.

Glamorgan estate 1824
In 1829, there were proposals to adapt the mill stream and in 1836, Blackweir farm was purchased by the Marquess, partly to aid construction of dock feeder (figure 26), which took place in 1836-41. A footpath was added from the Taff to the moat, the northern moat was cleaned and lowered, and a well constructed. The bridge across the feeder became known as Lady Bute’s bridge (see photo below).

Lady Bute's Bridge

Dock feeder 1833

The first Cardiff dock opened in 1839 and in 1848, the 2nd Marquess died. His heir, the 3rd Marquess was only one year old, so trustees took care of the estate for the next 20 years. The River work was completed in 1851 and area now known as Bute Park became one complete site for the first time. See figure 19 for the Ordnance Survey of that year.

Ordnance Survey 1851

In 1855, the trustees bought Coopers Fields and closed Bute park to the public to give the family more privacy. To compensate for this, a plan was devised to open Sophia Gardens on the west bank of the river for public use. With the grounds closed, deer were kept in Bute Park between 1851 and 1870.

1859 saw the opening of the second Cardiff dock, and construction of a new bridge, which is still in use today. You can still see the foundations of the previous bridge at the edge of the park (see photo below).

Bute Park and bridge foundations

The 3rd Marquess gained his majority in 1868 and began to transform the castle with William Burges. Plate 10 shows the view over the new bridge in 1869.

W from clocktower 1869

In 1875, a Swiss bridge (by Burges) was constructed over the moat at the west of the castle (see plate 23). It was relocated west of the mews in 1927, then demolished in 1963. Few pictures of it remain beyond those in the report (in other words, I couldn’t find any on the internet).

Swiss Bridge 1879

Figure 27 shows the 1880 Ordnance Survey plan of the park, which apparently shows the deer fences, but I can’t make them out.

Ordnance Survey 1880

In 1887 Blackfriars’ was excavated by Kempson & Fowler. The animal wall was constructed a few years later; it had to be relocated in 1923 due to the widening of Duke St.

The 3rd Marquess died in 1900 and his son, the 4th Marquess, died in 1947. The 5th Marquess gifted the castle grounds to the people of Cardiff. The arboretum was started the same year, and in 1950, the council proposed a zoo in Bute park. Perhaps this was to compensate for the recent closure of a zoo in Victoria Park.

In 1978 the Gorsedd stones were erected for the National Eisteddfod, in 2000 the footbridge to Sophia gardens was installed, and in 2004 the current round of development began, with postal and face-to-face surveys, electronic counters, research, etc., feeding into a 258-page report. It’s interesting that, in the surveys, Bute Park was named the least favourite of all the parks in Cardiff, with anti-social behaviour, drink and drug use, and crime being the main reasons.

So, hats off to Cardiff Council for making so many improvements to the park and for turning it into a place that people want to visit again. Let’s hope it can stay that way for many years to come.

[Yes, the title is a reference to Parks and Recreation. If you haven’t seen it yet, take a look!]