An interesting journey with PowerShell GPS data and SVG. (Part 1)

Eileen phoned me from a traffic jam yesterday. “I’ve got a demon in the car” she said. A little late for a technical person Eileen has joined the world of Sat Nav owners and her characterization of hers put me in mind of the personal Dis-organizer device which shows up in some of the Terry Pratchett books.

An extremely annoying personal organiser, it is powered by a (usually incompetent) imp, which can perform various tasks. There have been 3 models encountered so far: the Mark 1, mark 2 and Mark 5. All of these start up with an unusually happy tune such as “bingly-bingly beep!”, “bingle bingle bingle” or (when wet) “ob oggle sobble obble”.

The [Mark 1] claimed to have 10 functions, although it appeared that five were apologising for the useless manner in which it performed the others.
… the Mark 5, the Gooseberry, [is] much more useful than its predecessors. It has games, such as “Splong”, and “Guess my weight in pigs”. It has an “iHum” feature, and can [send messages using ‘BlueNose’]

Eileen’s late to GPS, but since she can find her position on the Globe with a wrist watch a protractor and a couple of match sticks (another of those Obsolete Skills that I referred to), I can’t say I blame her. I’m into old-style navigation myself, having got an ‘O’ level in Air Navigation: actually I’m even more retro than that, I have prints of 17th century maps hanging on the walls at home – many by a Dutchman called Blaeu. Wikimedia have some of this maps – this one gives an idea of the style of the ones I have, and Taschen recently published some of his Atlases  and I had the “Anglia” and “Scotia and Hibernia” volumes as a Christmas present. They have an introduction explain Blaeu’s role in making the maps (as publisher rather than surveyor), his business and the role of other cartographers, notably Mercator.

Mercator is famous for two things. One he was the first person to call a collection of Maps an Atlas, and he gave his name to a way of mapping the surface of the roughly spherical earth onto a flat sheet of paper. “Mercator’s projection”  is still widely used even though it is “wrong”.  (West wing addicts may remember “Cartographers for social Justice” – the idea behind is here ).  Looking at a Mercator Map you’d think that if you were going to fly from Munich (Lat 48 degrees) to Seattle (also Lat 48 degrees) the shortest way would be to follow the line of latitude all the way, right ? The shortest distance between two points is a straight line, right ? But (unless you’re building a tunnel) you can’t go in a straight line along the earth’s surface, you have to go in a arc, and the shortest arc doesn’t follow a line of latitude, but follows the edge of a slice which passes through the centre of the earth. Which is why flights from Europe to the use go North.

Yipee - I got it working in powergadgets !The problem Mercator solved is simple. As you move away from the equator, lines of latitude are equally spaced – 1 arc minute of Latitude is 1 Nautical Mile*. However lines of longitude are not. Just South of North pole you can jog round 360 degrees  of longitude in a few paces. At the equator its over 20,000 miles.  How do you draw that ? Mercator’s solution draw lines of longitude evenly spaced and parallel (in real life they converge at the poles); but to allow for the fact they are actually narrower as you move away from the equator increase spaces between parallel lines of latitude (in real life they are constant distance). So grabbing a handy Mercator projection map (my local Ordnance Survery map) 5′ of latitude takes 18CM of map, and 5′ of longitude takes only 11CM.

Why does this matter? Well if you have GPS co-ordinates for mapping the boundary of something, then if you simply plot them as square, then the map looks wrong. I’ve found data for building the SVG file I need for PowerGadgets to do a British county Map. I processed it into the SVG file using PowerShell (of course – and that will be where part 2 comes in). But although the map is recognisable, it looks wrong because I haven’t made allowance for the projection. I’m going to do that later, and then explain the PowerShell which I got me there.

Technorati Tags: ,,,,

*Foot note. A Nautical Mile is 6076 feet, so one arc second of Latitude is about 100 feet. I’ve seen GPS numbers locations with fractions quoted greater than 0.1 second acuracy the “10 foot” accuracy quoted for consumer GPS devices

Comments (1)