Skip to content

Instantly share code, notes, and snippets.

@JoaoCarabetta
Created April 19, 2021 21:48
Show Gist options
  • Save JoaoCarabetta/d45ef052aded84eb043c7ec55a12bf7c to your computer and use it in GitHub Desktop.
Save JoaoCarabetta/d45ef052aded84eb043c7ec55a12bf7c to your computer and use it in GitHub Desktop.
Intersect point to hexagon - SQL Base dos Dados
select id_grid_h3, hora, ST_ASTEXT(ANY_VALUE(geometria)) wkt, count(*) n_registros, ANY_VALUE(quantidade_pessoas) populacao
from `rj-smtr.br_rj_riodejaneiro_onibus_gps.registros_tratada` t1
join `basedosdados.br_ipea_acesso_oportunidades.estatisticas_2019` t2
on st_intersects(geometria, st_geogpoint(longitude, latitude))
where id_municipio in (
select id_municipio
from `basedosdados.br_bd_diretorios_brasil.municipio`
where municipio = 'Rio de Janeiro')
group by id_grid_h3, hora
@fernandascovino
Copy link

a coluna municipio mudou para nome la no diretorios, nao sei como submeter uma mudanca aqui no gist ahah

@JoaoCarabetta
Copy link
Author

Bota a query nova aqui pfv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment