Certain minimum altitudes exist for airplanes. At any time, the airplane must be flown high enough to allow for a safe landing should the engine fail.
If flying over a town or group of people, the airplane must be kept at least 1,000 feet above the highest obstacle within 2,000 feet laterally of the airplane.
Over rural areas, a minimum altitude of 500 feet above the ground is required.
Finally, over open water or sparsely populated areas, only a minimum distance of 500 feet from any person or property is required.
ยง 91.119 Minimum safe altitudes: General.