Inﬂuence of the Population Density of Cities on Energy Consumption of Their Households

: 36% of the energy consumed and 40% of emissions are due to buildings in the residential and tertiary sectors. These antecedents have forced governments to focus on saving energy and reducing emissions in this sector. To help government decision-making and facilitate energy planning for utilities, this work analyzes the energy consumption that occurs in city buildings. The information used to carry it out is publicly accessible. The study is carried out from the point of view of the population density of the cities, and these are analyzed individually. Furthermore, the area actually occupied by the city has been considered. The results are studied by inhabitant and household. The proposed method has been applied to the case of Spanish cities with more than 50,000 inhabitants. The results show that the higher the population density, the higher the energy consumption. This occurs both per inhabitant and per household. Furthermore, the consumption of electrical energy is inelastic, which is not the case with the consumption of thermal origin.


Introduction
Energy is responsible for more than 80% of greenhouse gas (GHG) emissions, with transport corresponding to only a third [1]. Thirty six percent of the energy consumed and 40% of emissions are due to buildings in the residential and tertiary sectors [2]. In them, the usual form of energy consumption is through electricity and natural gas for thermal consumption [3].
Therefore, cities are the most important centers for the consumption of energy and the production of polluting emissions. Being aware of this, the European Union created the Covenant of Mayors. Subsequently, it changed its name to Climate & Energy to integrate mayors from 8000 cities from 53 countries around the world. Among its objectives is to achieve access to affordable and sustainable energy for all citizens [4].
Currently, and because cities have been the main areas affected by the COVID-19 pandemic [5], the European Union has launched a EUR 750 billion recovery plan for COVID-19 [6] with six fields of action, one of which is construction and buildings [7].
For all the above, cities in general and their buildings in particular take a leading role for governments and utilities. In the case of the former, to establish laws that favor the reduction of consumption and emissions; in the latter, to plan the infrastructures that allow the growth of energy consumption, if possible, through renewable energy sources. Therefore, it is essential to know the relationship between energy and urbanization to achieve sustainable cities.
For this reason, this paper studies the energy consumption of buildings. All the buildings have been considered, and their consumption has been distributed among their inhabitants, including non-residential ones. This is so because non-residential buildings are used by the inhabitants of a city and exist in greater or lesser numbers depending on the population of it.
The methodology used in the study, based on statistical analysis, is similar to others that, although classic, are still being used recently and use information from statistical databases [8][9][10][11][12] and on others that are based on the creation of synthetic populations [13]. Thus, the population of cities is represented in a simplified way from aggregated public data.
The main contributions of this paper are: analyze energy consumption of city buildings based on population density; study the behavior of the cities of a country separately, and not in an aggregate way; analyze the results by household and by inhabitant; and apply the method to the case of Spanish cities with more than 50,000 inhabitants. To the authors' knowledge, a similar investigation has not been carried out previously. With all this, it is intended that both utilities and governments have detailed knowledge of the behavior of cities based on their population density.
The article is structured as follows: Section 2 presents studies that relate energy in cities with the population density; Section 3 describes the proposed method, based on the use of public information; the application to the case of Spanish cities is presented in Section 4; the results, per inhabitant and household, are presented and discussed in Section 5; finally, Section 6 summarizes the findings of the study.

