I trained a neural network feature extraction to compress images of a flags to a vectors of numbers. The image above shows the results of hierarchical clustering of those vectors. We can see how the horizontal striped flags were clustered together (on the left), the British colonies (toward the right), and the vertical striped flags (bottom right), as well as a number of other nice clusters (the flags with circular emblems in the middle are all in the top middle). With the vector representation of flags, we can also measure the similarity between flags. We can find the most similar (though some countries, like Chad and Romania have virtually the same flag), the most unique, and we can see if there are geographic or historical trends in flag design.
The original question that prompted this project was whether neighboring countries were more likely to have similar flags (because their geographic closeness might also be reflected culturally) or different flags (because they developed their flags to distinguish themselves from their neighbors). Using this vector representation, the answer is that a country's flag just as similar to its neighbors as it is to any other country.