Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Estimativa de efetivo para PMMT nas eleições de 2018

Project: Pesquisa
Views: 2364
Kernel: Python 3 (Ubuntu Linux)
# pip3 install simplekml
import simplekml as kml import pandas as pd
df = pd.read_excel('res5.xlsx', sheet_name='dados')
df[:5]
longitude latitude cod_localidade_tse nom_localidade nom_bairro num_local nom_local des_endereco codigo lqtd_secoes ... crimes_eleitorais boca_de_urna roubo furto desacato desobediencia CV ind_cid GRUPOS efetivo
0 -61.504226 -10.870787 89960 RONDOLÂNDIA CENTRO 1015 ESCOLA ESTADUAL OLAVO BILAC RUA MATHILDE KLEMS, S/N 61899601015 10 ... 0 0 0 2 1 0 0 0 336 2.000000
1 -60.941759 -10.475339 89960 RONDOLÂNDIA ZONA RURAL 1066 ESCOLA ZAWA KAREY PANGYJY ALDEIA INDÍGENA ZORÓ 61899601066 1 ... 0 0 0 0 0 0 0 0 337 0.077778
2 -60.180703 -14.107886 90867 NOVA LACERDA GLEBA SANTA AMÉLIA 1040 ESCOLA MUNICIPAL VALE DO GUAPORÉ COMUNIDADE SANTA AMÉLIA 61908671040 1 ... 0 0 0 0 0 0 0 0 444 0.077778
3 -59.967301 -15.014093 91090 VILA BELA DA SANTÍSSIMA TRINDADE JARDIM AEROPORTO 1341 CRECHE AVIAOZINHO AVENIDA MARTIMIANO RIBEIRO DA FONSECA, S/N 25910901341 1 ... 0 1 0 13 0 1 0 0 440 1.000000
4 -59.950224 -15.003089 91090 VILA BELA DA SANTÍSSIMA TRINDADE CENTRO 1171 CAMARA MUNICIPAL DE VILA BELA DA SANTISSIMA TR... AV. SÃO LUIZ, S/N, VILA BELA DA SS. TRINDADE 25910901171 2 ... 0 0 0 0 0 0 0 0 439 0.461111

5 rows × 22 columns

mapa = kml.Kml()
str(round(df['efetivo'].loc[0],1))
'2.0'
def InsereKML(i): aux = str(df['GRUPOS'].loc[i]) + ' (' +str(round(df['efetivo'].loc[i],1)) + ')' mapa.newpoint(name=aux, coords=[(df['longitude'].loc[i],df['latitude'].loc[i])])
def InsereKML(i): aux = str(df['GRUPOS'].loc[i]) + ' (' +str(round(df['efetivo'].loc[i],1)) + ')' pnt = mapa.newpoint(name=aux, coords=[(df['longitude'].loc[i],df['latitude'].loc[i])]) pnt.style.labelstyle.scale = 0.75 if str(round(df['efetivo'].loc[i],1)) == '2.0': pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/police.png' pnt.style.labelstyle.color = kml.Color.red else: pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/track.png'
for i in range(len(df.index)): InsereKML(i)
mapa.save("Mapa 5.kml")