The insufficiency of current energy sources, elevated costs and global climate worriment are distinctive factors making of renewable energy an issue of boosting consideration. In this concern, solar energy is viewed as being indefinitely environmental friendly, carbon-free, beneficial nature with appreciated cost potentials and is witnessing fast progressing. Following the Horizon 2020 climate and energy package, the volume of gases emitted by greenhouses has to be cut down by 20% by all the European Union (EU) member countries in order to enhance energy performance by 20% and raise the renewable energy rate to 20% by 2020. Solar energy on building roofs plays a crucial aspect in renewable and sustainable energy consumption of high-density human habitats. A merest energy should be allocated to provide hot water service from solar sources, as other European norms for new buildings by the Spanish Technical Building Code, similarly to other European regulation on achievement objectives. The climate zone and the overall demand of hot water in the building regulate this minimal amount needed. This manuscript use a new methodology for automatic detection of geometric patterns from aerial or space images using a Hierarchical Temporal Memory (HTM) algorithm. In this way, an automatic method for the identification of building roofs in order to assess the opportunities available to install solar thermal systems in small urban areas has been developed. As case of study: a village with 7000 inhabitants was analyzed in the South of Spain. The maximum overall accuracy obtained among the different classifications made was 98.05%, avoiding problems related to the use of images with high spatial resolution, as in the salt-and pepper noise effect. This approach contributes reducing the generated carbon and GHG emissions and open new perspectives for energy savings strategies to optimize the energy efficiency of buildings. In the case study, implementing the solar thermal systems would come out with a saving of 1.4 tons of CO2 per inhabitant. (C) 2017 Elsevier Ltd. All rights reserved.