36
edições
Sem resumo de edição |
Sem resumo de edição |
||
Linha 2: | Linha 2: | ||
create database <NOME_BANCO>; | create database <NOME_BANCO>; | ||
</syntaxhighlight>Insira o comando abaixo para entrar no banco recém-criado<syntaxhighlight lang="psql"> | </syntaxhighlight>Insira o comando abaixo para entrar no banco recém-criado<syntaxhighlight lang="psql"> | ||
\c < | \c <nome_base_de_dados>; | ||
</syntaxhighlight>Habilite a base de dados para trabalhar com dados geográficos por meio do comando abaixo.<syntaxhighlight lang="psql"> | </syntaxhighlight>Habilite a base de dados para trabalhar com dados geográficos por meio do comando abaixo.<syntaxhighlight lang="psql"> | ||
create extension postgis; | create extension postgis; | ||
Linha 14: | Linha 14: | ||
</syntaxhighlight><syntaxhighlight lang="bash"> | </syntaxhighlight><syntaxhighlight lang="bash"> | ||
psql <nome_base_de_dados> < prepare1-binCodes.sql | psql <nome_base_de_dados> < prepare1-binCodes.sql | ||
</syntaxhighlight> | </syntaxhighlight><syntaxhighlight lang="bash"> | ||
psql <nome_base_de_dados> < prepare1a-asserts.sql | |||
</syntaxhighlight><syntaxhighlight lang="bash"> | |||
psql <nome_base_de_dados> < prepare1b-demo.sql | diff - ../data/prepare1b-demo.txt | |||
</syntaxhighlight><syntaxhighlight lang="bash"> | |||
psql <nome_base_de_dados> < prepare2-baseConv.sql | |||
</syntaxhighlight><syntaxhighlight lang="bash"> | |||
psql <nome_base_de_dados> < prepare2a-asserts.sql | |||
</syntaxhighlight><syntaxhighlight lang="bash"> | |||
psql <nome_base_de_dados> < prepare2b-demo.sql | diff - ../data/prepare2b-demo.txt | |||
</syntaxhighlight>A base de dados está pronta para receber as grades do Brasil. Agora vá para o diretório /tmp e execute o comando abaixo para fazer download das grades do Brasil.<syntaxhighlight lang="bash"> | |||
wget http://www.addressforall.org/_private/grid_br_dump2.sql.gz | |||
</syntaxhighlight>Dê as permissoões necessárias ao arquivo recém-baixado para que o mesmo possa ser descompactado. Após isso, mude o usuário do Ubuntu para o usuário postgres por meio do comando:<syntaxhighlight lang="bash"> | |||
sudo -i -u postgres | |||
</syntaxhighlight>Agora vá para o diretório /tmp, e execute o comando abaixo:<syntaxhighlight lang="bash"> | |||
gunzip -c grid_br_dump2.sql.gz | <nome_base_de_dados> | |||
</syntaxhighlight>Após a finalizar o carregamento das grades do brasil na base de dados, algumas configurações adicionais ainda são necessárias. Ainda no usuário postgres, mude para a interface de linha de comando (CLI) do postgres com o comando:<syntaxhighlight lang="bash"> | |||
psql | |||
</syntaxhighlight>entre na base de dados onde acabamos de carregar as grade do brasil:<syntaxhighlight lang="bash"> | |||
\c <nome_base_de_dados> | |||
</syntaxhighlight>Insira o script SQL abaixo:<syntaxhighlight lang="sql"> | |||
/** | |||
* System's Public library (commom for many scripts) | |||
* Module: PostGIS general complements. Fragment. | |||
*/ | |||
CREATE extension IF NOT EXISTS postgis; | |||
INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) VALUES | |||
-- -- -- -- | |||
( -- IBGE Albers, SRID number convention in Project DigitalGuard-BR: | |||
952019, | |||
'BR:IBGE', | |||
52019, | |||
'+proj=aea +lat_0=-12 +lon_0=-54 +lat_1=-2 +lat_2=-22 +x_0=5000000 +y_0=10000000 +ellps=WGS84 +units=m +no_defs', | |||
$$PROJCS[ | |||
"Conica_Equivalente_de_Albers_Brasil", | |||
GEOGCS[ | |||
"GCS_SIRGAS2000", | |||
DATUM["D_SIRGAS2000",SPHEROID["Geodetic_Reference_System_of_1980",6378137,298.2572221009113]], | |||
PRIMEM["Greenwich",0], | |||
UNIT["Degree",0.017453292519943295] | |||
], | |||
PROJECTION["Albers"], | |||
PARAMETER["standard_parallel_1",-2], | |||
PARAMETER["standard_parallel_2",-22], | |||
PARAMETER["latitude_of_origin",-12], | |||
PARAMETER["central_meridian",-54], | |||
PARAMETER["false_easting",5000000], | |||
PARAMETER["false_northing",10000000], | |||
UNIT["Meter",1] | |||
]$$ | |||
), | |||
-- -- -- -- | |||
( -- Grid of Colombia, IGAC MAGNA-SIRGAS / Origen-Nacional: | |||
9377, -- official EPSG number | |||
'CO:IGAC', | |||
9377, | |||
'+proj=tmerc +lat_0=4.0 +lon_0=-73.0 +k=0.9992 +x_0=5000000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs', | |||
$$PROJCS[ | |||
"MAGNA-SIRGAS / Origen-Nacional", | |||
GEOGCS[ | |||
"MAGNA-SIRGAS", | |||
DATUM[ | |||
"Marco_Geocentrico_Nacional_de_Referencia", | |||
SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]], | |||
TOWGS84[0,0,0,0,0,0,0], | |||
AUTHORITY["EPSG","6686"] | |||
], | |||
PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]], | |||
UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]], | |||
AUTHORITY["EPSG","4686"] | |||
], | |||
PROJECTION["Transverse_Mercator"], | |||
PARAMETER["latitude_of_origin",4.0], | |||
PARAMETER["central_meridian",-73.0], | |||
PARAMETER["scale_factor",0.9992], | |||
PARAMETER["false_easting",5000000], | |||
PARAMETER["false_northing",2000000], | |||
UNIT["metre",1,AUTHORITY["EPSG","9001"]], | |||
AUTHORITY["EPSG","9377"] | |||
]$$ | |||
), | |||
-- -- -- -- | |||
-- "DGGS projections" from SRID 955001 to 955099. | |||
-- | |||
( -- rHEALPix default, PROJ v4.8+ | |||
955001, 'DGGS:001:rHEALPix', 1, | |||
'+proj=rhealpix', | |||
NULL -- no srtext | |||
), | |||
( -- rHEALPix variant 2, PROJ v4.8+ | |||
955002, 'DGGS:002:rHEALPix', 2, | |||
'+proj=rhealpix +ellps=WGS84 +south_square=0 +north_square=2', | |||
NULL -- no srtext | |||
), | |||
( -- QSC default, PROJ v?+ | |||
955010, 'DGGS:010:QSC', 10, | |||
'+proj=qsc', | |||
NULL -- no srtext | |||
), | |||
--( -- S2 default, PROJ v8.2+ | |||
-- 955020, 'DGGS:020:S2', 20, | |||
-- '+proj=s2', | |||
-- NULL -- no srtext | |||
--), | |||
( -- ISEA default, PROJ v?+ (without inverse!) | |||
955030, 'DGGS:030:ISEA', 30, | |||
'+proj=isea', | |||
NULL -- no srtext | |||
) | |||
ON CONFLICT DO NOTHING; | |||
</syntaxhighlight>O script SQL acima proporciona a base de dados a lidar com projeções compatíveis com o IBGE. | |||
Em seguida, | |||
==== Consulta para verificar se um determinado nível de grade está disponível para todos os municípios brasileiros ==== | ==== Consulta para verificar se um determinado nível de grade está disponível para todos os municípios brasileiros ==== |
edições