In this letter, the localization of terrestrial nodes when unmanned aerial vehicles (UAVs) are used as base stations is investigated. Particularly, a novel localization scenario based on received signal strength from terrestrial nodes is introduced. In contrast to the existing literature, our analysis includes height-dependent path loss exponent and shadowing which results in an optimum UAV altitude for minimum localization error. Furthermore, the Cramér-Rao lower bound is derived for the estimated distance which emphasizes, analytically, the existence of an optimal UAV altitude. Our simulation results show that the localization error is decreased from over 300 m when using ground-based anchors to 80 m when using UAVs flying at the optimal altitude in an urban scenario.