Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions models/br_mma_cnuc/br_mma_cnuc__unidades_conservacao.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{
config(
alias="unidades_conservacao",
schema="br_mma_cnuc",
materialized="table",
)
}}

select
safe_cast(ano as int64) ano,
safe_cast(semestre as int64) semestre,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variáveis string com descrições de ucs e similares estão ora em caixa alta ora em Title

safe_cast(id_uc as int64) id_uc,
safe_cast(codigo_uc as string) codigo_uc,
safe_cast(nome_uc as string) nome_uc,
safe_cast(esfera_administrativa as string) esfera_administrativa,
safe_cast(categoria_manejo as string) categoria_manejo,
safe_cast(categoria_iucn as string) categoria_iucn,
safe_cast(grupo as string) grupo,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

converter para NULL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mesmo acontece nas variáveis orgao_gestor e informacoes_gerais

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esse comportamento acontece com diversas colunas

safe_cast(protecao_integral as int64) protecao_integral,
safe_cast(uso_sustentavel as int64) uso_sustentavel,
safe_cast(sigla_uf as string) sigla_uf,
safe_cast(municipios_abrangidos as string) municipios_abrangidos,
safe_cast(ano_criacao as int64) ano_criacao,
safe_cast(ano_ato_legal_recente as int64) ano_ato_legal_recente,
safe_cast(ato_legal_criacao as string) ato_legal_criacao,
safe_cast(outros_atos_legais as string) outros_atos_legais,
safe_cast(plano_manejo as string) plano_manejo,
safe_cast(conselho_gestor as string) conselho_gestor,
safe_cast(orgao_gestor as string) orgao_gestor,
safe_cast(informacoes_gerais as string) informacoes_gerais,
safe_cast(fonte_area as int64) fonte_area,
safe_cast(area_soma_biomas as float64) area_soma_biomas,
safe_cast(area_soma_biomas_continental as float64) area_soma_biomas_continental,
safe_cast(area_ato_legal_criacao as float64) area_ato_legal_criacao,
safe_cast(area_amazonia as float64) area_amazonia,
safe_cast(area_caatinga as float64) area_caatinga,
safe_cast(area_cerrado as float64) area_cerrado,
safe_cast(area_mata_atlantica as float64) area_mata_atlantica,
safe_cast(area_pampa as float64) area_pampa,
safe_cast(area_pantanal as float64) area_pantanal,
safe_cast(area_marinha as float64) area_marinha,
safe_cast(bioma_declarado as string) bioma_declarado,
safe_cast(biomas_abrangidos as string) biomas_abrangidos,
safe_cast(percentual_alem_linha_costa as float64) percentual_alem_linha_costa,
safe_cast(recortes as float64) recortes,
safe_cast(mar_territorial as float64) mar_territorial,
safe_cast(municipio_costeiro as float64) municipio_costeiro,
safe_cast(
municipio_costeiro_area_marinha as float64
) municipio_costeiro_area_marinha,
safe_cast(amazonia_legal as float64) amazonia_legal,
safe_cast(lei_mata_atlantica as float64) lei_mata_atlantica,
safe_cast(sobreposicao_ti_tq as float64) sobreposicao_ti_tq,
safe_cast(programa_projeto as string) programa_projeto,
safe_cast(sitios_patrimonio_mundial as string) sitios_patrimonio_mundial,
safe_cast(sitios_ramsar as string) sitios_ramsar,
safe_cast(mosaico as string) mosaico,
safe_cast(reserva_biosfera as string) reserva_biosfera,
safe_cast(codigo_wdpa as string) codigo_wdpa,
safe_cast(regiao as string) regiao,
safe_cast(
qualidade_dados_georreferenciados as string
) qualidade_dados_georreferenciados,
safe_cast(presente_versao_anterior as string) presente_versao_anterior,
safe_cast(diferenca_area as float64) diferenca_area,
safe_cast(razao_diferenca_area as float64) razao_diferenca_area,
safe_cast(data_publicacao_cnuc as date) data_publicacao_cnuc,
safe_cast(data_ultima_certificacao as date) data_ultima_certificacao,
st_geogfromtext(safe_cast(geometria as string), make_valid => true) geometria,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

geometria deve ser tipada como geography. Atualizar o manual de estilo e integrar com o MCP seria um bom próx passo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outro ponto, pra garantir qualidade é bom validar as geometrias com o BBOX aproximado do brasil. O objetivo é saber se os polígonos estão dentro do território BR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das +-36k de linhas somente 2927k tem geometrias não nulas. Me parece estranho;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existem geometrias nulas com valores de áreas em hectares nas demais colunas

from {{ set_datalake_project("br_mma_cnuc_staging.unidades_conservacao") }} as t
Loading
Loading