Creates GeoJSON map data for Brazilian states and the entire country using the data published by the IBGE (Instituto Brasileiro de Geografia e Estatistica). This code currently uses the most recent data published May 20, 2020 and represents the 2019 dataset. You can read more about the dataset here.
The script uses ogr2ogr
to convert the files from Shapefiles to GeoJSON. It is a part of the Geospatial Data Abstraction Library (GDAL). Check their site for downloads compatible with your system. It is also included in the Homebrew (Mac) and apt (Debian/Ubuntu) package managers as well.
Running get_geojson.sh
will create a data
directory with 4 files for each state (and optionally the entire country):
UF_municipalities.json
: GeoJSON file for the IBGE municipalities (municipios) within a particular Unidade Federativa (UF)UF_microregions.json
: GeoJSON file for the IBGE microregions (microrregiões) within a UFUF_mesoregions.json
: GeoJSON file for the IBGE mesoregions (mesorregiões) within a UFUF_state.json
: GeoJSON file for the geometry of each UF
-c
or--clean
: will delete the tmp directory created to store all the original Shapefiles upon completion-b
or--brasil
: will optionally download every municipality, mesoregion, etc. for the whole country as one file (large files)