CNEFE

De Documentação
Revisão de 22h50min de 30 de maio de 2024 por Peter (discussão | contribs) (→‎Pontos)

CNEFE - Cadastro Nacional de Endereços para Fins Estatísticos

Ver https://www.ibge.gov.br/estatisticas/sociais/populacao/38734-cadastro-nacional-de-enderecos-para-fins-estatisticos.html?edicao=40122&t=resultados

Faces de Quadra

Pegar em 4314902_faces_de_logradouros_2021.prj

mkdir /tmp/POA_FACES/

cd /tmp/POA_FACES

wget https://dl.digital-guard.org/5d5daa06e048ad8c83c909babee040e26fd8a54a29ed4cef2d2d220a3bd17b84.zip

zip -T 5d5daa06e048ad8c83c909babee040e26fd8a54a29ed4cef2d2d220a3bd17b84.zip

cd '/tmp/5d5daa06e048ad8c83c909babee040e26fd8a54a29ed4cef2d2d220a3bd17b84/rs_faces_de_logradouros_2021/'
cp 4314902* /tmp/POA_FACES

Supor arquivos logradouro em log:

create database poa;
\c poa
create extension postgis;
-----
shp2pgsql  log | psql -q postgres://postgres@localhost/poa

Melhorando os dados:

drop view if exists vw01_log ;
create view vw01_log as select *, regexp_replace( coalesce(nm_tip_log,'') || ' '||  coalesce(nm_tit_log,'') ||' '|| coalesce(nm_log,''), '\s+', ' ', 'g') as via_name from log;

select gid, cd_setor, cd_quadra, cd_face, via_name, tot_res from vw01_log limit 100;

Pontos

Por cidade temos Censo_Demografico_2022/Arquivos_CNEFE/Municipio, direto latLong em srid=4326.

Pelo cabeçalho podemos copiar para uma tabela texto,

CREATE TABLE ibge_cnefe2022 (
COD_UNICO_ENDERECO text,
COD_UF text,
COD_MUNICIPIO text,
COD_DISTRITO text,
COD_SUBDISTRITO text,
COD_SETOR text,
NUM_QUADRA text,
NUM_FACE text,
CEP text,
DSC_LOCALIDADE text,
NOM_TIPO_SEGLOGR text,
NOM_TITULO_SEGLOGR text,
NOM_SEGLOGR text,
NUM_ENDERECO text,
DSC_MODIFICADOR text,
NOM_COMP_ELEM1 text,
VAL_COMP_ELEM1 text,
NOM_COMP_ELEM2 text,
VAL_COMP_ELEM2 text,
NOM_COMP_ELEM3 text,
VAL_COMP_ELEM3 text,
NOM_COMP_ELEM4 text,
VAL_COMP_ELEM4 text,
NOM_COMP_ELEM5 text,
VAL_COMP_ELEM5 text,
LATITUDE real,
LONGITUDE real,
NV_GEO_COORD text,
COD_ESPECIE text,
DSC_ESTABELECIMENTO text,
COD_INDICADOR_ESTAB_ENDERECO text,
COD_INDICADOR_CONST_ENDERECO text,
COD_INDICADOR_FINALIDADE_CONST text,
COD_TIPO_ESPECI text
);
copy ibge_cnefe2022 from '/tmp/POA_FACES/4314902_PORTO_ALEGRE.csv' with  (format CSV, delimiter ';', header);

----
drop view if exists vw02_ibge_cnefe2022;
create view vw02_ibge_cnefe2022 as
select *, regexp_replace( coalesce(nom_tipo_seglogr,'') || ' '||  coalesce(nom_titulo_seglogr,'') ||' '|| coalesce(nom_seglogr,''), '\s+', ' ', 'g') as via_name,
ST_SetSRID(ST_MakePoint(longitude::float, latitude::float),4326) as geom
from ibge_cnefe2022;

select count(*) from ibge_cnefe2022; -- 762239

select count(*) from (select distinct ST_GeoHash(geom,9) as ghs, cod_setor, num_quadra, num_face, via_name, num_endereco
from vw02_ibge_cnefe2022 -- same where geom is not null and via_name>'' and num_endereco>''          
) t; -- 379957
select 379957.0/762239; -- 49,847% = 50%

Só na redução de pontos para 50% já é bem drástica, provavelmente inclui casos que diferenciam apenas no complemento. Falta eliminar mesmo ponto e mesmo endereço/CEP.