{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "# pip3 install simplekml" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "import simplekml as kml\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "df = pd.read_excel('res5.xlsx', sheet_name='dados')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
longitudelatitudecod_localidade_tsenom_localidadenom_bairronum_localnom_localdes_enderecocodigolqtd_secoes...crimes_eleitoraisboca_de_urnaroubofurtodesacatodesobedienciaCVind_cidGRUPOSefetivo
0-61.504226-10.87078789960RONDOLÂNDIACENTRO1015ESCOLA ESTADUAL OLAVO BILACRUA MATHILDE KLEMS, S/N6189960101510...000210003362.000000
1-60.941759-10.47533989960RONDOLÂNDIAZONA RURAL1066ESCOLA ZAWA KAREY PANGYJYALDEIA INDÍGENA ZORÓ618996010661...000000003370.077778
2-60.180703-14.10788690867NOVA LACERDAGLEBA SANTA AMÉLIA1040ESCOLA MUNICIPAL VALE DO GUAPORÉCOMUNIDADE SANTA AMÉLIA619086710401...000000004440.077778
3-59.967301-15.01409391090VILA BELA DA SANTÍSSIMA TRINDADEJARDIM AEROPORTO1341CRECHE AVIAOZINHOAVENIDA MARTIMIANO RIBEIRO DA FONSECA, S/N259109013411...0101301004401.000000
4-59.950224-15.00308991090VILA BELA DA SANTÍSSIMA TRINDADECENTRO1171CAMARA MUNICIPAL DE VILA BELA DA SANTISSIMA TR...AV. SÃO LUIZ, S/N, VILA BELA DA SS. TRINDADE259109011712...000000004390.461111
\n", "

5 rows × 22 columns

\n", "
" ] }, "execution_count": 4, "metadata": { }, "output_type": "execute_result" } ], "source": [ "df[:5]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "mapa = kml.Kml()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2.0'" ] }, "execution_count": 6, "metadata": { }, "output_type": "execute_result" } ], "source": [ "str(round(df['efetivo'].loc[0],1))" ] }, { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [ "def InsereKML(i):\n", " aux = str(df['GRUPOS'].loc[i]) + ' (' +str(round(df['efetivo'].loc[i],1)) + ')'\n", " mapa.newpoint(name=aux, coords=[(df['longitude'].loc[i],df['latitude'].loc[i])])" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "def InsereKML(i):\n", " aux = str(df['GRUPOS'].loc[i]) + ' (' +str(round(df['efetivo'].loc[i],1)) + ')'\n", "\n", " pnt = mapa.newpoint(name=aux, coords=[(df['longitude'].loc[i],df['latitude'].loc[i])])\n", "\n", " pnt.style.labelstyle.scale = 0.75\n", "\n", " if str(round(df['efetivo'].loc[i],1)) == '2.0':\n", " pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/police.png'\n", " pnt.style.labelstyle.color = kml.Color.red\n", " else:\n", " pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/track.png'" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "for i in range(len(df.index)):\n", " InsereKML(i)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "mapa.save(\"Mapa 5.kml\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (Ubuntu Linux)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.2" } }, "nbformat": 4, "nbformat_minor": 0 }