After Mexico's 7.1-magnitude quake, some buildings have collapsed while others, often right next door, remain standing. Why?
Mexico City was built on ancient waterways
The first factor is that the soil is not the same in every place underneath Mexico City. Much of the centre of town is built on the sediment of ancient lakes, making the soil loose.
When an earthquake strikes, it makes that particular soil vulnerable to shaking like jelly, prolongs the earthquake, and makes the buildings directly above it shake.
Seismologist Susanne Sergeant of the British Geological Survey says: "Softer materials amplify the ground shaking."
But she cautioned: "At this point it's going to be difficult to say whether a building has been damaged due to the architecture or the geological variation."
The building code changed after a massive earthquake in 1985
The 1985 earthquake claimed more than 10,000 lives, flattened 30,000 buildings and damaged 68,000 more. A year later a new law came in to place, requiring builders and architects to take into account the bad soil below parts of the city and for the authorities to fully supervise and inspect all building processes.
But it is not clear that those new regulations are always followed.
After Tuesday's earthquake, engineering lecturer Christian Malaga-Chuquitaype, from Imperial College London, told the BBC that people in Mexico, as in much of Latin America, tend to build their own homes or do their own renovations, knocking walls through or installing windows and changing the specifications so that they might no longer fit the code to which they were built.
The housing stock is infrequently updated, meaning plenty of buildings in the capital are pre-1985.
And he said: "Buildings need to be inspected. Designs need to be properly supervised.
"Sometimes in developing countries we cut corners."
During anniversary commemorations in 2015, an engineer from Mexico Autonomous National University (Unam) warned that the code was being breached too frequently, and called for stricter regulation.
Roberto Meli told EFE news agency that corners were being cut to keep budgets low and make buildings look better.
He did not single out any particular buildings or companies, but said: "Buildings have been found that do not comply 100% with the regulations. They do not have sufficient documentation."
Some buildings are earthquake-proofed
With earthquake engineering, the aim is to make the seismic force shoot predictably up and down the internal structures of the building.
This can be achieved, Dr Malaga-Chuquitaype says, by building structural walls instead of columns.
"If a building has more structural walls it will be stiffer," he says.
There may also be the option to extend foundations deeper, but this may not be feasible or cost-effective unless doing so will help them reach hard ground.
The force is less of an issue for taller buildings, built to sustain high winds, than it is for smaller ones.
The 57-storey Torre Reforma in the centre of town is triangular and has been praised for its walls that can bend without breaking.
And even in 1985, two skyscrapers survived: the 44-storey Torre Latinoamericana and the 54-storey Torre Ejecutiva Pemex.