The Map of Hogwarts and Surrounding Areas:
On one level, it could be argued that analysing the boundaries of a fictional, magical realm is pointless, because "it's just magic". But even Narnia had an identifiable shape: and part of the charm of JK Rowling's fictional world is that in many ways it's so very solid and mundane. Little streets of interesting magical shops may exist in a pocket of wizard-space, but they do so in an area of London which is full of little streets of interesting shops. Hogwarts itself is visible to Muggles, although disguised as a ruin, and many features of the wizarding world are identifiably caricatures of real-life institutions - and places. And if you sit down and work it out, the area around Hogwarts has a remarkably consistent ground plan; even if the castle itself is a bit fluid.
This, then, is an attempt to analyse everything we can derive from the books, concerning the location and layout of the Hogwarts/Hogsmeade area.
Some years ago, JK Rowling sketched a rough map of Hogwarts, which appeared pinned to a notice-board in the Prisoner of Azkaban DVD. A still of this has been posted on the Harry Potter Lexicon, but it's photographed at an angle, the paper is buckled and the image cuts off the bottom of the map. A complete, straight-on photo' of the same map appeared in The Daily Telegraph magazine in February 2010 but it's tiny and really low-resolution. I have therefore combined and traced over the two and prepared a complete, cleaned-up, legible version, so you can actually read the labels etc..
Generally speaking Rowling is a good artist, and could probably draw professionally if she could only break the habit of making the lower half of her human subjects' faces too small. In this case, however, her sketch-map was obviously done on the fly and is only a rough approximation - if you look closely you can see that she originally drew the railway line and the path to the lake in a different position and then scribbled the Forest over the top of them.
This sketch-map cannot be more than a very rough guide, in fact, since it conflicts with the books in obvious ways. To begin with, we know the proportions are wildly out, because we are told in Quidditch Through the Ages that the length of a Quidditch pitch is 500ft, and if JKR's drawing was anything like in proportion, and her pitch was 500ft long, that would mean that the "lane" leading to Hogsmeade was also 500ft long - and 150ft wide!
Then, the position of the lake vis-à-vis the castle cannot be correct, since we are told in the books that the characters walk past the lake en route between the castle and the front gates, and between the castle and Hagrid's cabin; and also that it is possible, while standing on the lawn just in front of the castle, to see the centre of the lake. We know that the lake is entirely enclosed within the perimeter wall, not abutting it as it does in this sketch, because students are able to walk right round the lake without leaving the Hogwarts grounds. We are also told, with a high degree of certainty, that the Forbidden Forest is west of the castle, and with a strong degree of probability that the lake is south of it, and in JKR's drawing if the Forest is west of the castle the lake is north of it.
In order to draw up a map of the castle which is actually compatible with the books, therefore, I have used JKR's own map as a rough guide but have adapted it where necessary, in order to comply with what we are actually told in the books.
As a general rule, here and elsewhere, I treat what is in the books as the primary source and as "fact", except in those few cases where what is in the books is manifestly impossible - which usually means where JK's maths has let her down more than ordinarily badly.
[It is impossible, for example, for Hagrid's cabin and the Beauxbatons carriage to be 200 yards apart, and yet for Hagrid to stand just outside his cabin and Madame Maxime to stand just outside her carriage and them to be able to converse in voices too quiet for somebody inside the cabin to hear what they're saying, and yet be able to hear each other, without using any sort of magical boost - especially since we are told elswhere that the cabin and carriage are next to each other.]
Formal writing by JK Rowling outwith the books, such as the "Famous Wizard" cards, is treated as canonical unless it clashes directly with the books. Less formal statements made by her, such as interviews, website comments etc., are treated as semi-canonical and as secondary to the books, used to clarify points which the books leave open, but disregarded if they clash directly with the books or other formal writing. Where such semi-canonical statements clash with each other, the most recent statement is usually to be preferred. Evidence from the films and other extra-canonical sources are referred to only if the books and JKR between them have failed to clarify a point.
I have tried, wherever possible, to avoid explaining away anomalies with the excuse "It's magic - it moves about." There are some instances, especially to do with the position of the Fat Lady inside the castle, where you just have to conclude that something does move but in general things clearly have a fixed or at least a usual position, otherwise nobody would ever find their way about, so I have tried wherever possible to find non-magical explanations for apparent anomalies.
Note that the section on the grounds needs to be read before the section on the castle, since a lot of the working-out of the shape of the castle depends on what areas of the grounds can be seen from which window, and that requires a prior knowledge of how the grounds are laid out.
A lot of the measurements in this essay depend on knowing the average speed for a human walking, running etc., and saying "If it takes five minutes to get from A to B, and we know roughly how fast they were going, then we have the approximate distance between A and B". Normal walking speed is often cited as 4mph but in fact that is a very fast "power walk". The U.S. Manual on Uniform Traffic Control Devices assumes the average speed of a pedestrian - presumably a normal sort of strolling speed, neither hurrying nor dawdling unduly - to be 4ft per second, or about 2.7 miles per hour: see for example The Continuing Evolution of Pedestrian Walking Speed Assumptions, which discusses the advisibility of actually lowering this to 2mph when considering e.g. pedestrians moving away from an intersection.
Health researchers at Harvard define 3mph and above as "a fast walk" - see e.g. this summary of an article in the journal Stroke. Wilderness Backpacking states that 2.5 to 3mph is a normal speed for a walker on a gentle trail, carrying a light pack; so since most people at Hogwarts are walking up and down grassy slopes, carrying schoolbags, brooms etc., I have taken the MUTCD's 4ft per second, or 2.7 mph, as my standard.
Against this, an Italian friend (SilviaLaura of the Loose Canon Harry Potter discussion-group) maintains, as somebody who walks as a hobby, that normal walking speed for somebody who is actively trying to get somewhere is around 3.5mph. But I know that when I was in my late teens, at a time when I could and often did walk eight miles in a day without even thinking about it and then go dancing, my own normal speed - walking solo, in a moderate hurry and without the distraction of a companion to talk to - was indeed around 2.7mph, though I could do 4mph if I was really rushing. So I'm sticking with the MUTCD figure as a rough guide: but bear in mind that walking speeds, and therefore some of the distances, could be slightly greater.
Estimates of normal running speed are more problematic - figures seem to vary considerably, and are complicated by the fact that humans can sprint over short distances much faster than they can run over long ones. The record speed for a human sprinter (Usain Bolt) is nearly 30mph. According to Medicine & Science in Sports & Exercise, the average speed for runners at the Atlanta Olympics was 19.4 kilometers per hour, or about 12 mph - but that was for top runners, albeit over a fairly long haul. At the other extreme I found a website for a long-run club which gave the average speed of their runners as between 5 and 7.5 mph. These are not trained athletes, but their speed is probably on the low side even for non-athletes, since they are running at a steady pace over long distances.
The chart of different running speeds shown in the article In Search of a 10k PR by Dr Nicholas Romanov, Florida Sports (US) Vol.11, No.10 · December/January 1997-98, has 1.14 minutes as slowest speed shown for a distance of 400 metres - which is to say, about 13 mph - but that's for top runners, presumably on a track. Harry and co. when they run are usually dashing - but although Harry and Ron at least are quite athletic they are not practised runners, and are generally running hundreds of yards over uneven ground, often in the dark, so they will be somewhere between the 13mph of the top athletes and the 5mph of the long-haul hobbyists.
Wikipedia says that the speed of a trotting horse is "about 8mph, or roughly the speed a human can run". A respondent on Wiki answers states that "the average [running] speed for a normal person would be 10 to 14 km per hour" (6.2 - 8.7mph) and nobody has disputed that. In the absence of anything more authoritative, then, I'm going to assume Harry's running speed to be about 8-10mph, depending on how hard he's sprinting.
As for swimming, the article Concept Designs for Underwater Swimming Exoskeletons, by Peter D. Neuhaus and others, gives the top speed for a reasonably experienced human diver wearing fins as 1.5 m/s (3.36 mph) and the extended cruising speed as 0.5 m/s (1.12 mph).
As regards other speeds used as measures in these articles, the estimate of the top speed of a normal rowing boat as about 4.5mph, or just over 130 yards per minute, is derived from an article on a robot rowing project.
HorsemanPro gives the normal trotting speed of a horse as about 9mph and the walking speed half that, although well-practised carriage horses can trot at 14mph. That's probably referring to racing-carriages though: not working horses (or Thestrals) pulling coachloads of kids.
Some detailed information on the speed of British steam trains can be found at Mike's Railway History.