In the past decades, the electric power grid in Mexico was a centralized system compounded by the primary subsystems of generation, transmission and distribution. This traditional system used to work in a vertical way (generation-transmission-distribution) with unidirectional power flows and power plants located far away from the loads. However the pursuit of more resilient and sustainable systems has driven the growing integration of distributed generation, especially with renewable energy resources. Particularly, microgrids, that allow locally matching demand and generation, can contribute positively to this issues and may play a key role in the new paradigm of decentralized power systems. Among others, microgrids offer the promise of many positive effects such as reduced electrical losses, increased security and flexibility, and integration of renewable energies, which also results in a more resilient system and reduced carbon emissions. In our particular case, photovoltaic generation is proposed due to its easy access to potential users and because most of the worldwide population is concentrated in the greatly insolated "sunbelt" regions of the world, located in between the 35º North and South parallels, which includes Mexico, large Asian regions in China and India as well as the southwestern United States, southern Europe, Australia, the MENA regions, etc.This work proposes a theoretical strategy to study microgrids configuration and performance in Mexican urban environments evaluating compliance of two Mexican standards for electric power distribution systems at domestic level related to network size (in number of nodes) and spatial size (in meters). In doing so, we bring together the unique aspects of computer science tools, power flow equations, and real consumption and generation data, taking a cross-disciplinary approach between power systems and renewable energies engineering; data science and statistical mechanics. The algorithm developed for this work has been coded in Mathematica and it generates a statistical ensemble of the microgrids properties, the inputs are geographical buildings coordinates and real consumption data.Basically, the buildings geographical coordinates were taken from Google Earth images and considered as nodes for the power grid. We defined the microgrids applying to the complete set of nodes four different clustering methods such as k-means, k-medoids, spectral and agglomerate. Every cluster was considered as a microgrid. Then, a travelling salesman algorithm is applied to find the optimal wiring configuration for each microgrid; and an analysis and comparison of the statistical properties of network and spatial sizes takes place. According to the Federal Electrical Commission standards at domestic level, no more than 35 houses can be connected to the same transformer and the one that is far away from the source cannot need more than 80m of wire to be connected to it. Therefore, what we look for is to find the optimal size and clustering method that better complies the aforementioned standards. After size and clustering method are selected, power flow equations are solved and voltage regulation is evaluated for microgrids, both evaluating the base case scenario without any distributed generation and with solar PV as distributed energy resource, assuming that the loads are equipped with a smart architecture that is capable of managing bidirectional flows in the microgrid.The algorithm was feeded with the coordinates of 17,131 buildings located in Temixco, Morelos. Due to its geographical distribution and concerning to meet the spatial size standard of 80m, for all the 4 methods, microgrids of 5 nodes reported the best results for both network and spatial size parameters against bigger microgrids. Also, the best method was k-means, were mean network size was 5 with a standard deviation of 2.64; and reporting an average wiring need of 77.91m with a standard deviation of 91.98m, in comparison with the k-medoids where the network standard deviation was 2.68 , needing 76.71m of wire in average and with a standard deviation of 87.69m. Spectral and agglomerate methods presented greater deviations. For instance, 5 nodes k-means formed microgrids were selected to evaluate its electrical performance.For the non-solar powered microgrids, the worst case scenario was the one that needed more wiring, 1.87km to be exact, with a 34.68% voltage drop reported. In average, a 0.61% voltage drop was found for all the microgrids. In the other hand, for the solar-powered microgrids, voltage drops reported decreased and the average voltage drops reported were 0.22%. The worst case scenario in this case was again, the 1.87km microgrid, with a 16.89% voltage drop, showing that distributed solar generation helps decreasing voltage regulation value, hence, improving the ability of our microgrid to provide near constant voltage over the load conditions.Currently, this work is still in progress. So far we have presented a basic study on the performance of solar-powered urban microgrids against non solar-powered ones for a representative part of Temixco, Morelos. The proposed model captures some essential requirements and characteristics of microgrids such as spatial constraints and power flow equations, with an idealised network configuration. Our aim is to design an optimization algorithm for the electrical microgrids performance.There are many ways this work can be extended. The same study can be replicated to other cities in order to generate unique statistical ensembles of the microgrids properties from other parts in the world. Also, data on actual distribution grid topologies can easily be incorporated in order to analyse its performance. Furthermore, within the scope of this work, we have limited ourselves to only solar generation without being coupled to any electrical storage, therefore further models of solar-powered urban microgrids can incorporate grid storage elements. Likewise, in additional microgrid models, different distributed generation sources can be incorporated.