Skip to content

Instantly share code, notes, and snippets.

View harllos's full-sized avatar

Harllos Arthur harllos

  • @labFGV
  • Rio de Janeiro
View GitHub Profile
We can't make this file beautiful and searchable because it's too large.
CID,DESCRICAO
A000,"Cólera devida a Vibrio cholerae 01, biótipo cholerae"
A001,"Cólera devida a Vibrio cholerae 01, biótipo El Tor"
A009,Cólera não especificada
A010,Febre tifóide
A011,Febre paratifóide A
A012,Febre paratifóide B
A013,Febre paratifóide C
A014,Febre paratifóide não especificada
A020,Enterite por salmonela
@harllos
harllos / scrap_stf.py
Created October 11, 2019 18:31
código em python muito simples para scrapear site do STF em busca de informações sobre os processos de uma ou mais partes
import requests
from bs4 import BeautifulSoup
import pandas as pd
import numpy as np
import pandas as pd
from datetime import datetime, timedelta
#import oauth, tweepy
import gspread
import gspread_dataframe as gd
from oauth2client.service_account import ServiceAccountCredentials
// adding menu but doing nothing yet 
 var popup = new mapboxgl.Popup({
 closeButton: false,
 closeOnClick: true
 });
map.on('click', 'unclustered-point', function(e) {
 // Change the cursor style as a UI indicator.
 map.getCanvas().style.cursor = 'pointer';
var coordinates = e.features[0].geometry.coordinates.slice();
 var description = '<h2>aptos: '+e.features[0].properties.total_aptos+'<h2>local: '+e.features[0].properties.nm_local+'</h2>'+'\n'
function initmap() {
updateClusters(false);
select_el.addEventListener('change', function(e) {
 // Update selected aggregation on dropdown
 select_value = select_el.value
 updateClusters(true);
 })
map.addSource("locais-2018-mp-clean", {
 type: "geojson",
 data: clusterData,
var colorStops, radiusStops;
function updateClusters(repaint) {
 currentZoom = map.getZoom();
 clusterData = turf.featureCollection(cluster.getClusters(worldBounds, Math.floor(currentZoom)))
let stops_domain = chroma.limits(getFeatureDomain(clusterData, select_value), 'e', 8)
 //coloração original era definida pela linha abaixo. copiei, colei e utilizei escala logarítimica que tirei daqui: https://github.com/gka/chroma.js/
 var scale = chroma.scale(color).domain(stops_domain).mode('lab')
 colorStops = createColorStops(stops_domain, scale)
 radiusStops = createRadiusStops(stops_domain, 20, 50);
if (repaint) {
map.on('style.load', function() {
 fetch(data_url)
 .then(res => res.json())
 .then((out) => {
 mydata = out;
 // Usando a Supercluster!
 cluster.load(mydata.features);
 // Criando o mapa
 initmap();
 })
mapboxgl.accessToken = 'seu token vai aqui';
 var map = new mapboxgl.Map({
 container: 'map',
 style: "seu map style vai aqui. você poderá criar um estilizado ou utilizar um padrão do Mapbox.
 Também é possível utilizar uma solução do OpenStreet Map ou similares, que não é o escopo deste tutorial.",
 center: [-43.01,-22.495], #escolha uma latitude/longitude inicial para seu mapa
 zoom: 8, #escolha um zoom inicial
 hash: true
 });
//Supercluster with property aggregation
 var cluster = supercluster({
 radius: clusterRadius,
 maxZoom: clusterMaxZoom,
 initial: function() {
 return {
 count: 0,
 sum: 0,
 min: Infinity,
 max: -Infinity
function getFeatureDomain(geojson_data, myproperty) {
 let data_domain = []
 turf.propEach(geojson_data, function(currentProperties, featureIndex) {
 data_domain.push(Math.round(Number(currentProperties[myproperty]) * 100 / 100))
 })
 return data_domain
 }
function createColorStops(stops_domain, scale) {
 let stops = []
 stops_domain.forEach(function(d) {
<script>
 var select_el = document.getElementById('select-option')
 var select_value = select_el.value
var clusterRadius = 40;
 var clusterMaxZoom = 20;
 //Propriedade a ser utilizada para gerar os pontos a serem clusterizados em nosso aquivo GeoJSON. Precisa ser uma variável do tipo NUMÉRICO.
 var propertyToAggregate = "total_aptos"
//este é o link onde armazenei nosso GeoJSON
 let data_url = "https://gist.githubusercontent.com/harllos/022379b54666103b8f842a18f71bb88a/raw/7442f4648c9f8f9371f21a79593265f9503279a6/locais_2018_mp_clean.geojson"; 
 var mydata;