Literature Review
Utilities and governments are paying increasing attention to cities in general, and their buildings in particular, as focuses to reduce energy consumption. Therefore, this study investigates from the point of view of population density. Despite the importance that population density is acquiring in cities, this approach has been little analyzed [14]. Instead, the buildings have been analyzed individually: hotels [15], houses [16]; or the urban heat island generated [17]; or the relationship between transport and population density from the point of view of energy consumption [18].
Studies that analyze the population of cities have been carried out taking into account urbanization or population density. The most numerous are the first. They analyze the percentage of urban population with respect to the total national population. These give a general idea of the influence of migration from rural to urban areas. In addition, they usually refer to large areas, as is the case in the country-level analysis: Brazil [19], the USA [20], CIVETS countries, namely, Colombia, Indonesia, Vietnam, Egypt, Turkey, and South Africa [21], or 72 countries [22]. However, they do not provide information at the city level.
In general, the published works that analyze energy consumption focus on calculating the forecast of electricity demand at the country level, as is the case of Turkey [23], Spain [24], or Greece [25]; or at the level of the residential sector in some countries [26]. Studies that take natural gas into account usually also predict demand. This is the case of Pakistan [27], Bangladesh [28], or Bahrain, Saudi Arabia, Syria, and the United Arab Emirates [29]; or also at the residential level [30].
Using population density as a study variable, information can be obtained from a more specific area. This variable considers people by land area. In this way, it can be analyzed in more detail from a country [31] to a city [32] and is more appropriate for smaller areas. However, studies usually include the area occupied by the entire municipality and not just the area occupied by the populated area. Therefore, the population density that is calculated is that corresponding to the inhabitants who live in a certain city with respect to the entire area of the municipality, although a significant part of that area is neither inhabited nor has services for its inhabitants. However, from the authors' point of view, this is not valid for a detailed study of the influence of population density on certain magnitudes such as those analyzed in this study. On the contrary, the area considered must be that actually occupied by population.
The works that analyze the influence of population density do so considering the total energy. Therefore, they also include transport, so the influence of buildings is not specifically analyzed, despite being one of the main consumers of energy and producers of emissions [33].
Regarding the works that analyze energy consumption in buildings, they focus on a specific sector. Thus, in the electricity consumed in the residential sector, it increases when they do household income and number of rooms. In the study carried out in Malysia on a sample of 620 urban households, the average consumption was determined [34]. Depending on the urban density, the energy consumption increases up to a certain value, and from there it hardly has any influence. In the specific case of the study carried out in 29 provinces of China, this value is 808 inhabitants per square kilometer. In addition, other variables were used, such as economic development or urbanization. In the case of this last variable, the urbanization rate increased above 55.31%; below this value, residential energy consumption decreased [35]. In the service sector, consumption per inhabitant is lower as density increases. This efficiency is justified by the higher factor productivity [36].
At the country level, in Kenya the possible drivers of energy consumption have been studied. Among them are population density and urbanization. In this case, while population density and urbanization reduce energy consumption, electricity consumption increases [37]. Something similar happens in China: as population density increases, energy consumption increases, while just the opposite occurs with urbanization [38]. However, in Canada the opposite is true. The electricity consumption of all sectors, except industrial, is analyzed and six predictors are used. Among them, population density is one of the determining factors. As a conclusion, it is obtained that when the population density is higher, the electricity consumption per capita is lower [39]. In addition, in a study of 93 countries, the results were found to be completely different from country to country [40].
Therefore, of the studies that analyze energy consumption, there are very few that relate energy consumption in buildings with population density. Not only that, but they also do not even consider a very important energy source, natural gas. Hence, the need to know more precisely the influence that population density has on energy consumption, in the case of this article, by applying the proposed method to the specific case of Spain.

Materials and Methods
The phases of the proposed method are as follows: first, the study area must be defined; second, the criteria for selecting the cities in that area are defined; third, cities must be classified according to density of inhabitants; and fourth, the consumption per inhabitant and per household in the buildings must be obtained.
The data used for the study should come from public databases and, whenever possible, should be of government origin. All this information must be properly processed to obtain the desired results. In this way, with the information on the energy consumed, it will be possible to implement specific measures that favor the reduction of consumption in each city and implement renewable energy sources that cover the growth in demand in each city and reduce their emissions. A methodological approach of the proposed method is shown in Figure 1. specifically analyzed, despite being one of the main consumers of energy and producer of emissions [33].
Regarding the works that analyze energy consumption in buildings, they focus on a specific sector. Thus, in the electricity consumed in the residential sector, it increases when they do household income and number of rooms. In the study carried out in Malysia on a sample of 620 urban households, the average consumption was determined [34]. Depend ing on the urban density, the energy consumption increases up to a certain value, and from there it hardly has any influence. In the specific case of the study carried out in 2 provinces of China, this value is 808 inhabitants per square kilometer. In addition, othe variables were used, such as economic development or urbanization. In the case of thi last variable, the urbanization rate increased above 55.31%; below this value, residentia energy consumption decreased [35]. In the service sector, consumption per inhabitant i lower as density increases. This efficiency is justified by the higher factor productivity [36].
At the country level, in Kenya the possible drivers of energy consumption have been studied. Among them are population density and urbanization. In this case, while popu lation density and urbanization reduce energy consumption, electricity consumption in creases [37]. Something similar happens in China: as population density increases, energy consumption increases, while just the opposite occurs with urbanization [38]. However in Canada the opposite is true. The electricity consumption of all sectors, except industrial is analyzed and six predictors are used. Among them, population density is one of th determining factors. As a conclusion, it is obtained that when the population density i higher, the electricity consumption per capita is lower [39]. In addition, in a study of 93 countries, the results were found to be completely different from country to country [40] Therefore, of the studies that analyze energy consumption, there are very few tha relate energy consumption in buildings with population density. Not only that, but they also do not even consider a very important energy source, natural gas. Hence, the need to know more precisely the influence that population density has on energy consumption in the case of this article, by applying the proposed method to the specific case of Spain.

