From a worldbuilding project I did –
- Population of megacity I worldbuilt: 502.72 million (bigger than the USA)
- Area of megacity I worldbuilt: 20108.8km² (comparable to one of Ireland's four provinces)
- Population density of city I worldbuilt = 25,000/km² (Comparable to Manhattan's 28,873.0/km²)
The megacity can be modelled as having six different population densities
1. PARKS AND WATER
40% of that area is parks and lakes. (FORTY PER CENT! Has ZERO population!)
8043.52km² area, 0 population
2. ECOVILLAGES (or leafy suburbs)
400m² per head, 2614.144km² = a population of 6,535,360 people who prefer keeping chickens and vegetable gardens to the bustle of the city.
That is 13% of the area, 1% of the population.
3. 200m² PER PERSON
This is a population density like a low density town of bungalows, 5000 people per km²
This takes up 13.5% of my megacity, an area of 2714.688km², which, at that population density, represents a population of 13,573,440, 3% of the population.
4. Mid-rise apartments
Here things start to get dense and urban. Each person has an average of 23m², a population density of 43,478/km², only about 20-21% denser than Eixample, which "limited building height to 16 metres", and Eixample doesn't feel crazy-dense.
This part of the megacity covers 18.4% of the territory, 3700.0192km², giving it a population of 160,870,400, 32% of the total population.
5. 20-story apartments
(Note that when I say 20-story apartments, that's not a strict law, just an average.)
This covers 15% of the territory, 3016.32km², and the population density is one person per 10m², more than TriBeCa or Central Tokyo, but much less than Kowloon Walled City. This gives a population of 301.632 million, 60% of the city's population.
Here we get into science-fiction densities, 100-story building the size of the Pentagon. The density is one million per km² or 1m² per person. This is still half of what Kowloon Walled City saw IRL.
Though this takes up just 0.1% of the territory (20.1088km²), it houses 4% of the population (20.1088 million)
Add up the densities and all the populations of the different density-zones and you get the numbers at top. You've expanded Manhattan to be the size of an Irish province. You've crammed half a billion people into an area with 80km radius.
AND YET you did all that while devoting 40% of the area to water and parks, and having 1% of the population keeping chickens.
Point is megacities don't have to be uniformly dense. You have high-density zones and low-density zones. The really dense parts pick up the slack from the low-density and no-density parts.