Yes, i did think about this in the shower.
Just to put things into proportion:
This is vienna. Vienna has an area of around 400 km².

And the blue area is the area that would have to be covered by solar panels to produce enough energy for the whole city:

Source: I did the maths myself. I assumed that per person around 30 MWh of energy/year are needed. Data for this: our world in data, energy usage per person. It’s well known that 1 m² of solar panel produces around 200 Wp and that’s 200 kWh/year. So you need about 150 m² of solar cells per person. Vienna has about a million inhabitants, so that makes 150 km² of solar panels approximately.


The thing is it doesn’t need to be produced in the city. Cities are notoriously population dense. If you take into account the energy usage of the surrounding rural areas and the land area that they have, it starts to be a tiny proportion of all of the land area of a country, rather than a city.
yeah it’s sth like 1% of humanity’s total land area usage (i did that math last week). 97% of humanity’s land area usage go to agriculture
And the nice thing: mixing solar panels and agricultural land use can increase crop yields depending on the plant!