Pain is a great example of many important themes in philosophy of perception. Here I want to focus on spatial perception, but I will start with a few general comments.
First of all, why do we feel pain in the first place? Scientists tend to offer two types of explanations. One is expressed in terms of efficient causes: you hit your knee against a wall, it activates receptors in your skin, these receptors make some neurons in a particular region of the brain fire, and then these neurons produce a substance (molecules) that is characteristic of pain experience (material cause). Such an explanation has some value, for example it might suggest pharmacological targets for pain relief. However, it does not explain the experience of pain at all. Why is it that a particular molecule induces the experience of pain? This does not seem to be a much better explanation than to say that the contact of the wall induces pain (it is somewhat better because it is more universally associated with pain – i.e., pain caused by other events). This problem is what philosophers call the problem of “qualia”: to explain how pain feels like, why pain hurts rather than just being some information about the state of your body. It is notoriously difficult to explain qualia in terms of efficient causes (see Thomas Nagel's famous paper, “What is it like to be a bat?”). It is much easier to explain the informative content of pain (what is going on in your body), than to explain the phenomenal content of pain (how it feels like).
A second type of explanation is in terms of final cause: it hurts because it is an experience you should avoid. It is useful for you to feel pain because then you will learn to avoid dangerous stimuli: pain has a survival value, which is why it has been selected by evolution. But again this type of explanation fails to address the phenomenal content of pain, because what it requires is a modification of behavior with dangerous stimuli, not necessarily an emotional experience. You could well imagine that when your knee is hit, you get the information that this is something that you should avoid in the future, without carrying an unpleasant feeling. You could also imagine that the event triggers a series of cognitive responses (e.g. negative conditioning) without producing any feeling at all. You could imagine that you hit your knee while sleeping, without being conscious of the event, and that your body reacts to it, perhaps even with negative conditioning (e.g. avoiding to turn in the same direction again), without you actually experiencing pain. So why does it hurt?
I do not know why it hurts. So in this series I want to address another question: where does it hurt? This is also quite an interesting question, because although it sounds obvious to us what is meant by the location of pain, we are really asking about the perceived location in the world of a feeling. What kind of weird question is this?