Gravitational potential energy is
 (mass) x (gravity) x (height) .
When you see this formula, you should be asking yourself:
"Self ! 'Height' above WHAT ?
The answer to that question is: It doesn't matter. It can be the height 
above anything, as long as you make very clear what the reference 
(zero) level is, so that it doesn't change during the course of working 
with the problem.
There is no particular level relative to which the gravitational potential 
energy must always be measured.
In a large number of cases ... like when the problem involves something 
going up and down hills, or roller coasters making loops, or soccer balls 
or golf balls being launched ... the reference level for gravitational energy 
is the ground, because it's THERE and it's convenient.
But if the action in the problem takes place in an office on the 80th floor 
of the Aon building in Chicago, or down in a coal-mine shaft in Kentucky 
where da sun don't shan, then the floor of the room you're in would be a 
much wiser and more convenient level to adopt as the the zero-reference 
level.
There's no law.