Flags and their meanings

As the La Vuelta cycle race returned to our local roads recently, it seems appropriate to look at the meaning of the coloured flags displayed by the accompanying Guardia Civil motorcycles.
It is not just during events like a cycle race that flags are used, they can be used at any time on the roads, so it is important we know the different meanings.
Red flag
The red flag indicates that the road beyond the vehicle carrying it is closed to traffic, except for those authorised to proceed. You must not pass a vehicle carrying a red flag.
Green flag
The green flag indicates that the road is open again and normal rules of passage apply.
Yellow flag
The yellow flag indicates the need for extreme caution as there may be an approaching danger. This flag is also used for road-based events such as cycle races when extreme caution is also required.