This template is used onapproximately 453,000 pages. To avoid major disruption and server load, any changes should be tested in the template's/sandbox or/testcases subpages, or in your ownuser subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on thetalk page before implementing them.
Thissubtemplate of{{Infobox settlement}} displays a metric/imperial pair of population density values for a line in the main infobox.
Usage
{{Infobox settlement/densdisp| /km2=''auto'' or population density per[[Square kilometre|km<sup>2</sup>]] (via''population_density_km2'' and others)| /sqmi=''auto'' or population density per[[sqmi]] (via''population_density_sq_mi'' and others)| pop= population (via''population_total'' and others)| km2= area in square kilometres (via''area_total_km2'' and others)| sqmi= area in square miles (via''area_total_sq_mi'' and others)| ha= area in[[hectare]]s (via''area_total_ha'' and others)| acre= area in[[acre]]s (via''area_total_acre'' and others)| dunam= area in[[dunam]]s (via''area_total_dunam'' and others)| pref= preference to display /km2 or /sqmi (via''unit_pref'')| name= name of country (via''subdivision_name'')}}
Examples
density as auto
As shown in the following examples, this template calculates the density if all three of the following conditions are met: /km2 (or /sqmi) is set to auto, a number if given for population, and a number is given for area. It also strips any formatting from the numbers, such as population with commas in the examples, which would otherwise cause an error in the calculation (seemw:Help:Magic words#Formatting).
As shown in the following examples, this template always displays the density if given as a number, regardless of whether the population and area are defined. It also strips any formatting in the number, such as the commas in the examples.