"This building is at an intersection."
An interesting japanese sentence which illustrates that although there is no reference made of the positional relationship of either the building or intersection, we still know that it means the two are close to one and other. This is when learning becomes very effective by way of understanding the nuances of a particular language through its grammatical structure!
に is used to mark the location of the subject. If there is an action verb, the location of the subject that has stayed after the action has been performed.
で marks the location where the action takes place.
本が 本だなに あります - there is no action verb. So marking the location of 本 (book) i.e. 本だな (bookshelf). It cannot be でbecause there is no action involved.
バスは 学校の前に とまります - the action is とまります (stop) and after the stopping action, the バス (bus) stays at 学校の前 (in front of the school). It can be exchanged with で and the emphasis switches: に emphasize that the bus has stayed. で emphasize the action.
私は 部屋で 勉強しました - 勉強しました (study) is the action. The location that this action is 部屋 (room). It cannot be に because after studying, the subject 私 does not stay at the room (can be but not necessary and is not the focus).