Materials and Methods
The phases of the proposed method are as follows: first, the study area must be de fined; second, the criteria for selecting the cities in that area are defined; third, cities mus be classified according to density of inhabitants; and fourth, the consumption per inhab itant and per household in the buildings must be obtained.
The data used for the study should come from public databases and, whenever pos sible, should be of government origin. All this information must be properly processed to obtain the desired results. In this way, with the information on the energy consumed, i will be possible to implement specific measures that favor the reduction of consumption in each city and implement renewable energy sources that cover the growth in demand in each city and reduce their emissions. A methodological approach of the proposed method is shown in Figure 1.  Certain factors can influence energy consumption in cities. For example, the type of housing, the age of its construction, its orientation, the orographic characteristics of its surroundings, the climatic zone in which it is located, etc. However, their elimination is beyond the scope of this study. Therefore, the possible influence that they could have remains within the study.

Classification of Cities by Population Density
First, the area to study must be defined. Its size will depend on the scope of the study to be carried out. Next, the cities in that area must be selected. The selection will be made depending on the criteria of interest. These criteria can be the number of inhabitants, the energy consumed, the saturation of its infrastructure, its emissions, its growth rate, or any other that is of interest. From there, each city is represented by its population density and a segmentation can be defined.
To perform the analysis, the main statistical data of electric, thermal, and total energy consumptions for each group of cities are studied: Standard deviation : Median : th term if the total number of the elements is an Minimum : where n i is the number of cities that belong to group i; E i is the mean energy consumed in group i; E ij is the energy consumption of city j, which is located in group i; s i is the standard deviation of the energy consumed in the cities of group i; the energy consumed will be thermal, electric or total depending on the case study; and cities consumptions should be listed in ascending order to calculate the median. An index analogous to that defined in [41] is used to analyze the energy consumption of cities. The density variation index (DVI) is defined as: where DV I i is the index of the group of cities that have size i, E i is the energy consumption mean value of group i and E is the mean energy consumption of all cities (of all groups).
With it, the consumption of the groups can be easily compared.

Population Density of Cities
To calculate the population density, it is necessary to identify the study area. One criterion is to consider the one that corresponds to the entire municipality of the city (this is the commonly used criterion). However, according to the authors, this is not the appropriate option. In certain cases, the city occupies the entire land area of the municipality; this usually happens in those highly populated cities with very little land area. However, usually the area of the municipality is greater than what the population occupies. Therefore, the whole area of the city municipality should not be considered, but only that which is actually populated. To do this, only the area occupied by buildings must be considered and not the rest. This surface can be continuous or discontinuous (depending on their housing scheme: single family houses or high-rise dwelling, city center of suburb). This is the criterion that will be followed in the study: only the surface occupied by buildings will be considered, and this can be continuous or discontinuous. Therefore, the area considered is that occupied by continuous and discontinuous urban fabric [42].

Electric and Thermal Energy Consumption
To analyze energy consumption in cities, only that corresponding to buildings has been considered. That of industries has not been considered, nor that of means of transport. However, not only energy consumption in residential buildings has been considered, but also that of tertiary sector buildings. This is due to a double reason: on the one hand, the official data provided does not usually distinguish between whether the supply points correspond to residential, commercial, or administrative offices; and on the other, the rest of non-residential buildings in a city exist to serve its inhabitants, and their number is greater or lesser depending on the number of its inhabitants. For this reason, the study is carried out considering the energy consumption of all these buildings and is distributed among the inhabitants of each city.
Population and consumption data by city are used to calculate thermal and electrical consumption. In addition, they must be disaggregated from the information usually provided by public bodies. For electricity consumption, the classification of the Statistical Classification of Economic Activities in the European Community, commonly referred to as NACE (for the French term "nomenclature statistique des activités économiques dans la Communauté européenne") is used [43]. The  For thermal consumption, the information corresponding to supply points with a pressure equal to or less than 4 bar and a consumption between 5000 and 50,000 kWh per year is used. These points are those that usually correspond to homes, stores, public administrations, and services.

