The purpose of this chapter is to promote the health, safety, morals, and the general welfare of the community, by regulating and restricting the height, number of stories, and size of buildings and other structures, the percentage of lot that may be occupied, the density of population, the size of lots, yards, courts, and other open spaces, and the location and use of buildings, structures and land for trade, industry, residence, and other purposes; to provide for adequate light and air; to prevent congestion and undue crowding of land; to secure safety from fire, panic, and other danger; and to conserve the value of property.