There is a Google Internationalization project called Region Flags that structures the Wikipedia data.
This package is a collection of flags for BCP 47 region codes. Most people think of these as country flags, but there are a few codes / flags that do not correspond to countries. The flags are in SVG and PNG format and named by their BCP 47 region code, which for countries is the same as ISO 3166-2 country code.
The license is based on the Wikipedia license, which are flag-dependent
The flags are downloaded from Wikipedia. When Wikipedia flags were copyrighted, we worked we Wikipedia editors to either relicense them, or drew / sourced and uploaded new public-domain versions.
How to get data:
To download missing flags, run download-wp.py.
To update to latest flags from Wikipedia, delete the html, svg, and png directories, then run make-aliases.sh followed by download-wp.py.
Data formats are PNG and SVG, where SVG can be easily and safely be used at any resolution.