Application of the Method to the Case of Spain
An example of application of the proposed method is presented in this section. As a study area, the whole of Spain is considered. In it, cities with more than 50,000 inhabitants have been selected. They represent more than 50% (24.5 million) of the 46.5 million inhabitants it has. The data used correspond to 2016. The results of the study will allow detailed knowledge of energy consumption, which will favor decision-making and the assessment of infrastructures that allow supplying energy demand and its growth.

Classification of Spanish Cities
To carry out the classification of cities according to their density, it is necessary to know the population [44] and the area of each one of them [45].
The number of cities that meet the criteria of having more than 50,000 inhabitants is 145. From the public information available, their density, electricity and thermal consumption in the form of natural gas in their buildings and their emissions have been calculated.
Based on density, cities have been segmented into five groups. For this, the number of inhabitants per hectare has been calculated, being 1 hectare 10,000 square meter. Group 1 is made up of cities with a density lower than 100 inhabitants/hectare; Group 2, for those whose density is greater than or equal to 100 and less than 200; Group 3, for cities with a density greater than 200 and less than 300 inhabitants/hectare; Group 4 has a density between 300 and 400; and Group 5 is made up of cities with a density greater than 400 inhabitants/hectare. Table 1 shows the segmentation of the cities ordered alphabetically. Although the influence of external factors has not been eliminated, it must be mentioned that the climate is one of those that may be of greater importance. That is why, to have a vision of the types of climates in which cities are located, Figure 2 shows the types of climates in Spain and the number of cities studied that are in each of them [41]. between 300 and 400; and Group 5 is made up of cities with a inhabitants/hectare. Table 1 shows the segmentation of the cities Although the influence of external factors has not been elim tioned that the climate is one of those that may be of greater imp have a vision of the types of climates in which cities are located, of climates in Spain and the number of cities studied that are in e

Thermal and Electric Energy Consumption
To obtain the consumption of thermal and electrical energy, information from the Ministry of Economic Affairs and Digital Transformation and the Ministry for Ecological Transition and Demographic Challenge has been used: Spanish National Statistics Insti-  [48].

Sample of Study
The energy consumption in the buildings of the 145 Spanish cities with more than 50,000 inhabitants have been studied. The buildings are those corresponding to households, government agencies, and tertiary sectors. Consumption is that usually used in buildings: thermal in the form of natural gas and electricity. The data used are public and from official sources, although properly processed. The cities have been segmented into five groups according to Table 1. Figure 3 presents the number of cities in each group. The most numerous groups are the two with the lowest population density. Each of them represents almost 40% of cities. The rest of the groups only represent 22% and as the density increases, the number of cities decreases. Thus, the group of cities with the highest density barely represents 3%. However, of the number of inhabitants, Group 2 is the largest, with 32% of the total. Groups 3 and 1 follow with more than 25%. The one with the lowest number of inhabitants is Group 5, with only 2% (Figure 4). stainability 2021, 13, x FOR PEER REVIEW from official sources, although properly processed. The cities have be five groups according to Table 1. Figure 3 presents the number of cities in each group. The most num the two with the lowest population density. Each of them represents al The rest of the groups only represent 22% and as the density increas cities decreases. Thus, the group of cities with the highest density bar However, of the number of inhabitants, Group 2 is the largest, with Groups 3 and 1 follow with more than 25%. The one with the lowest num is Group 5, with only 2% (Figure 4).   Table 2 shows the main statistical data of the households and p group. The first column shows each of the groups into which the ana vided, and each of its rows contains its statistical data. The conclusions a indicated. ustainability 2021, 13, x FOR PEER REVIEW from official sources, although properly processed. The cities have been s five groups according to Table 1. Figure 3 presents the number of cities in each group. The most numero the two with the lowest population density. Each of them represents almos The rest of the groups only represent 22% and as the density increases, cities decreases. Thus, the group of cities with the highest density barely However, of the number of inhabitants, Group 2 is the largest, with 32% Groups 3 and 1 follow with more than 25%. The one with the lowest number is Group 5, with only 2% (Figure 4).   Table 2 shows the main statistical data of the households and popu group. The first column shows each of the groups into which the analysi vided, and each of its rows contains its statistical data. The conclusions are s indicated.  Table 2 shows the main statistical data of the households and population of each group. The first column shows each of the groups into which the analysis has been divided, and each of its rows contains its statistical data. The conclusions are similar to those indicated.  Table 3 shows, in each of its rows, the statistical data of the total consumption of each group, in MWh per year. The highest consumptions are produced in Groups 2 and 3, with almost identical consumptions, even though Group 2 has almost 15% more inhabitants. They are followed by Group 1 with a 36% lower consumption, although its number of inhabitants is only 11% lower. Group 5 is the one with the lowest consumption.

