It is a transfer of the meaning on the basis of comparison. Metaphor can be based on different types of similarity:
a) similarity of shape: head (of a cabbage), bottleneck, teeth (of a saw, a comb);
b) similarity of position: foot (of a page, of a mountain), head (of procession);