Skip to main content

Convert CEP (Brazilian zip code) to coordinates

Project description

Pacote Python para converter CEP em latitude e longitude

Como usar:

  1. Instale:
git clone https://github.com/millengustavo/cep-to-coords.git
cd cep-to-coords
git checkout master
pip install -e .
  1. Converta um CEP para latitude e longitude:
from cep_to_coords.convert import cep_to_coords


coordenadas = cep_to_coords('22070-900')
print(coordenadas)

# {'latitude': -22.9864082, 'longitude': -43.189592}

Opcional - Usando o https://cepaberto.com/

Para usar esse conversor você precisa se cadastrar no site e exportar seu token como variável de ambiente CEP_ABERTO_TOKEN

export CEP_ABERTO_TOKEN='seu_token'
from cep_to_coords.convert import cep_to_coords
from cep_to_coords.strategies import CEPAbertoConverter


coordenadas = cep_to_coords('22070-900', factory=CEPAbertoConverter)
print(coordenadas)

# {'latitude': -22.9864082, 'longitude': -43.189592}

Testando

python -m unittest discover

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cep_to_coords-0.1.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

cep_to_coords-0.1.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page