As either an interrogative or a relative, where can be thought of as a ‘pro-locative’—that is, just as a pro-noun stands for a noun phrase, where stands for a phrase (usually a preposition phrase) expressing location. It most comfortably takes (literal or figurative) spatial locations, either static or the goals of movement, as its referents—the sort of locations employed with prepositions like at, in, to.
The library where I did my research ← The library at which . . .
The situation where we find ourselves ← The situation in which . . .
The country where he is going ← The country to which . . .
In formal writing, and to a somewhat lesser extent in casual speech,where may be uncomfortable with locatives expressing the origins of literal or figurative movement. For instance, you can get away with this in casual speech:
The University of Wisconsin, where I graduated from . . .
But in academic copy you would do better to write
The University of Wisconsin, which I graduated from . . . OR
The University of Wisconsin, from which I graduated . . .
And where is generally uncomfortable with locations and goals which are not felt to be in some sense ‘spatialized’; these require which + preposition (either pied-piped or stranded) instead.
ok The principle on which he rests his argument . . . but not
∗ The principle where he rests his argument . . .
ok The goal which I am striving toward . . . but not
∗ The goal where I am striving . . .
I know of no reliable a priori method of distinguishing what referents will be acceptable with where from what will not.