Total Energy Consumption
From the point of view of electricity consumption, the behavior is similar. However, the consumption of Group 2 is 12% higher than that of Group 3, even though the total consumption of both groups was almost identical. Regarding thermal consumption, Groups 2 and 3 have a behavior contrary to that presented in electricity consumption: Group 3 is the one with the highest consumption, followed by Group 2. The rest of the groups follow a similar behavior.
Graphically, Figure 5 presents the total, thermal and electrical consumption of each group in GWh per year. The consumptions that a group of average values would present are also shown. It can be observed that, at the level of total consumption, Groups 2 and 3 have higher consumption than the average value, while Groups 4 and 5 have lower consumption; Group 1 has a total consumption almost identical to the average value. Therefore, when analyzing this figure and relating it to Figure 3; Figure 4 of the number of cities and inhabitants per group respectively, it is not possible to draw a conclusion about the trend that exists in the global consumption of each group. Global consumption does not follow a trend proportional to the number of cities per group or of inhabitants. Regarding electrical and thermal consumption, the behavior is similar to that described, except in Group 1, which in the case of electrical consumption is above the average value and in the case of thermal, below. tainability 2021, 13, x FOR PEER REVIEW From the point of view of electricity consumption, the behavior i the consumption of Group 2 is 12% higher than that of Group 3, ev consumption of both groups was almost identical. Regarding the Groups 2 and 3 have a behavior contrary to that presented in elect Group 3 is the one with the highest consumption, followed by Grou groups follow a similar behavior.
Graphically, Figure 5 presents the total, thermal and electrical co group in GWh per year. The consumptions that a group of average va are also shown. It can be observed that, at the level of total consumpt have higher consumption than the average value, while Groups 4 and sumption; Group 1 has a total consumption almost identical to the av fore, when analyzing this figure and relating it to Figure 3; Figure 4 of and inhabitants per group respectively, it is not possible to draw a co trend that exists in the global consumption of each group. Global con follow a trend proportional to the number of cities per group or of inh electrical and thermal consumption, the behavior is similar to that d Group 1, which in the case of electrical consumption is above the avera case of thermal, below.  Table 4 and Figure 6 show the main statistical data and the avera consumption per household, respectively. Total energy consumption   Table 4 and Figure 6 show the main statistical data and the average values of energy consumption per household, respectively. Total energy consumption increases as density increases, except between the two highest density groups, among which there is a small decrease of 2%. The group with the lowest density, Group 1, is the only one that has a lower value than the mean value of all the groups. While the group with the highest consumption presents a value 13% higher than the average value, the lowest is 8% below. In addition, the differences in consumption between groups are similar, none of them being much more pronounced than the rest.  Figure 6. Thermal, electric, and total mean energy consumption per househ cities.

