Skip to content

Instantly share code, notes, and snippets.

@lsdr
Last active June 1, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsdr/dc3fcd9594bced95aa7ff76f8faa98be to your computer and use it in GitHub Desktop.
Save lsdr/dc3fcd9594bced95aa7ff76f8faa98be to your computer and use it in GitHub Desktop.
Carregando dados do IBGE no PostGIS
# download dos shapefiles do IBGE
curl -s 'ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2016/Brasil/BR/BR.zip' -o BR.zip
# abrir o pacote
unzip -j BR.zip
# instala o postgresql e o postgis
brew install postgis
# inicia o postgresql
brew services start postgresql
# converte shapefile para SQL
shp2pgsql -c -D -i -I BRMUE250GC_SIR geo.municipios > load_muni.sql
shp2pgsql -c -D -i -I BRMIE250GC_SIR geo.microrregioes > load_micro.sql
shp2pgsql -c -D -i -I BRMEE250GC_SIR geo.mesorregioes > load_meso.sql
shp2pgsql -c -D -i -I BRUFE250GC_SIR geo.uf > load_uf.sql
# carrega dados do shapefile no PostGIS
psql -d postgres -f load_muni.sql
psql -d postgres -f load_micro.sql
psql -d postgres -f load_meso.sql
psql -d postgres -f load_uf.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment