வார்ப்புரு:Show data
{{#if:{{{flag image|}}}|[[File:{{{flag image}}}|150px|right]]}}
 This template contains various independently retrievable data items about '''{{#if:{{{1|}}}|[[{{{article|{{{1}}}}}}]]|&lt;code&gt;&lt;nowiki&gt;[[{{{article|{{{1}}}}}}]]&lt;/nowiki&gt;&lt;/code&gt;}}''' in the form of parameter values of a variable template of choice, in a standardized fashion. It is a member of a family of templates, those with names starting with &quot;Data&quot; in [[:Category:Data templates]]. The system used is similar to that of [[Wikipedia:WikiProject Flag Template]]. {{#ifexist:Template:Country data {{{1}}}| The corresponding template of that project is [[Template:Country data {{{1}}}]].}}
 
 ==Parameters==
 {| class=&quot;wikitable&quot;
 |-
 !Parameter name!!Value!!Meaning
 |-
 | &lt;code&gt;1&lt;/code&gt;
 | &lt;code&gt;{{{1}}}&lt;/code&gt;||last part of template name, used to identify it within the family of templates&lt;ref&gt;It may seem odd, but a template cannot retrieve its own name (PAGENAME only provides this on the template page itself), and even if it could, a string operation would be needed to remove &quot;Data &quot;. Putting the name of the entity in the data template removes the need to supply it as a parameter when the data template is called (in the cases that it would need this name).&lt;/ref&gt;
 |-
 |&lt;code&gt;article&lt;/code&gt;||{{#if:{{{article|}}}|&lt;code&gt;{{{article}}}&lt;/code&gt;}}||article name; needs to be specified only if it differs from &lt;code&gt;{{{1}}}&lt;/code&gt;; in applications, use &lt;code&gt;&lt;nowiki&gt;[[{{{article|{{{1}}}}}}]]&lt;/nowiki&gt;&lt;/code&gt; to link to the article (as has been done at the top of this page)
 |-
 |&lt;code&gt;short name&lt;/code&gt;||{{#if:{{{short name|}}}|&lt;code&gt;{{{short name}}}&lt;/code&gt;}}||shorter display name to be used in some contexts; an application or application parameter can specify whether this is used; only intended for dispensing with disambiguation in a context where it is not needed 
 |-
 |&lt;code&gt;type&lt;/code&gt;||{{#if:{{{type|}}}|&lt;code&gt;{{{type}}}&lt;/code&gt;}}||type of entity, e.g. continent, country, province, municipality
 |-
 |&lt;code&gt;code&lt;/code&gt;||{{#if:{{{code|}}}|&lt;code&gt;{{{code}}}&lt;/code&gt;}}||code
 |-
 |&lt;code&gt;code description&lt;/code&gt;||{{#if:{{{code description|}}}|&lt;code&gt;{{{code description}}}&lt;/code&gt;}}||code description
 |-
 |&lt;code&gt;continent&lt;/code&gt;||{{#if:{{{continent|}}}|&lt;code&gt;{{#ifeq:[[:Template:Data {{{continent}}}]]|{{Template:Data {{{continent}}}}}|[[{{{continent}}}]]|{{data {{{continent}}}|linkd}}}}&lt;/code&gt;}}||continent, if ''type'' is lower than &quot;continent&quot;
 |-
 |&lt;code&gt;country&lt;/code&gt;||{{#if:{{{country|}}}|&lt;code&gt;{{data {{{country}}}|linkd}}&lt;/code&gt;}}||country, if ''type'' is lower than &quot;country&quot;
 |-
 |&lt;code&gt;province&lt;/code&gt;||{{#if:{{{province|}}}|&lt;code&gt;{{data {{{province}}}|linkd}}&lt;/code&gt;}}||province, if ''type'' is lower than &quot;province&quot;
 |-
 | &lt;code&gt;popbase&lt;/code&gt;
 | {{#if:{{{popbase|}}}|&lt;code&gt;{{formatnum:{{{popbase}}}}}&lt;/code&gt;}}
 | population on a given date (stored without commas)
 |-
 | &lt;code&gt;popbaseyear&lt;/code&gt;
 | {{#if:{{{popbaseyear|}}}|&lt;code&gt;{{{popbaseyear}}}&lt;/code&gt;}}
 | year for which the population base figure applies
 |-
 | &lt;code&gt;popbasemonth&lt;/code&gt;
 | {{#if:{{{popbasemonth|}}}|&lt;code&gt;{{{popbasemonth}}}&lt;/code&gt;}}
 | month for which the population base figure applies
 |-
 | &lt;code&gt;popbaseday&lt;/code&gt;
 | {{#if:{{{popbaseday|}}}|&lt;code&gt;{{{popbaseday}}}&lt;/code&gt;}}
 | day for which the population base figure applies
 |-
 | &lt;code&gt;popinc&lt;/code&gt;
 | {{#if:{{{popinc|}}}|&lt;code&gt;{{{popinc}}}&lt;/code&gt;}}
 | population increase per day; used to extrapolate the population figure
 |-
 | &lt;code&gt;land area&lt;/code&gt;
 | {{#if:{{{land area|}}}|&lt;code&gt;{{formatnum:{{{land area}}}}}&lt;/code&gt;}}
 | land area in km&lt;sup&gt;2&lt;/sup&gt; (stored without commas)
 |-
 | &lt;code&gt;total area&lt;/code&gt;
 | {{#if:{{{total area|}}}|&lt;code&gt;{{formatnum:{{{total area}}}}}&lt;/code&gt;}}
 | total area in km&lt;sup&gt;2&lt;/sup&gt; (stored without commas)
 |-
 |&lt;code&gt;flag image&lt;/code&gt;
 | {{#if: {{{flag image|}}}|&lt;code&gt;{{{flag image}}}&lt;/code&gt;}}
 |name of the flag image (or other illustration, if there is no flag) shown above
 |}
 Throughout the family of templates, fixed names are used for the parameters. (The parameter names are kept short to reduce counts for the [[Wikipedia:Template_limits#Post-expand_include_size|post expand include size]] and the [[Wikipedia:Template_limits#Template_argument_size|template argument size]] in cases where these are applicable.) However, not necessarily all parameters have been given a value: some parameters may not be applicable, while for some other parameters the value may just have not been specified yet. The table shows all parameters, and for each the value, if specified. 
 
 {{#if: {{{related1|}}} |
 ===Related templates===
 Please see the following related &lt;code&gt;country_data&lt;/code&gt; templates:
 * [[Template:Data {{{related1}}}]]&lt;span style=&quot;position:absolute; left:32em;&quot;&gt;{{flag|{{{related1}}}}}&lt;/span&gt;&lt;!--
 --&gt;{{#if: {{{related2|}}} |
 * [[Template:Data {{{related2}}}]]&lt;span style=&quot;position:absolute; left:32em;&quot;&gt;{{flag|{{{related2}}}}}&lt;/span&gt; }}&lt;!--
 --&gt;{{#if: {{{related3|}}} |
 * [[Template:Data {{{related3}}}]]&lt;span style=&quot;position:absolute; left:32em;&quot;&gt;{{flag|{{{related3}}}}}&lt;/span&gt; }}&lt;!--
 --&gt;{{#if: {{{related4|}}} |
 * [[Template:Data {{{related4}}}]]&lt;span style=&quot;position:absolute; left:32em;&quot;&gt;{{flag|{{{related4}}}}}&lt;/span&gt; }}&lt;!--
 --&gt;{{#if: {{{related5|}}} |
 * [[Template:Data {{{related5}}}]]&lt;span style=&quot;position:absolute; left:32em;&quot;&gt;{{flag|{{{related5}}}}}&lt;/span&gt; }}&lt;!--
 --&gt;}}
 
 ==Related data templates==
 {{#if:{{{continent|}}}|*{{#ifeq:[[:Template:Data {{{continent}}}]]|{{Template:Data {{{continent}}}}}|[{{fullurl:Template:Data {{{continent}}}|action=edit&amp;preload=Template:Data/preload}} {{{continent}}}]|[[Template:Data {{{continent}}}]]}}}}
 {{#if:{{{country|}}}|*{{#ifeq:[[:Template:Data {{{country}}}]]|{{Template:Data {{{country}}}}}|[{{fullurl:Template:Data {{{country}}}|action=edit&amp;preload=Template:Data/preload}} {{{country}}}]|[[Template:Data {{{country}}}]]}}}}
 {{#if:{{{province|}}}|*{{#ifeq:[[:Template:Data {{{province}}}]]|{{Template:Data {{{province}}}}}|[{{fullurl:Template:Data {{{province}}}|action=edit&amp;preload=Template:Data/preload}} {{{province}}}]|[[Template:Data {{{province}}}]]}}}}
 
 ==Derived data==
 {{if||{{{popinc|}}}|The population today is {{formatnum:{{#expr:{{data {{{1}}}|poptoday}}round-4}}}}.&lt;ref&gt;Estimated by extrapolation.&lt;/ref&gt;
 
 }}{{if||{{{popbase|}}}|The population is {{ppm|{{sigdig|({{{popbase}}}{{#if:{{{popinc|}}}|+{{{popinc}}}*{{age in days|{{{popbaseyear}}}|{{{popbasemonth}}}|{{{popbaseday}}}}}}})/{{worldpop}}|3}}}} of that of the world.{{if|eq|{{{type}}}|country| It is {{#expr:({{{popbase}}}{{#if:{{{popinc|}}}|+{{{popinc}}}*{{age in days|{{{popbaseyear}}}|{{{popbasemonth}}}|{{{popbaseday}}}}}}})/{{data {{{continent}}}|{{#if:{{data {{{continent}}}|pst2|popinc}}|{{#ifeq:{{padleft:|1|{{data {{{continent}}}|pst2|popinc}}}}|{|pst2|poptoday}}|pst2}}|popbase}}*100round1}}% of that of {{{continent}}}.}}{{if|eq|{{{type}}}|province| It is {{#expr:({{{popbase}}}{{#if:{{{popinc|}}}|+{{{popinc}}}*{{age in days|{{{popbaseyear}}}|{{{popbasemonth}}}|{{{popbaseday}}}}}}})/{{#iferror:{{data {{{country}}}|poptoday}}|{{data {{{country}}}|pst2|popbase}}}}*100round1}}% of that of {{{country}}}.}}{{if|eq|{{{type}}}|municipality| It is {{#expr:{{{popbase}}}/{{data {{{province}}}|pst2|popbase}}*100round1}}% of that of {{{province}}}.}}
 
 }}{{if||{{{total area|}}}|The total area is {{convert|{{{total area}}}|km2}}. It is {{ppm|{{sigdig|({{{total area}}}/{{data world|pst2|land area}})|3}}}} of the land area of the world.{{if|eq|{{{type}}}|country| It is {{#expr:({{{total area}}})/{{data {{{continent}}}|pst2|total area}}*100round1}}% of that of {{{continent}}}.}}{{if|eq|{{{type}}}|province| It is {{#expr:({{{total area}}})/{{data {{{country}}}|pst2|total area}}*100round1}}% of that of {{{country}}}.}}{{if|eq|{{{type}}}|municipality| It is {{#expr:{{{total area}}}/{{data {{{province}}}|pst2|total area}}*100round1}}% of that of {{{province}}}.}}
 
 }}{{if||{{{land area|}}}|The water area is {{#expr:(1-{{{land area}}}/{{{total area}}})*100round1}}% of the total area.
 
 }}{{if||{{{popbase|}}}|{{if||{{{land area|}}}|The population density is {{convert|{{#expr:({{{popbase}}}{{#if:{{{popinc|}}}|+{{{popinc}}}*{{age in days|{{{popbaseyear}}}|{{{popbasemonth}}}|{{{popbaseday}}}}}}})/{{{land area}}}round1}}|/km2|1}} land area.
 
 |{{if||{{{total area|}}}|The population density is {{convert|{{#expr:({{{popbase}}}{{#if:{{{popinc|}}}|+{{{popinc}}}*{{age in days|{{{popbaseyear}}}|{{{popbasemonth}}}|{{{popbaseday}}}}}}})/{{{total area}}}round1}}|/km2|1}} total area.
 
 }}}}}}
 
 ==Retrieval of data items==
 &lt;code&gt;&lt;nowiki&gt;{{data&lt;/nowiki&gt; {{{1}}}&lt;nowiki&gt;|pst2|land area}}&lt;/nowiki&gt;&lt;/code&gt;, using parameter selection template [[Template:Pst2]], gives the parameter ''land area'', etc.
 
 For retrieval of more data items it is more efficient to prepare a template for that, to be used as follows:
 
 &lt;code&gt;&lt;nowiki&gt;{{data&lt;/nowiki&gt; {{{1}}}&lt;nowiki&gt;|&lt;/nowiki&gt;&lt;/code&gt;''template name''&lt;code&gt;&lt;nowiki&gt;|..|..|..|..}}&lt;/nowiki&gt;&lt;/code&gt;
 
 so that this data template needs to be called only once.&lt;ref&gt;See the first two rows of the first table in [[m:Help:Array#Summary of counts for template limits]].&lt;/ref&gt; The default template is [[Template:Show  data]], producing this page.
 
 The four parameters are optional, they are passed on to the prepared template as parameters 2-5.
 
 Special templates:
 *[[Template:Linkd]] - link to article
 *[[Template:Poptoday]] - used above
 *[[Template:Popdens]] - for use on the page [[List of sovereign states and dependent territories by population density]]
 *[[Template:Poptoday 1]] - for use on the page [[List of countries by population]]
 *[[Template:Popareadens]] - for use on the page [[List of countries by population]]
 
 A parameter being undefined or empty typically means the same, see below. &lt;code&gt;&lt;nowiki&gt;{{data ..|pst2|..}}&lt;/nowiki&gt;&lt;/code&gt; gives the empty string and the text &quot;&lt;code&gt;&lt;nowiki&gt;{{{..}}}&lt;/nowiki&gt;&lt;/code&gt;&quot;, respectively. Therefore an application checking the parameter has to check both. Checking whether a result is equal to e.g. the text &quot;&lt;code&gt;{{{popinc}}}&lt;/code&gt;&quot; cannot be done directly with #ifeq in a template which itself has also a parameter with that name, because if that is defined, there would be a comparison with the value instead of the text itself. Instead, it can be checked whether the first character of the result is &quot;&lt;code&gt;{&lt;/code&gt;&quot;, e.g.: &lt;code&gt;&lt;nowiki&gt;{{#ifeq:{{padleft:|1|{{data {{{continent}}}|pst2|popinc}}}}|{|..|..}}&lt;/nowiki&gt;&lt;/code&gt;.
 
 ==Creating new data templates==
 [[Template:Data/preload]] can be used to create new data templates. On the page of the data template of a province, if there is no data template yet for the country, a link appears to create that, preloading this template. Otherwise the wikitext can be copied to the new data template. For parameters which are not applicable, such as ''country'' for a country, the parameter definition &quot;country=&quot; can be deleted. For parameters to be filled in later the parameter definition like &quot;popinc=&quot; (specifying the empty string as value) can be left in the wikitext to be filled in later. Do not forget parameter 1.
 
 ==Efficiency==
 In this template system each template contains various properties of a single entity, as opposed to the other common system, where a template contains one property (e.g. population or area) of many entities. Although that other system can be convenient if updates of a property for all these entities become available together, in the case of large-scale use of data on one page that other system can be problematic due to its inefficiency. This is because of the following:
 *There are often more entities than properties, and [[wp:template limits|page counts]] (or in the case of &lt;code&gt;#switch&lt;/code&gt;, average page counts) are proportional to the number of data items in the data template (if they are stored in a linear way, not in a tree, and not stored as unnamed parameters).
 *In the case of large-scale use of data on one page there are usually one or more tables, where an entity  forms a row and a property a column, because there are often more entities than properties, and because this way the sorting feature allows sorting entities based on a property. In this template system this allows producing a row with only one call of the data template, making the count not grow faster than proportional to the average number of data items stored per data template, times the number of entities in the table.
 
 The include part of the data template of an entity does not contain a long list of its sub-entities or their properties, because that would make this method inefficient too.  
 
 {{reflist}}
 &lt;includeonly&gt;[[Category:Data templates|{{if||{{{country|}}}|{{{country}}} {{{1}}}|{{if|eq|{{{type}}}|continent| {{{1}}}|{{if|eq|{{{1}}}|world| |{{{1}}}}}}}}}]]&lt;/includeonly&gt;&lt;noinclude&gt;[[Category:Data retrieval templates]]&lt;/noinclude&gt;
 
 Until here the documentation is automatically generated by [[Template:Show data]].
 
 &lt;noinclude&gt;
 {{documentation}}