Energy Consumptions per Household
Thermal consumption follows a similar behavior, although not difference is that the second group with the highest consumption is n Group 5, but Group 3, although with similar values between them. highest consumption is 42% higher than the average, while the gro thermal consumption is 30% lower. Therefore, the differences between are much more pronounced than in the case of the comparison in to fact, among the less dense groups the difference that exists is almost has a lower value than the value of the mean group.
Regarding electricity consumption, it is the least dense group t consumption, and Group 3 that has the lowest, with the consumptio groups being almost identical. However, the difference between the m mum consumption is only 3%. Therefore, the electrical consumption p behavior. In addition, now the opposite occurs, and only Group 1 is th than-average consumption. Thermal consumption follows a similar behavior, although not identical. The main difference is that the second group with the highest consumption is not the densest cities, Group 5, but Group 3, although with similar values between them. The group with the highest consumption is 42% higher than the average, while the group with the lowest thermal consumption is 30% lower. Therefore, the differences between the extreme groups are much more pronounced than in the case of the comparison in total consumption. In fact, among the less dense groups the difference that exists is almost 40%. Only Group 1 has a lower value than the value of the mean group.
Regarding electricity consumption, it is the least dense group that has the highest consumption, and Group 3 that has the lowest, with the consumption of the rest of the groups being almost identical. However, the difference between the maximum and minimum consumption is only 3%. Therefore, the electrical consumption presents an inelastic behavior. In addition, now the opposite occurs, and only Group 1 is the one with a higher-than-average consumption.
The DVI index defined in Equation (7) has been used to easily analyze the variations in consumption between groups. Figure 7 shows the index for the three types of consumption. Total consumption increases as population density increases, except in the group of most populated cities, in which it decreases slightly. Furthermore, this increase is relatively mild. In the case of thermal consumption, the behavior of consumption is similar to the total. However, the differences are much more pronounced, reaching 70% between the extremes. Regarding electricity consumption, it is similar in all groups, with a minimal difference between all of them.  Table 5 shows the statistical data of the consumption per inhabit mean values of each group and the mean consumption of all the group As density increases, per capita consumption increases, up to a den and 400 inhabitants/hectare, Group 4. The four cities that make up highest density, Group 5, have consumption identical to Group 3. The in consumption between groups occurs between the one correspondin sity group, Group 1, and the next, reaching 15%. Among the rest of th ence in consumption only oscillates 5%. The only group with a value l value is Group 1. As conclusion: the higher the population density in the cities, the higher the consumption, except in the four cities with the highest density, in which it decreases slightly; and the electrical consumption is almost inelastic, whereas the thermal one is not. Furthermore, although the increase in total consumption between groups is approximately homogeneous, the growth in thermal consumption is not. In fact, a very significant increase occurs among the groups with the lowest density. Table 5 shows the statistical data of the consumption per inhabitant and Figure 8 the mean values of each group and the mean consumption of all the groups, in MWh per year. As density increases, per capita consumption increases, up to a density of between 300 and 400 inhabitants/hectare, Group 4. The four cities that make up the group with the highest density, Group 5, have consumption identical to Group 3. The greatest difference in consumption between groups occurs between the one corresponding to the lowest density group, Group 1, and the next, reaching 15%. Among the rest of the groups, the difference in consumption only oscillates 5%. The only group with a value lower than the mean value is Group 1.

Energy Consumptions per Inhabitant
Thermal consumption is similar to total consumption. Group 4 is the one with the highest consumption, with Group 3 being the next. However, the difference between the three densest groups is barely 5%. The one with the lowest consumption is Group 1, which is also the only one that has a value lower than the average of the groups. In this case, the differences in consumption between groups are more pronounced. Thus, the difference between the extreme groups reaches over 70%. The greatest difference occurs between Groups 1 and 2, being greater than 45%. However, the difference from the rest of the groups is just over 20%.   Thermal consumption is similar to total consumption. Group 4 is th highest consumption, with Group 3 being the next. However, the differen three densest groups is barely 5%. The one with the lowest consumption is G is also the only one that has a value lower than the average of the groups. I differences in consumption between groups are more pronounced. Thus, between the extreme groups reaches over 70%. The greatest difference o Groups 1 and 2, being greater than 45%. However, the difference from groups is just over 20%.
Regarding electricity consumption, this is similar in all groups, oscil among all. However, here it is Groups 1 and 2 that have a higher consum mean, although this is minimal.
The variation of the DVI index for all consumptions per inhabitant is sh 9. Total consumption increases with increasing population density, except four cities with the highest density. Furthermore, except in Group 1, the occurs among the other groups is 5%. However, from Group 1 to 2 there is 15%. Regarding electricity consumption, this is similar in all groups, oscillating only 4% among all. However, here it is Groups 1 and 2 that have a higher consumption than the mean, although this is minimal.
The variation of the DVI index for all consumptions per inhabitant is shown in Figure 9. Total consumption increases with increasing population density, except in the group of four cities with the highest density. Furthermore, except in Group 1, the variation that occurs among the other groups is 5%. However, from Group 1 to 2 there is a difference of 15%.  Thermal consumption is similar to total consumption. Group 4 is the highest consumption, with Group 3 being the next. However, the differenc three densest groups is barely 5%. The one with the lowest consumption is G is also the only one that has a value lower than the average of the groups. I differences in consumption between groups are more pronounced. Thus, between the extreme groups reaches over 70%. The greatest difference o Groups 1 and 2, being greater than 45%. However, the difference from groups is just over 20%.
Regarding electricity consumption, this is similar in all groups, oscil among all. However, here it is Groups 1 and 2 that have a higher consum mean, although this is minimal.
The variation of the DVI index for all consumptions per inhabitant is sh 9. Total consumption increases with increasing population density, except i four cities with the highest density. Furthermore, except in Group 1, the occurs among the other groups is 5%. However, from Group 1 to 2 there is 15%.  Regarding thermal consumption, the behavior is similar, but here the differences are again more pronounced. These differences are greater between Group 1 and 2 (reaching 45%), and between 2 and 3 (reaching 20%). Regarding electricity consumption, the behavior is almost identical in all groups. There is only a 3% variation between all of them.
The conclusions are similar to those obtained when studying households: the higher the population density, the higher the consumption, except in the cities with the highest density, where there is a slight decrease; in addition, the thermal consumption is elastic, with the electrical being practically inelastic. In addition, the differences between groups are more pronounced than those presented in consumption per household, mainly in relation to thermal consumption.

Conclusions
Eighty percent of GHG emissions correspond to CO 2 . 40% of the emissions are due to buildings in the residential and tertiary sectors. In addition, they consume 36% of the energy. Against this background, governments consider cities in general, and buildings in particular, priority centers for reducing energy consumption and emissions. Considering also that the COVID-19 pandemic has mainly affected cities, the concern of governments is evident. For all this, Covenant of Mayors and the COVID-19 recovery plan have been created.
To help governments make decisions and utilities to plan their infrastructures correctly, this paper has analyzed the energy consumption of buildings in cities. Electricity and thermal consumption in the form of natural gas have been considered. These are the forms of energy commonly consumed in buildings. The study has been carried out from the point of view of the population density of the cities. For this, the area that the city actually occupies has been considered, and not the area covered by the municipality, which always has large uninhabited areas. In addition, the energy consumption of all buildings has been considered, both for residential and tertiary use. The results have been analyzed per inhabitant and per household. Therefore, the consumption of non-residential buildings has been distributed among the inhabitants and households of the city. This has been done because cities have a greater or lesser number of tertiary sector buildings to serve their inhabitants, and they exist insofar as they are necessary for them. For ease of analysis, an index has been introduced. Information of public access has been used for the study. The case of the 145 Spanish cities with more than 50,000 inhabitants has been presented as an application of the proposed method.
The results of the total consumption of the groups do not show a relationship with respect to the number of cities in each group or with the number of inhabitants of each one of them.
The findings obtained on consumption per household show that the higher the population density in the city, the higher the consumption. However, there is an exception in the four cities with the highest density, in which consumption decreases slightly compared to the previous group. Furthermore, while total consumption has an approximately homogeneous growth among the different groups, in the case of thermal consumption such growth is very marked. Regarding electricity consumption, it hardly changes as a consequence of the variation in the density of cities. Thus, electrical consumption is almost inelastic, while thermal is quite elastic.
Regarding consumption per inhabitant, the conclusions are similar to those obtained per household. Thus, the higher the population density in the city, the higher the consumption, except in the four densest cities. The fact that electricity consumption is inelastic is also represented. However, thermal consumption is elastic and even with variations between groups much more pronounced than in the case of consumption per household.
These conclusions will allow utilities and governments to have a detailed understanding of the behavior of energy consumption in cities as a function of their density. In this way, utilities will be able to adequately plan their infrastructures and governments will issue laws that help optimize energy use in buildings.