tag:blogger.com,1999:blog-384865252024-02-07T21:12:35.672-03:00Prof. Marcello BenignoMarcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.comBlogger62125tag:blogger.com,1999:blog-38486525.post-8350610740610291812016-04-10T11:28:00.000-03:002016-04-10T11:28:25.000-03:00Geoserver: importação de arquivos SLD gerados pelo QGIS<div style="text-align: justify;">
O <a href="http://docs.geoserver.org/latest/en/user/styling/sld-introduction.html" target="_blank">SLD</a> (<i><a href="http://docs.geoserver.org/latest/en/user/styling/sld-introduction.html" target="_blank">Styled Language Descriptor</a></i>) é responsável pela estilização dos <i>layers</i> no <a href="http://geoserver.org/" target="_blank">GeoServer</a>, trata-se de um arquivo <a href="https://www.w3.org/XML/" target="_blank">XML</a> baseado nas especificações da <a href="http://www.opengeospatial.org/" target="_blank">OGC</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Neste <i>post</i> será demonstrado como gerar arquivos SLD a partir do <i>software</i> <a href="http://qgis.org/" target="_blank">QGIS</a>. Para tanto, utilizaremos uma tabela espacial representando o mapa de uso e cobertura da terra do estado de São Paulo (Figura 1), armazenada em um Banco de Dados Espaciais (PostgreSQL/PostGIS).</div>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiszhjldXfFHT03wbrle2HJUx9YYBNCE6pmv1x8PqPqat6dF6qtJ2QHk5Q5PCxE29sJUPXfLOyB1cosHLd-ep5_rszwBUb8v4WUpv78AScrHuhsTUutr3vUy8XtPnxoftRWBV0Ybg/s1600/1-screen-qgis.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="404" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiszhjldXfFHT03wbrle2HJUx9YYBNCE6pmv1x8PqPqat6dF6qtJ2QHk5Q5PCxE29sJUPXfLOyB1cosHLd-ep5_rszwBUb8v4WUpv78AScrHuhsTUutr3vUy8XtPnxoftRWBV0Ybg/s640/1-screen-qgis.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Mapa Temático no QGIS</td></tr>
</tbody></table>
<br />
<br />
<br />
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<h2 style="clear: both; text-align: left;">
1 - Criação do SLD no QGIS:</h2>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Em propriedades da camada (Layer Properties), defina a simbologia de cada classe da sua camada, como mostra a Figura 2.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd0AgOf5Ty7jTdtJMESEPFhU6NoyraqawQT-8G6OBfIA0wgas9eevGeRlTQsyqgnl-Qxu1acVj1CPgqYmvG5Pwifqu10EoL2EGCSPalB58hVAwwQ8u0dtn9bBtufc7Dwax-VaZ1A/s1600/tela-2.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="417" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd0AgOf5Ty7jTdtJMESEPFhU6NoyraqawQT-8G6OBfIA0wgas9eevGeRlTQsyqgnl-Qxu1acVj1CPgqYmvG5Pwifqu10EoL2EGCSPalB58hVAwwQ8u0dtn9bBtufc7Dwax-VaZ1A/s640/tela-2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Definição da simbologia</td></tr>
</tbody></table>
<span style="text-align: justify;"><br /></span>
<br />
<br />
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div style="text-align: justify;">
Em seguida, exporte o arquivo de estilos criado para para o formato SLD (Figura 3), com o nome "uso_ocupacao_solo_solo.sld."</div>
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCsD8mv5T-X5K3Uk3DTwshF8guAz2YO4vWIBvetH2Lqtan6adRM1ts7iJ9YjFoqVJ809JZN13-X8NflWd9m8CWVDvUeDBZf0F2l_2eph8wPApZo8dN609misbz4k7OoZPhnc684A/s1600/export-sld.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCsD8mv5T-X5K3Uk3DTwshF8guAz2YO4vWIBvetH2Lqtan6adRM1ts7iJ9YjFoqVJ809JZN13-X8NflWd9m8CWVDvUeDBZf0F2l_2eph8wPApZo8dN609misbz4k7OoZPhnc684A/s640/export-sld.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Exportação para SLD</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h2 style="clear: both;">
2 - Configuração do arquivo SLD no GeoServer:</h2>
<div style="text-align: justify;">
<br />
Em <b style="font-style: italic;">Style Editor </b>adicione um <b>name</b> e um <b>Workspace</b> ao seu arquivo SLD, na sequência, abra o arquivo <b>uso_ocupacao_solo_solo.sld </b>com algum editor de texto. Copie e cole o SLD para a janela do GeoServer (Figura 4). <span style="color: red;"><b>Obs:</b></span> não utilize a opção de upload, pois a mesma pode gerar inconsistências no seu arquivo.</div>
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKwkOt2YezzlR65UVFrQcPlCCzS0YEpLGl60-W9csYpWRrq9P4V35eJ68pTDogVowJPoz1Q-xc6s5zYGLTQnEZ2n2xfKxQndEkw14pQz9a6yc-kYzHrUGYjrofqTocffGah5mqDw/s1600/geo1.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="474" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKwkOt2YezzlR65UVFrQcPlCCzS0YEpLGl60-W9csYpWRrq9P4V35eJ68pTDogVowJPoz1Q-xc6s5zYGLTQnEZ2n2xfKxQndEkw14pQz9a6yc-kYzHrUGYjrofqTocffGah5mqDw/s640/geo1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 4 - Configuração do SLD no Geoserver</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="text-align: justify;">Para adicionar o estilo ao seu layer, vá até a aba </span><b style="text-align: justify;">Edit Layer</b><span style="text-align: justify;">, na opção </span><b style="text-align: justify;">WMS Settings</b><span style="text-align: justify;"> e escolha o SLD criado, como mostra a Figura 5.</span><br />
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXwbNyDHlLI8CWNxg0SZu791bdZcWyM5abiqEVoHC4E_1LG3ObZoVyvzQGDWQb1hEcZ39M-xOlwGiWVGQ8DNR_VYhkhexszsKvtqmzvaMjFySASCqfs489LhGRo4HHGqMNhBWuPA/s1600/layer-geoserver.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="347" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXwbNyDHlLI8CWNxg0SZu791bdZcWyM5abiqEVoHC4E_1LG3ObZoVyvzQGDWQb1hEcZ39M-xOlwGiWVGQ8DNR_VYhkhexszsKvtqmzvaMjFySASCqfs489LhGRo4HHGqMNhBWuPA/s640/layer-geoserver.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 5 - Adição do estilo criado à camada.</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<h2 style="clear: both;">
3 - Resultado no Leaflet:</h2>
<br />
Crie um arquivo html com o contendo o código a seguir:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/14b7517bbfeb2a6aeb00648afc8dddc6.js"></script>
<br />
O resultado pode ser visto na Figura 6.<br />
<br />
<div style="text-align: left;">
</div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmNHlmJs2ZpQ5Xaz7ZYQ_omnl1ETbscfrQRNvunmRGb3RStZcHOI5iPcwF2ZsZvXuy4GI-ZwDbHEYg8jxe1aSVRM2VG34_vQaU-o3N4vuFhyzXR8QW6N7ICtgLreqeKtTEfF7cLQ/s1600/resultado.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmNHlmJs2ZpQ5Xaz7ZYQ_omnl1ETbscfrQRNvunmRGb3RStZcHOI5iPcwF2ZsZvXuy4GI-ZwDbHEYg8jxe1aSVRM2VG34_vQaU-o3N4vuFhyzXR8QW6N7ICtgLreqeKtTEfF7cLQ/s640/resultado.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 6 - Leaflet consumindo a camada WMS com o SLD criado</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com3tag:blogger.com,1999:blog-38486525.post-29162129947801532612015-07-15T09:15:00.004-03:002015-07-15T09:27:50.728-03:00Análises Espaciais com o PostGIS Raster - Parte 2Na <a href="http://profmarcello.blogspot.com.br/2015/07/analises-espaciais-com-o-postgis-raster.html" target="_blank">postagem anterior</a>, vimos como fazer a conversão e importação de um arquivo raster para um Banco de Dados Espaciais.<br />
<br />
A seguir serão demostradas algumas consultas e análises com os dados da tabela <b>uso_ocupacao_solo</b>.<br />
<br />
<h2>
1) Obtendo Metadados</h2>
<div>
<br /></div>
<div>
Para visualizar os metadados de um registro da tabela raster, podemos utilizar a seguinte consulta:<br />
<br /></div>
<script src="https://gist.github.com/marcellobenigno/9e522374ac4246a1bb08.js"></script>
<br />
Como resultado, são exibidos diversos valores, tais como: coordenadas do canto superior (esquerdo e direito), tamanho do pixel, SRID , número de bandas, valores NODATA, dentre outros exibidos na Figura 1.<br />
<div>
<br /></div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcJMZmZ1r0mLNLCZuyyLd0BGNFjfHTKlyyN_HZDwWFNDAhke3Z2roF9IhKV-Dk6h-qr4iTGF0-aHNCIwNmR1tgLvRUh6b3LEpSK2jOjUHHmILqk-UhMWJYPRvlV-mXx5JMe1lx1g/s1600/saida1.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="51" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcJMZmZ1r0mLNLCZuyyLd0BGNFjfHTKlyyN_HZDwWFNDAhke3Z2roF9IhKV-Dk6h-qr4iTGF0-aHNCIwNmR1tgLvRUh6b3LEpSK2jOjUHHmILqk-UhMWJYPRvlV-mXx5JMe1lx1g/s640/saida1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Obtendo Metadados</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
Outro dado importante é o espaço ocupado pela tabela no HD, obtido através da seguinte consulta:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/af51882859f8c830fc58.js"></script>
<br />
<h2>
2) Interseção da Tabela Raster com um Município</h2>
<div>
<br />
Exemplo: gerar uma nova tabela a partir do recorte (clip) do uso e ocupação do solo em função dos limites do município de Ibitinga (Figura 2).</div>
<div>
<br />
<script src="https://gist.github.com/marcellobenigno/9bcbfb19d61fd8ed827a.js"></script>
Por padrão, operações que geram novas geometrias envolvendo tabelas de diferentes tipos (raster/vetor) geram vetores a partir da poligonização do raster. A Figura 2 mostra o resultado da tabela criada no QGIS:<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDWjikWzppmq-TY_bqI7nZO5jM99UjhCpgQ5p5gj9zJ9PKuCEi4PsHPfakU5y0dSItD3wyKqdDb4Z1HoP8uAJzHrE0Otj1rH8Ckgfss5vUjmV_-BPoYjvxwHlYEyfT_grTLmd1Vw/s1600/ibitinga.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDWjikWzppmq-TY_bqI7nZO5jM99UjhCpgQ5p5gj9zJ9PKuCEi4PsHPfakU5y0dSItD3wyKqdDb4Z1HoP8uAJzHrE0Otj1rH8Ckgfss5vUjmV_-BPoYjvxwHlYEyfT_grTLmd1Vw/s640/ibitinga.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Clip entre a tabela raster e o município de Ibitinga</td></tr>
</tbody></table>
<br /></div>
<div>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<h2>
</h2>
<div>
<br /></div>
<h2>
</h2>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div>
As dimensões de cada polígono desta tabela são equivalentes a resolução espacial do raster, definido na importação com o comando <a href="http://postgis.refractions.net/docs/using_raster.xml.html#RT_Loading_Rasters" target="_blank">raster2pgsql</a>.<br />
<br /></div>
<h2>
3) Quantificando o Resultado</h2>
<br />
Exemplo: qual é a área total de cada classe de uso no município de Ibitinga, em hectares?<br />
<br />
<script src="https://gist.github.com/marcellobenigno/d54c28c159a8cbffc1c3.js"></script>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
O resultado da consulta pode ser visto na Figura 3:<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDd_P2IxV00PmWUtZOlqN_BexhCZrZKjt7MNFn5gb1Pl6ZejBCh6a3q6S2tpoyeYg6FFYEYDMaAphwyiEihchwcDI_KRqhdbQ_rWaOCxPugh4ETFYN9cYJE-CRBM0cqkwYBWPQ-g/s1600/sum.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDd_P2IxV00PmWUtZOlqN_BexhCZrZKjt7MNFn5gb1Pl6ZejBCh6a3q6S2tpoyeYg6FFYEYDMaAphwyiEihchwcDI_KRqhdbQ_rWaOCxPugh4ETFYN9cYJE-CRBM0cqkwYBWPQ-g/s640/sum.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Área total de cada classe de uso</td></tr>
</tbody></table>
<br />
<h2>
<br />
</h2>
<h2>
</h2>
<h2>
</h2>
<div>
<br /></div>
<div>
Também é possível realizar esta mesma consulta no terminal e exportar o resultado para CSV, através do comando:</div>
<div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.1999998092651px; line-height: 18.4799995422363px; text-align: justify;">
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span>psql sp -c "copy ( SELECT dn, SUM(ST_Area(geom::geography)) / 10000 AS area_ha FROM uso_ocupacao_ibitinga GROUP BY dn ORDER BY dn ) to STDOUT WITH CSV" -o sum.csv</pre>
<div>
<br /></div>
</div>
</div>
<h2>
4) Análise de Buffer</h2>
<br />
Exemplo: determinar o uso e ocupação do solo para um buffer com raio de 500 metros, em torno do rio formado pelos trechos com os seguintes gids: 8530, 8560, 8561, 8562, 8578, 8590, 8591, 8592,8595 (Figura 4).<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJcdCPymJwzGzACncagih1q4tqD-1-5T8SEQpNkbROnoJgHtP9TYAMhxE_TE7-tO2VnKAiarM-VhJkmint0vMhVNrUKlx_zBCRlUI-D9Mkw8GHktIiLcr4q7ecN9HG02HJXYOOQ/s1600/rio.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJcdCPymJwzGzACncagih1q4tqD-1-5T8SEQpNkbROnoJgHtP9TYAMhxE_TE7-tO2VnKAiarM-VhJkmint0vMhVNrUKlx_zBCRlUI-D9Mkw8GHktIiLcr4q7ecN9HG02HJXYOOQ/s400/rio.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 4 - Trechos que compõem o rio a ser analisado</td></tr>
</tbody></table>
<div>
<br /></div>
<div style="text-align: left;">
</div>
<div>
<div>
</div>
</div>
<script src="https://gist.github.com/marcellobenigno/2f7b14e80f0fc53b435b.js"></script>
Desta forma podem ser analisadas as classes de uso e ocupação do solo que estão dentro do buffer. O resultado pode ser visto na Figura 5:
<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5N1GD8h-Wmeg7Q_iq9MI0WqvtdvcpUFFgglg-pwcsml4U6ZAfNXy2S_cT2v6kD5XVzur2cZk_YomwN6Y6_Y9Bn6vQXl_twyUKphHW2WxZD_nsx5-i_mKpMRrmRA2s817nLEJ0A/s1600/buffe.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5N1GD8h-Wmeg7Q_iq9MI0WqvtdvcpUFFgglg-pwcsml4U6ZAfNXy2S_cT2v6kD5XVzur2cZk_YomwN6Y6_Y9Bn6vQXl_twyUKphHW2WxZD_nsx5-i_mKpMRrmRA2s817nLEJ0A/s640/buffe.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 5 - Resultado do buffer com as classes de uso e ocupação do solo</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-2844092242992031052015-07-08T17:28:00.004-03:002015-07-18T07:37:55.466-03:00Análises Espaciais com o PostGIS Raster - Parte 1<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>PT-BR</w:LidThemeOther>
<w:LidThemeAsian>JA</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
<w:UseFELayout/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false"
DefSemiHidden="false" DefQFormat="false" DefPriority="99"
LatentStyleCount="380">
<w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index 9"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" Name="toc 9"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="header"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footer"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="index heading"/>
<w:LsdException Locked="false" Priority="35" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of figures"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="envelope return"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="footnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="line number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="page number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote reference"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="endnote text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="table of authorities"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="macro"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="toa heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Bullet 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Number 5"/>
<w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Closing"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Signature"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="true"
UnhideWhenUsed="true" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="List Continue 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Message Header"/>
<w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Salutation"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Date"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text First Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Heading"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Body Text Indent 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Block Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Hyperlink"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="FollowedHyperlink"/>
<w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Document Map"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Plain Text"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="E-mail Signature"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Top of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Bottom of Form"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal (Web)"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Acronym"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Address"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Cite"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Code"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Definition"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Keyboard"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Preformatted"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Sample"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Typewriter"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="HTML Variable"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Normal Table"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="annotation subject"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="No List"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Outline List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Simple 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Classic 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Colorful 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Columns 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Grid 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table List 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table 3D effects 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Contemporary"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Elegant"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Professional"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Subtle 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Web 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Balloon Text"/>
<w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Table Theme"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 1"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 2"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 3"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 4"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 5"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 6"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 7"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 8"/>
<w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
Name="Note Level 9"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" QFormat="true"
Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" QFormat="true"
Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" QFormat="true"
Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" QFormat="true"
Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" QFormat="true"
Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" QFormat="true"
Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" SemiHidden="true"
UnhideWhenUsed="true" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" SemiHidden="true"
UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
<w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
<w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
<w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
<w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
<w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
<w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
<w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="Grid Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="Grid Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="Grid Table 7 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
<w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
<w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 1"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 1"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 2"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 2"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 3"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 3"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 4"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 4"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 5"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 5"/>
<w:LsdException Locked="false" Priority="46"
Name="List Table 1 Light Accent 6"/>
<w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
<w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
<w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
<w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
<w:LsdException Locked="false" Priority="51"
Name="List Table 6 Colorful Accent 6"/>
<w:LsdException Locked="false" Priority="52"
Name="List Table 7 Colorful Accent 6"/>
</w:LatentStyles>
</xml><![endif]-->
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tabela normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Calibri;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
</style>
<![endif]-->
<!--StartFragment-->
<!--EndFragment-->
<br />
<div>
<div style="text-align: justify;">
O projeto <a href="https://trac.osgeo.org/postgis/wiki/WKTRaster" target="_blank">PostGIS Raster</a> possibilita o armazenamento e manipulação de dados matriciais em Banco de Dados Espaciais através da linguagem SQL.</div>
<div style="text-align: justify;">
<br /></div>
<div>
<div style="text-align: justify;">
Nesta série de tutoriais, serão demonstradas algumas funcionalidades desta extensão através da utilização dos dados de uso e ocupação do solo da mesorregião de Aracicaba (SP) e adjacências. Os dados podem ser obtidos através deste link: <a href="http://ge.tt/1Hye7zJ2/v/0?c" target="_blank">http://ge.tt/1Hye7zJ2/v/0?c</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Caso você ainda não tenha o PostgreSQL e o PostGIS instalados no Ubuntu, este post descreve o processo: <a href="http://profmarcello.blogspot.com.br/2013/10/instalacao-do-postgis-20-no-ubuntu-via.html" target="_blank">Instalação do PostGIS 2.0 no Ubuntu via Terminal</a></div>
<br /></div>
<h2 style="text-align: justify;">
1) Criação do Banco de Dados Espaciais</h2>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Com o terminal aberto, entre com o comando:</div>
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ </span>createdb sp</pre>
<br />
<div>
Uma vez criado o Banco de Dados, deve-se então habilitar a extensão PostGIS no mesmo:<br />
<div>
<span style="font-size: x-small;"><br /></span></div>
</div>
<div style="text-align: justify;">
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-size: 13.1999998092651px; line-height: 18.4799995422363px; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: x-small; line-height: 1.4;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; line-height: 22px;"><span style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace;">psql sp
psql (9.4.4)
Type "help" for help.
postgis=# <span style="color: red;">CREATE EXTENSION postgis;</span></span></span></pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Digite <b>\q</b> para sair do Banco de Dados.<br />
<br />
<div>
<h2>
2) Conversão do arquivo Raster para SQL</h2>
<div>
<br /></div>
<div>
Para realizar a conversão, abra o terminal e navegue até o diretório onde o arquivo <b>uso_ocupacao.tif</b> se encontra, em seguida, execute o seguinte comando:</div>
</div>
<div>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span>raster2pgsql -s 4326 -I -M -C uso_ocupacao.tif -F -t 30x30 uso_ocupacao_solo > uso_ocupacao_solo.sql</pre>
</div>
<div>
<br /></div>
<div style="text-align: start;">
Cada flag, que são as letras iniciadas com um "-" determina uma propriedade no arquivo sql que é gerado, neste caso em específico, temos:</div>
<div style="text-align: start;">
</div>
<ul>
<li><b>-s</b> : sistema de referência espacial do raster (<a href="http://spatialreference.org/ref/epsg/wgs-84/" target="_blank">SRID 4326</a>)</li>
<li><b>-I</b>: cria um índice GiST na coluna do raster</li>
<li><b>-M</b>: adiciona um "<i>Vacuum analise</i>" ao script</li>
<li><b>-C</b>: cria as <i>constraints</i> da tabela raster</li>
<li><b>-F</b>: adiciona uma coluna com o nome do arquivo</li>
<li><b>-t</b> 30×30: resolução espacial do raster</li>
</ul>
<br />
<div style="text-align: start;">
Outras opções sobre as flags e sobre o <a href="http://postgis.refractions.net/docs/using_raster.xml.html#RT_Loading_Rasters" target="_blank">raster2pgsql</a> podem ser encontradas no link:</div>
<div style="text-align: start;">
<br /></div>
<div style="text-align: start;">
<a href="http://postgis.refractions.net/docs/using_raster.xml.html#RT_Loading_Rasters">http://postgis.refractions.net/docs/using_raster.xml.html#RT_Loading_Rasters</a></div>
<div style="text-align: start;">
<br /></div>
<div style="text-align: start;">
Agora é possível carregar todos os arquivos no Banco de Dados (municipios.sql, hidrografia.sql e uso_ocupacao_solo.sql) através de um único comando:</div>
<div>
<br /></div>
</div>
<div style="text-align: justify;">
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="color: #222222; font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="color: #222222; font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent; text-align: justify;">for f in *.sql; do psql -f $f -d sp; done</span></pre>
</div>
<div style="text-align: justify;">
<pre class="lang-sql prettyprint prettyprinted" style="border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"></pre>
</div>
</div>
<div>
<h2>
<span style="text-align: justify;">3) Visualização das tabelas no QGIS:</span></h2>
<br />
Uma vez configurada a conexão entre o QGIS e o Banco PostGIS, através do plugin <a href="http://docs.qgis.org/1.8/en/docs/user_manual/plugins/plugins_db_manager.html" target="_blank">DB Manager</a> podemos então visualizar as tabelas do tipo raster, como mostra a Figura 1:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qrtJUw4opWrV5Di_KBu85zb4OhQ-RHHCo9MW6Jl7QZ5_Bs4Yhyphenhyphen_Ly-Kszu1m7pNIWGAV_QLKu0RTR2PDtfKLIPNFPxaZwposnz15PURAJpkueEa-gdbu7T-7sazOGG5vEGoD_Q/s1600/dbmanager.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="448" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qrtJUw4opWrV5Di_KBu85zb4OhQ-RHHCo9MW6Jl7QZ5_Bs4Yhyphenhyphen_Ly-Kszu1m7pNIWGAV_QLKu0RTR2PDtfKLIPNFPxaZwposnz15PURAJpkueEa-gdbu7T-7sazOGG5vEGoD_Q/s640/dbmanager.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Com o botão direito do mouse é possível escolher a opção "Add to canvas"</td></tr>
</tbody></table>
<br />
Para melhor representação visual da tabela, clique com o botão direito no layer e em "Properties -> Style" realize o ajuste exibido na Figura 2:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTtx5I7Db1ISf7stHIatokGykqA79MXvIacCxcqdK9fZNU9iKzpTlj6HZXajCcO6-ODfvqH45WKjq9v-VFv7e6zejInKXlv3RpSVSlOu0jQ6oq7yS3AnoQvtQl7JpD5ynfLAW0_Q/s1600/tematico.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTtx5I7Db1ISf7stHIatokGykqA79MXvIacCxcqdK9fZNU9iKzpTlj6HZXajCcO6-ODfvqH45WKjq9v-VFv7e6zejInKXlv3RpSVSlOu0jQ6oq7yS3AnoQvtQl7JpD5ynfLAW0_Q/s640/tematico.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Ajuste das cores do mapa temático</td></tr>
</tbody></table>
<br />
A Figura 3 mostra como deve ficar o resultado no QGIS.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfCAK4LO-MqXXPxiedM8iQDQBPLohkPjjBpGL_9aRaDvlHEUuZNPjcneBaGhrzmWdsmtCGECU4dlFgrcDN7F7f4Q4TZxWKuZJ4WfyJs0qKL2aHJsBH1hEkjpYpEYGJUmw15HnWog/s1600/area_estudo.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="402" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfCAK4LO-MqXXPxiedM8iQDQBPLohkPjjBpGL_9aRaDvlHEUuZNPjcneBaGhrzmWdsmtCGECU4dlFgrcDN7F7f4Q4TZxWKuZJ4WfyJs0qKL2aHJsBH1hEkjpYpEYGJUmw15HnWog/s640/area_estudo.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Mapa de uso e ocupação do solo</td></tr>
</tbody></table>
<br />
No próximo post demonstrarei algumas consultas e análises espaciais úteis utilizando os dados desta tabela, através da linguagem SQL... até breve :)</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com3tag:blogger.com,1999:blog-38486525.post-72476199753697328202015-04-18T09:51:00.002-03:002015-04-26T21:08:39.993-03:00Instalação do Laravel 5 no Ubuntu 14.10<div style="text-align: justify;">
O <i>framework</i> <a href="http://laravel.com/" target="_blank">Laravel</a> é atualmente um dos mais bem conceituados no mundo PHP. Isso se dá não apenas por conta do seu código limpo e elegante, mas também pela suave curva de aprendizado, recursos oferecidos, facilidade de uso e uma boa documentação.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Neste post, será demonstrado a instalação do mesmo no Ubuntu 14.10 utilizando o Terminal. Alguns pacotes e configurações descritos são opcionais, principalmente para quem não trabalha com desenvolvimento Webmapping.</div>
<br />
<h2>
<span style="font-size: large;">
1) Atualizando o Ubuntu:</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo apt-get </span><span style="background-color: transparent;">update && sudo apt-get upgrade -y</span></pre>
<br />
<h2>
<span style="font-size: large;">
2) Servidor Apache</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo</span><span style="background-color: transparent;"> apt-get install apache2</span></pre>
<br />
Em seguida, deve-se configurar as permissões do seu usuário na pasta de html. Substitua a palavra "<b>marcello</b>" pelo nome do seu <b>usuário</b>:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">s</span><span style="background-color: transparent;">udo adduser marcello www-data</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">s</span><span style="background-color: transparent;">udo chown marcello:www-data -R /var/www/html</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo chmod 755 -R /var/www/html</span></pre>
<h2>
<span style="font-size: large;"><br /> 3) PHP 5</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo</span><span style="background-color: transparent;"> apt-get install php5</span></pre>
<br />
Criação o arquivo info.php dentro do diretório /var/www/html:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">cd /var/www/html/</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">t</span><span style="background-color: transparent;">ouch info.php</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">e</span><span style="background-color: transparent;">cho </span><span style="background-color: transparent;">'</span><span style="background-color: transparent;"><?php phpinfo(); ?></span><span style="background-color: transparent; line-height: 1.4;">' >> info.php</span></pre>
<br />
Abra o browser e verifique a instalação: <a href="http://localhost/info.php">http://localhost/info.php</a><br />
<br />
<h2>
<span style="font-size: large;">
4) PostgreSQL / PostGIS (opcional)</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">apt-get install postgresql-9.4-postgis-2.1 pgadmin3</span></pre>
<br />
Troque o seu usuário para o usuário postgres com os comandos:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo su</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">su postgres</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="color: #222222; font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; color: #222222;">postgre</span><span style="background-color: transparent;"><span style="color: #222222;">s@ubuntu:/home/marcello$ createuser -s </span><span style="color: red;"><seu_usuario></span><span style="color: #222222;"> -P</span></span></pre>
<br />
<h2>
<span style="font-size: large;">
5) Módulo PostgreSQL para o PHP 5</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">apt-get install php5-pgsql</span></pre>
<br />
<h2>
<span style="font-size: large;">
6) Extensão Mcrypt</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">apt-get install php5-mcrypt</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">php5enmod mcrypt</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo</span><span style="background-color: transparent;"> service apache2 reload</span></pre>
<br />
<h2>
<span style="font-size: large;">
7) Habilitando o mod_rewrite</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">a2enmod rewrite</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">service apache2 restart</span></pre>
<br />
Abra o arquivo:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">nano /etc/apache2/sites-available/000-default.conf</span></pre>
<br />
Procure por “<b>DocumentRoot /var/www/html</b>” e adicione as linhas a seguir logo abaixo:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="line-height: 12.6000003814697px;"><Directory "/var/www/html">
AllowOverride All
</Directory></span></span></pre>
<br />
Saia do nano digitando <b>control x</b>, confirme as modificações (<b>y</b>) e por último tecle <b>ENTER</b>. Reinicie o servidor novamente:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">service apache2 reload</span></pre>
<br />
<h2>
<span style="font-size: large;">
8) Composer</span></h2>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">apt-get install curl</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">curl -sS https://getcomposer.org/installer | php</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">mv composer.phar /usr/local/bin/composer</span></pre>
<br />
<h2>
<span style="font-size: large;">
9) Nosso primeiro projeto com o Laravel 5</span></h2>
Na pasta <b>/var/www/html/</b>, execute o comando abaixo para realizar a instalação do Laravel:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="color: #222222; font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; color: #222222;">co</span><span style="background-color: transparent; color: #222222;">mposer create-project laravel/laravel</span><span style="background-color: transparent;"><span style="color: #222222;"> </span><span style="color: red;"><nome-do-projeto></span><span style="color: #222222;"> </span></span><nome-do-projeto style="background-color: transparent; color: #222222;">--prefer-dist</nome-do-projeto></pre>
<br />
Neste exemplo, o nome do nosso projeto será <b>sirh</b>. Em seguida entre na pasta e execute os comando a seguir:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">c</span><span style="background-color: transparent;">d sirh</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo chm</span><span style="background-color: transparent;">od -R 777 storage/</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">php artisan serve</span></pre>
<br />
Temos então a aplicação funcionando no endereço <a href="http://localhost:8000/">http://localhost:8000</a><br />
<br />
<h2>
<span style="font-size: large;">
10) Criando um Virtual Host (opcional)</span></h2>
<div style="text-align: justify;">
Embora seja possível acessar o projeto atráves do comando anterior, eu particularmente prefiro acessar através de uma url com o seguinte formato <a href="http://nome-do-projeto.dev/">http://nome-do-projeto.dev</a>. Para isso é necessário configurar um Virtual Host, da seguinte forma:</div>
<div style="text-align: justify;">
</div>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">cd </span><span style="background-color: transparent;">/etc/apache2/sites-available</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo t</span><span style="background-color: transparent;">ouch sirh.dev.conf</span></pre>
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo nano </span><span style="background-color: transparent;">sirh.dev.conf</span></pre>
<br />
Coloque o conteúdo a seguir dentro do arquivo criado:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="color: #222222; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="line-height: 18.2000007629395px;"><VirtualHost *:80>
ServerName sirh.dev
DocumentRoot /var/www/html/sirh/public
<Directory /var/www/html/sirh/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</span></span><span style="color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; line-height: 18.2000007629395px;"></VirtualHost></span></pre>
<br />
<virtualhost></virtualhost>
Saia do nano digitando <b>control x</b>, confirme as modificações (<b>y</b>) e por último tecle <b>ENTER</b>. Será necessário ativar o VirtualHost com o comando:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">a2ensite sirh.dev.conf</span></pre>
<br />
Altere o arquivo de hosts...<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">nano /etc/hosts</span></pre>
<br />
...adicionando a seguinte linha ao final do arquivo:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">127.0.0.1 sirh.dev</span></pre>
<br />
Por último, reinicie o servidor Apache:<br />
<br />
<pre style="background-color: whitesmoke; border-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo </span><span style="background-color: transparent;">service apache2 reload</span></pre>
<br />
Acesse o link <a href="http://sirh.dev/">http://sirh.dev/</a>, você deverá ver a página inicial do Laravel:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjnAbjbivjccyBNgh2i6jLRhohtaEV9TBsOx6gRy6mVf_H4xtJv1UlA5HgTxsvW5nka_SgtAH4PV34ZDb916egCGlAKX-s82x9SojHLCW8jkRcOK497j_2Z9RNDb7699DRf6Nsnw/s1600/laravel.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjnAbjbivjccyBNgh2i6jLRhohtaEV9TBsOx6gRy6mVf_H4xtJv1UlA5HgTxsvW5nka_SgtAH4PV34ZDb916egCGlAKX-s82x9SojHLCW8jkRcOK497j_2Z9RNDb7699DRf6Nsnw/s1600/laravel.png" height="401" width="640" /></a></div>
<br />
<br />
Caso não consiga chegar até aqui, entre em <a href="http://profmarcello.blogspot.com.br/p/contato.html" target="_blank">contato</a> comigo, dúvidas e sugestões serão bem vindas.<br />
<br />
<h2>
<span style="font-size: large;">Referências:</span></h2>
Documentação do Laravel:<br />
<a href="http://laravel.com/docs/master">http://laravel.com/docs/master</a><br />
<br />
Iniciando um Novo Projeto no Laravel:<br />
<a href="http://magazine.softerize.com.br/tutoriais/php/laravel/iniciando-um-novo-projeto-laravel">http://magazine.softerize.com.br/tutoriais/php/laravel/iniciando-um-novo-projeto-laravel</a><br />
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com3tag:blogger.com,1999:blog-38486525.post-15922686168299305502015-01-02T13:26:00.000-03:002015-01-03T11:42:28.096-03:00Trabalhando com Formulários no QGIS<div style="text-align: justify;">
A criação de formulários personalizados no QGIS, é um recurso muito útil para o preenchimento dos campos de uma tabela de atributos. Vejamos então como isso funciona.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Neste exemplo será utilizada uma camada que representa os <b>postes </b>de iluminação pública de uma determinada área, com os seguintes campos (Figura 1):</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRoxlOVh5kFYzf66_y3AGWAR0-MCSl6dfVU_b7Ire5b73QAmGqNXkRpKjnwSPqcIiH0Nh4I0L0FaBtII4Fr5wL5of0izCXufWKRXsNLkd8zlBbc4mDwuEj7VjFGrjaSmSbpP2hBQ/s1600/1-tabela_de_atributos.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRoxlOVh5kFYzf66_y3AGWAR0-MCSl6dfVU_b7Ire5b73QAmGqNXkRpKjnwSPqcIiH0Nh4I0L0FaBtII4Fr5wL5of0izCXufWKRXsNLkd8zlBbc4mDwuEj7VjFGrjaSmSbpP2hBQ/s1600/1-tabela_de_atributos.png" height="336" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Campos da camada postes</td></tr>
</tbody></table>
<br />
<div>
Para cada campo deve ser criado um <b>Alias</b>, para facilitar o entendimento do usuário (Figura 2):</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizx76oqS4CLWUOco-LrYcSutwoWtGRCoxqBG_k9oF8OsKMVOBeFyzVh1Myfs0gLhwZ3vboTiTGS1xJ4P8xCCwfwifiNy75jbEkca0I8AeK7t4sKcwmzSPrcZjx2WPqf0eCVMXq3g/s1600/2-Alias.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizx76oqS4CLWUOco-LrYcSutwoWtGRCoxqBG_k9oF8OsKMVOBeFyzVh1Myfs0gLhwZ3vboTiTGS1xJ4P8xCCwfwifiNy75jbEkca0I8AeK7t4sKcwmzSPrcZjx2WPqf0eCVMXq3g/s1600/2-Alias.png" height="308" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Criação dos Aliases</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
O campo <b>manutencao</b> será definido como sendo do tipo <b>"Check Box"</b>, onde <b>0</b> será o valor para os postes que ainda não foram revisados e <b>1</b> o valor para os postes revisados (Figura 3):</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsmEb2jVVT4w56gUvSjKwWnGuU6ELOn6lc1-kNSNL4Sj7QEUZoGh1IJtQVQa4LVnbdDzvBxMty42a9g4MJ9_oDwEiW-zV63hyphenhyphenIcp6jscZlFNzcgaYt9CrK1oeQfAURkgyGxlXJqw/s1600/3-campo_manutencao.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsmEb2jVVT4w56gUvSjKwWnGuU6ELOn6lc1-kNSNL4Sj7QEUZoGh1IJtQVQa4LVnbdDzvBxMty42a9g4MJ9_oDwEiW-zV63hyphenhyphenIcp6jscZlFNzcgaYt9CrK1oeQfAURkgyGxlXJqw/s1600/3-campo_manutencao.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Definição do campo <b>manutencao</b> como Check Box</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
Para campos do tipo <b>Date</b>, é possível adicionar calendários "popup"<b> </b>para o preenchimento dos seus valores. O campo <b>data_manut</b> exemplifica o processo (Figura 4):</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJehO3vxJYaVhkVkkXmfrVCVNbZ1TjjMLz3D0ZQJQpgc9Hxbr6A1WmTmoQ-BaUGGWplEdnnpKr5JhyphenhyphenT3viPYFYYLC9X9fflonLSJcOETp9mG8Mc5k5Xo-3oB0JYqOZLqqzJ90jg/s1600/4-data_revisao.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJehO3vxJYaVhkVkkXmfrVCVNbZ1TjjMLz3D0ZQJQpgc9Hxbr6A1WmTmoQ-BaUGGWplEdnnpKr5JhyphenhyphenT3viPYFYYLC9X9fflonLSJcOETp9mG8Mc5k5Xo-3oB0JYqOZLqqzJ90jg/s1600/4-data_revisao.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 4 - Definição do campo <b>data_manut</b> como Date/Time</td></tr>
</tbody></table>
<div>
<br /></div>
<div style="text-align: justify;">
Para valores fixos, onde é mostrado uma lista contendo valores predeterminados, utiliza-se a opção <b>Value Map</b>. Este tipo de entrada de dado é muito útil, pois evita possíveis erros de digitação. Os campos <b>tipo_ilum</b> (Figura 5) e <b>cor_lampad</b> (Figura 6) são exemplos do uso desse recurso:</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9xF4wpl3H52hsWZWvhY07Tzhu0xHi8o0J4Rl80hR756Y-pqrRzcm7eZYMW_54Ht5-3ZJw2rkdl22OyOmGniIxS4_XhdQpoKxK5rdxkVmN8ZW0mIAyidvh1XZuiQsq2fhJoOkv3w/s1600/5-tipo_luminaria.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9xF4wpl3H52hsWZWvhY07Tzhu0xHi8o0J4Rl80hR756Y-pqrRzcm7eZYMW_54Ht5-3ZJw2rkdl22OyOmGniIxS4_XhdQpoKxK5rdxkVmN8ZW0mIAyidvh1XZuiQsq2fhJoOkv3w/s1600/5-tipo_luminaria.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 5 - Lista de valores para o campo <b>tipo_ilum</b></td></tr>
</tbody></table>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioFZXWdUYSnmvUASbjnmcvjmKCHO9v1tT4VeFp85WIFVRvg_Ci1VAg6USfWKdchgUU7LlpR4e44VXX7nYs31fV6GN1hukmjihbCvfBAexU6Oc-3LYMps46qK8McS-587njwQ9ViQ/s1600/6-Tipo_lampada.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioFZXWdUYSnmvUASbjnmcvjmKCHO9v1tT4VeFp85WIFVRvg_Ci1VAg6USfWKdchgUU7LlpR4e44VXX7nYs31fV6GN1hukmjihbCvfBAexU6Oc-3LYMps46qK8McS-587njwQ9ViQ/s1600/6-Tipo_lampada.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 6 - Lista de valores para o campo <b>cor_lampad</b></td></tr>
</tbody></table>
<br />
<div style="text-align: justify;">
Já a opção <b>Range</b> é útil quando um campo deve receber um valor a partir de uma variação de números. Também é possível definir o incremento ou <b>step</b>. Para este exemplo, o campo <b>qtde_lampa</b> é configurado da seguinte forma (Figura 7):</div>
<div style="text-align: justify;">
<br /></div>
<div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMj0pVlcaZmu0qUYdyxBxI5M0T4gqfJ_fdRtaFnBBlzrjgtBX3x734QDKlsuinENuwIedGjtoqERUB_VeHrVHCJ0ZrItLfuJoG8mrVkCqetPzuxpuQXEy6f9N3jKwsVQJJ6Q5w-g/s1600/7-Qtde_lampadas.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMj0pVlcaZmu0qUYdyxBxI5M0T4gqfJ_fdRtaFnBBlzrjgtBX3x734QDKlsuinENuwIedGjtoqERUB_VeHrVHCJ0ZrItLfuJoG8mrVkCqetPzuxpuQXEy6f9N3jKwsVQJJ6Q5w-g/s1600/7-Qtde_lampadas.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 7 - Definição do campo <b>qtde_lampa</b></td></tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Também é possível utilizar o recurso conhecido como "<i>autocomplete</i>", onde a medida que o usuário digita, são sugeridos valores que foram armazenados anteriormente. Para isso, deve-se escolher a opção <b>Unique Values</b>. O campo <b>tipo_poste </b>será utilizado como exemplo, a seguir (Figura 8):<b> </b></div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMK4NjoCpFatokZdW-XkOs4ZLJm9bRbUBi1tX6lUwTxProzKjLinBosi8fEuCrFeBR1U8TFDEmCOrwYa9yosdMZpoXC9mOELtK5yTHXsLTT3NAIMvan2EVljRj6yHQxw1oCoQHLw/s1600/8-tipo_poste.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMK4NjoCpFatokZdW-XkOs4ZLJm9bRbUBi1tX6lUwTxProzKjLinBosi8fEuCrFeBR1U8TFDEmCOrwYa9yosdMZpoXC9mOELtK5yTHXsLTT3NAIMvan2EVljRj6yHQxw1oCoQHLw/s1600/8-tipo_poste.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 8 - Habilitando o autocomplete no campo <b>tipo_poste</b></td></tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Para o campo <b>altura_pos</b> mais uma vez é escolhida a opção <b>Range</b>, como mostra a Figura 9:</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzKYFOb1lafwAfEhIeCp-NbGfd_-LhaijQRxAsEqmj7Mji4DTLM7caymslcz7D3DsKbJ0kmyZV8J1f-dkNY7l96P8UU_YErY1_RMrt1NXW5KFpLRMqkneW7Q-dAWWnlCY0ZujCAw/s1600/9-Altura_poste.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzKYFOb1lafwAfEhIeCp-NbGfd_-LhaijQRxAsEqmj7Mji4DTLM7caymslcz7D3DsKbJ0kmyZV8J1f-dkNY7l96P8UU_YErY1_RMrt1NXW5KFpLRMqkneW7Q-dAWWnlCY0ZujCAw/s1600/9-Altura_poste.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 9 - Campo <b>altura_pos</b></td></tr>
</tbody></table>
<div>
<br /></div>
<div>
Por último, para o campo <b>foto </b>deve-se escolher a opção<b> Photo</b>,<b> </b> dessa forma o QGIS exibirá uma miniatura da imagem escolhida (Figura 10).</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZCHiodyMQ2ErfpjIaC9KWwXGD_4ZN0OwKKUOPMYUFNh4STgenqE2_l4Ko9xCahX7c73SqM9YBnY7ATAv_mRBaGe8sjPjOPTs2DuLHxix0qYlRQy458G91V4X0s9q6duG9cxSnPg/s1600/10-foto.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZCHiodyMQ2ErfpjIaC9KWwXGD_4ZN0OwKKUOPMYUFNh4STgenqE2_l4Ko9xCahX7c73SqM9YBnY7ATAv_mRBaGe8sjPjOPTs2DuLHxix0qYlRQy458G91V4X0s9q6duG9cxSnPg/s1600/10-foto.png" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 10 - Campo <b>foto</b></td></tr>
</tbody></table>
<h3>
</h3>
<h3>
</h3>
<h3>
<br /></h3>
<h3>
O RESULTADO:</h3>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Ao entrar em modo de edição, o usuário terá um formulário personalizado que ajudará a diminuir a entrada de inconsistências por digitação... e o que é melhor, isso foi feito sem escrever uma só linha de código (Figura 11). </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9KxzV0AddgmKcsDPPFHlbfFWpn_gRqaTLEAjwTwqM4i6My6OmDhBpu4E23sm5E7HJ_erQ1FXWZaezH6PumtD07QAAJ4rgxgp2xH65gc-x4Rryck98uiwK-wS7Xd8kfOmROf-gg/s1600/11-Resultado.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf9KxzV0AddgmKcsDPPFHlbfFWpn_gRqaTLEAjwTwqM4i6My6OmDhBpu4E23sm5E7HJ_erQ1FXWZaezH6PumtD07QAAJ4rgxgp2xH65gc-x4Rryck98uiwK-wS7Xd8kfOmROf-gg/s1600/11-Resultado.png" height="531" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 11 - Resultado do formulário</td></tr>
</tbody></table>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-3829635467949541982014-10-18T08:46:00.003-03:002014-10-18T08:46:40.130-03:00A Função row_number() em Consultas de Agregação Espacial<div style="text-align: justify;">
Em Banco de Dados, as funções de agregação são utilizadas para agrupar valores de acordo com um ou vários campos, agregando em uma única linha o conteúdo de vários registros. Dessa forma, os detalhes da informação original são postos de lado e as informações são tratadas em conjunto. São exemplos de funções de agregação: count(), sum(), max(), avg(), dentre outras. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
As funções de agregação também são empregradas em dados espaciais, é o caso da função <a href="http://postgis.net/docs/ST_Union.html" target="_blank">ST_Union()</a>, onde os vértices adjacentes da nova camada são dissolvidos a partir dos valores armazenados em um campo específico. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Entretanto, para visualizar o resultado desta nova camada em um <i>software</i> de GIS ou de <i>Webmapping</i>, a maioria deles necessita que a camada tenha um campo com valores únicos. E é exatamente aí que a função <a href="http://www.postgresql.org/docs/9.2/static/functions-window.html" target="_blank">row_number() </a>se torna útil neste tipo de análise, permitindo gerar um campo “<b>ID</b>” (identificador único) a partir do número da linha dentro da consulta, de acordo com o “order by” informado. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Para ilustrar o uso função <a href="http://www.postgresql.org/docs/9.2/static/functions-window.html" target="_blank">row_number()</a>, vejamos o exemplo a seguir (Figura 1). Utilizando o <a href="http://www.qgis.org/" target="_blank">QGIS</a> e uma camada de um BD Espacial <a href="http://postgis.net/" target="_blank">PostGIS</a> é realizada uma agregação dos municípios a partir do campo “meso” (mesorregiões do estado). </div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBihdfuMR7h0405_uPAtialPRMCr5yqTAo2Ts6FbKnIKGdCTjp_LQMz6z_xlBxNT4sQTWRQ1kUeu1OuXVNK3fvOh6cSB3TSjdpaG8S0uT8_CiWvmW87rYh3IpxFXbzHv_BX9S9bQ/s1600/qgis2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBihdfuMR7h0405_uPAtialPRMCr5yqTAo2Ts6FbKnIKGdCTjp_LQMz6z_xlBxNT4sQTWRQ1kUeu1OuXVNK3fvOh6cSB3TSjdpaG8S0uT8_CiWvmW87rYh3IpxFXbzHv_BX9S9bQ/s1600/qgis2.png" height="564" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Consulta no DB Manager do QGIS</td></tr>
</tbody></table>
<div>
<br /></div>
<div style="text-align: justify;">
Desta forma, o campo <b>id</b> é criado e povoado através da função <a href="http://www.postgresql.org/docs/9.2/static/functions-window.html" target="_blank">row_number() </a>e o resultado pode ser visualizado no <a href="http://www.qgis.org/" target="_blank">QGIS</a> (Figura 2).</div>
<div>
<div>
<br /></div>
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt_WGZP7rRIf_hUAu_f6RVbRh5QnPqjNAK57g3n6-hh1Y0nBKZLIznrbZwOy3dpAHJ6CVM0EN910PIG_Y_Q-NfUt_6CtfWuV7VAnynSG7K689DVHaqdDU07AY0HR_NJ73Zx55edg/s1600/qgis3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt_WGZP7rRIf_hUAu_f6RVbRh5QnPqjNAK57g3n6-hh1Y0nBKZLIznrbZwOy3dpAHJ6CVM0EN910PIG_Y_Q-NfUt_6CtfWuV7VAnynSG7K689DVHaqdDU07AY0HR_NJ73Zx55edg/s1600/qgis3.png" height="401" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Resultado em forma de mapa temático</td></tr>
</tbody></table>
<div>
<br /></div>
<div style="text-align: justify;">
Existem outras formas de se obter o mesmo resultado do campo <b>id</b>, neste tipo de situação, porém, o emprego da função <a href="http://www.postgresql.org/docs/9.2/static/functions-window.html" target="_blank">row_number()</a> é muito simples, como foi demonstrado no exemplo.</div>
<div style="text-align: justify;">
<br /></div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-11405263427281055752014-08-17T09:42:00.000-03:002014-08-17T18:37:43.348-03:00WMS GetFeatureInfo Utilizando MapServer e Leaflet<div style="text-align: justify;">
No <a href="http://leafletjs.com/" target="_blank">Leaflet</a> existem duas formas bem usuais de se obter os dados tabulares de uma feição através do clique do usuário em uma determinada camada. Uma delas é através do uso de marcadores (<a href="http://leafletjs.com/examples/quick-start.html" target="_blank">Markers</a>), que é mais utilizada para a representação de pontos. A outra é o formato <a href="http://leafletjs.com/examples/geojson.html" target="_blank">GeoJSON</a>, que é uma excelente opção para exibir camadas de polígonos e de linhas neste aplicativo.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Porém, quando uma camada <a href="http://leafletjs.com/examples/geojson.html" target="_blank">GeoJSON</a> possui muitas feições ou uma grande quantidade de vértices, seu carregamento pode comprometer o desempenho do aplicativo. Uma saída para este problema é utilizar o formato <a href="http://mapserver.org/ogc/wms_server.html" target="_blank">WMS</a> habilitando a requisição <a href="http://mapserver.org/ogc/wms_server.html" target="_blank">GetFeatureInfo</a> como é mostrado no exemplo a seguir.</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
1 - Configuração do Mapfile como Servidor WMS:</h4>
<div>
<br /></div>
<div>
<span style="text-align: justify;">A configuração do servidor </span><a href="http://mapserver.org/ogc/wms_server.html" style="text-align: justify;" target="_blank">WMS</a><span style="text-align: justify;"> é feita através da definição dos itens obrigatórios para o seu funcionamento, a nível de </span><b style="text-align: justify;">MAP</b><span style="text-align: justify;"> e de </span><b style="text-align: justify;">LAYER</b><span style="text-align: justify;">, definidos na documentação do </span><a href="http://mapserver.org/" style="text-align: justify;" target="_blank">MapServer</a><span style="text-align: justify;"> no item "</span><a href="http://mapserver.org/ogc/wms_server.html#setting-up-a-wms-server-using-mapserver" style="text-align: justify;" target="_blank">Setting Up a WMS Server Using MapServer</a><span style="text-align: justify;">". </span><br />
<span style="text-align: justify;"><br /></span>
<script src="https://gist.github.com/marcellobenigno/3472c9d3961cdfe8c64e.js"></script>
<span style="text-align: justify;"><br /></span></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="text-align: justify;">
2 - Configuração do Template HTML para a requisição GetFeatureInfo:</h4>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div style="text-align: justify;">
Neste arquivo são definidos os dados que serão exibidos na janela de atributos através do GetFeatureInfo WMS Request. </div>
<br />
<script src="https://gist.github.com/marcellobenigno/e951f93ddd13575d62b7.js"></script>
<br />
<div style="text-align: justify;">
</div>
<h4 style="text-align: justify;">
3 - Configuração do Leaflet:</h4>
<div>
<br /></div>
<div>
<div style="text-align: justify;">
Para habilitar esta funcionalidade é necessário configurar a camada WMS no Leaflet, como é exibido a seguir:</div>
</div>
<div>
<br /></div>
<div style="text-align: justify;">
<script src="https://gist.github.com/marcellobenigno/93a5b633e2488e0bfbb1.js"></script>
Já com a função <b>IDENTIFY</b> abaixo, é possível associar ao clique do mouse uma requisição <b>GetFeatureInfo</b>, através da obtenção das variáveis <b>BBOX</b>, <b>WIDTH</b>, <b>HEIGHT</b>, <b>X</b> e <b>Y</b>. Com elas é definida a variável <b>URL</b> que fará esta requisição ao servidor WMS e trará o resultado de forma assíncrona com método <a href="http://api.jquery.com/jquery.get/" target="_blank">$.ajax</a> do <a href="http://jquery.com/" target="_blank">jQuery</a>.</div>
<div>
<br /></div>
<script src="https://gist.github.com/marcellobenigno/6e02f8a5cc69a1c90614.js"></script>
A página HTML contendo o Leaflet fica então desta forma:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/ae2a6ab716b1705b7f0b.js"></script>
<br />
<h4 style="text-align: justify;">
4 - Resultado:</h4>
<div>
<br />
Ao clicar em um município, é exibido uma janela contendo os atributos, como mostra a figura abaixo:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgycfzITUOPCICvoxdhXiCJRAs6hm9mgBybTDyUN56Zu6V83SUK-UhFFRX8Ec5qQuTLNVgj-ulfvNfGxiYD5Pz7ionOHW_hTlWynVCxj_L5fyoLsxm-KHHD-3GmQmQCUKq-0sEZDQ/s1600/Screenshot+from+2014-08-09+14:19:00.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgycfzITUOPCICvoxdhXiCJRAs6hm9mgBybTDyUN56Zu6V83SUK-UhFFRX8Ec5qQuTLNVgj-ulfvNfGxiYD5Pz7ionOHW_hTlWynVCxj_L5fyoLsxm-KHHD-3GmQmQCUKq-0sEZDQ/s1600/Screenshot+from+2014-08-09+14:19:00.png" height="512" width="640" /></a></div>
<br />
Você pode baixar os códigos deste exemplo neste <a href="http://ge.tt/6vN6qTr1/v/0" target="_blank">link</a>.<br />
<br />
<h3>
Sugestões de Leitura:</h3>
<div>
<br /></div>
<ul>
<li><a href="http://concani3.wordpress.com/2012/09/20/os-padroes-wms-e-wfs-do-consorcio-ogc-open-geospatial-consortium/" target="_blank"></a><a href="http://concani3.wordpress.com/2012/09/20/os-padroes-wms-e-wfs-do-consorcio-ogc-open-geospatial-consortium/" target="_blank">Os padrões WMS e WFS do consórcio OGC – Open Geospatial Consortium</a></li>
<li><a href="http://www.amazon.com/PostGIS-Cookbook-Paolo-Corti/dp/1849518661" target="_blank">PostGIS Cookbook (Capítulo 9 - PostGIS and the Web)</a></li>
</ul>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com3tag:blogger.com,1999:blog-38486525.post-26273146342068960952014-06-20T17:05:00.003-03:002014-06-21T21:42:47.987-03:00Instalação do i3Geo no Ubuntu 14.04<div style="text-align: justify;">
Estes dez passos te guiarão no processo de instalação do i3geo no Ubuntu 14.04.</div>
<br />
<b>1) Instalação do Mapserver</b><br />
<br />
<div style="text-align: justify;">
Para este primeiro item, realize os procedimentos descritos no post:<a href="http://profmarcello.blogspot.com.br/2014/04/instalacao-do-mapserver-no-ubuntu-1404.html" target="_blank"> Instalação do Mapserver no Ubuntu 14.04 via Terminal</a></div>
<br />
<b>2) Bibliotecas PHP necessárias para o funcionamento do i3geo:</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo apt-get install libapache2-mod-php5 php5-common php5-curl php5-dev php5-gd php5-odbc php5-pgsql php5-ps php5-xmlrpc php5-xsl php5-sqlite php5-imagick php5-json</span></pre>
<br />
Em seguida, reinicie servidor Apache:<br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo /etc/init.d/apache2 restart</span></pre>
<br />
<b>3) Instalação do do Banco de Dados sqlite:</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">sudo apt-get install sqlite</span></pre>
<br />
<b>4) Instalação do software estatístico R (item opcional)</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo apt-get install r-base r-base-core r-cran-maptools r-cran-spatstat</span></pre>
<br />
<b>5) Instalação do subversion (SVN)</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo apt-get install subversion</span></pre>
<br />
<b>6) Download do i3Geo</b><br />
<br />
<div style="text-align: justify;">
Para esta etapa, é necessário que você tenha uma conta no Portal do Software Público Brasileiro. Caso não possua, clique neste link: <a href="http://www.softwarepublico.gov.br/Registre-se">http://www.softwarepublico.gov.br/Registre-se</a> e crie sua conta, em seguida digite no terminal:</div>
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">svn checkout http://svn.softwarepublico.gov.br/svn/i3geo/i3geo/ /var/www/html/i3geo</span></pre>
<br />
e informe o seu email e senha cadastrada.<br />
<br />
<b>7) Altere as permissões do arquivo admin.db</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo chmod -R 755 /var/www/html/i3geo/admin/admin.db</span></pre>
<br />
<b>8) Crie a pasta ms_tmp dentro de /tmp</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo mkdir /tmp/ms_tmp && sudo chmod -R 755 /tmp/ms_tmp</span></pre>
<br />
<b>9) Crie um link simbólico dentro da pasta /var/www/html direcionando para /tmp/ms_tmp</b><br />
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: xx-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: xx-small;"><span class="nv" style="color: teal;"> </span></span><span style="background-color: transparent;">sudo ln -s /tmp/ms_tmp /var/www/html/ms_tmp</span></pre>
<br />
<b>10) Testanto a instalação:</b><br />
<br />
<div style="text-align: justify;">
Digite no <i>browser</i>: <a href="http://localhost/i3geo">http://localhost/i3geo</a>, você deverá ver uma tela semelhante a da figura abaixo. Caso ocorra algum erro, realize um teste de instalação através do link: <a href="http://localhost/i3geo/testainstal.php">http://localhost/i3geo/testainstal.php</a> (usuário admin, senha admin).</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9lhg9JG1TH21JD1mX5bs5X6JPdQSjRMTHO3L0u1ESYqdlLWRSazfq6q7sI4iqW7-TsKUm_23l08Fow8UgYeFD5FxR-g4dGw40wOOqDh5NociYty6FxKo_zxygbORMquagxprDcQ/s1600/i3geo2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9lhg9JG1TH21JD1mX5bs5X6JPdQSjRMTHO3L0u1ESYqdlLWRSazfq6q7sI4iqW7-TsKUm_23l08Fow8UgYeFD5FxR-g4dGw40wOOqDh5NociYty6FxKo_zxygbORMquagxprDcQ/s1600/i3geo2.png" height="480" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<h3>
Referência:</h3>
<a href="http://www.edmarmoretti.moodlelivre.com/course/view.php?id=2" target="_blank">Instalação e Administração do i3Geo - guia do administrador</a>Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-53371102283310248622014-06-16T18:34:00.001-03:002014-06-17T10:13:53.476-03:00Perfil Longitudinal do Rio Principal Utilizando o GRASS e o R<div style="text-align: justify;">
Por definição, o perfil longitudinal de um rio apresenta a relação existente entre a variação altimétrica e o comprimento do mesmo, desde a nascente até a foz ou ponto de confluência.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Neste tutorial daremos continuidade ao post "<a href="http://profmarcello.blogspot.com.br/2013/12/caracterizacao-morfometrica-de-bacias.html" target="_blank">Caracterização Morfométrica de Bacias Hidrográficas utilizando o GRASS</a>" onde a partir do rio principal, será gerado o gráfico do perfil longitudinal do mesmo, utilizando o <a href="http://grass.osgeo.org/" target="_blank">GRASS</a> e o <a href="http://www.r-project.org/" target="_blank">R</a>.<br />
<br />
Com o <a href="http://grass.osgeo.org/" target="_blank">GRASS</a> aberto no terminal, digite os comandos a seguir:</div>
<br />
<script src="https://gist.github.com/marcellobenigno/335a9635bb0a4cf94d77.js"></script>
Como resultado, teremos o gráfico abaixo:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8nOI2NXh4lSfcqjoYJHFrRGRC0iW4fkA8rZL6SrdTi16GIF9Q9q5dWNiEhWEOYqb4kTv3gpBuBwI8VpfwuspPAgODr-rmtr5jBQ-s69rlWbmo-Wpba_DB2b9OKsvCM9gkspqo6Q/s1600/grafico.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8nOI2NXh4lSfcqjoYJHFrRGRC0iW4fkA8rZL6SrdTi16GIF9Q9q5dWNiEhWEOYqb4kTv3gpBuBwI8VpfwuspPAgODr-rmtr5jBQ-s69rlWbmo-Wpba_DB2b9OKsvCM9gkspqo6Q/s1600/grafico.png" height="640" width="614" /></a></div>
<br />
<h4>
Referências:</h4>
<ul>
<li><a href="http://casoilresource.lawr.ucdavis.edu/drupal/node/375" target="_blank">Raster profile along arbitrary line segments</a> </li>
<li><a href="http://www.portailsig.org/content/grass-gis-et-r-superposition-des-couleurs-d-un-raster-quelconque-sur-un-profil-topographique" target="_blank">Grass Gis et R: superposition des couleurs d'un raster quelconque sur un profil topographique élaboré à partir d'un MNT</a></li>
</ul>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-3019555957049940212014-05-10T12:06:00.002-03:002014-05-11T08:06:31.131-03:00Aplicações WebGIS com o Laravel<div style="text-align: justify;">
Quem programa em PHP já deve conhecer ou ter ouvido falar sobre o <a href="http://laravel.com/" target="_blank">Laravel</a>. Uma coisa interessante neste framework é que é possível trabalhar com dados espaciais de forma muito prática.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
O código abaixo exemplifica a implementação da classe Obra, que no PostGIS é uma tabela espacial do tipo POINT.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Primeiro criamos a <a href="http://laravel.com/docs/migrations" target="_blank"><b>migration</b></a>:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<script src="https://gist.github.com/marcellobenigno/8b80f825c7309507d6cf.js"></script>
Após rodarmos a migration, criamos o <a href="http://laravel.com/docs/eloquent" target="_blank">model</a> <b>Obras.php</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<script src="https://gist.github.com/marcellobenigno/e626adbb9bd5146e9601.js"></script> No <b><a href="http://laravel.com/docs/controllers" target="_blank">controller</a></b> <b>ObrasConrtoller.php</b>, temos o método <b><span class="nf">postCreate</span></b><span class="p"><b>()</b>, que recebe os dados de uma view onde são informadas as coordenadas x e y através de um formulário (ou de alguma aplicação Webmapping como mostra a Figura 1). Tais coordenadas são checadas através do método estático</span><span class="na"> <b>checkCoords</b></span><b><span class="p">(</span><span class="nv">$x</span><span class="p">,</span> <span class="nv">$y</span></b><span class="p"><b>)</b> do model </span><span class="p"><b>Municipios.php</b>. Este método f</span>az a verificação das coordenadas informadas, que devem estar dentro dos limites do estado:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/4166f6373d8b2f2b6bf6.js"></script>
</div>
<div style="text-align: justify;">
<span class="p"> </span>
</div>
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: 0px; margin-right: 0px; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg55NNq6wyF_PsJyOzEDRw81Bmg5rhrISE5ulEH7ihNBPiqgY00Q6w4iVQyRLg4vmFLCqmaCmLvZJ2znFXnQJ5VUwUOpenRwoSdh56uCUyT-vPvnH8tKwi-LNWFquuYtiX-dx-tag/s1600/fig2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg55NNq6wyF_PsJyOzEDRw81Bmg5rhrISE5ulEH7ihNBPiqgY00Q6w4iVQyRLg4vmFLCqmaCmLvZJ2znFXnQJ5VUwUOpenRwoSdh56uCUyT-vPvnH8tKwi-LNWFquuYtiX-dx-tag/s1600/fig2.png" height="371" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Exemplo de View. </td></tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<script src="https://gist.github.com/marcellobenigno/b66d244e065a8e352708.js"></script> Embora o código aqui esteja bastante resumido, acredito que dá para se ter uma ideia do fluxo de trabalho neste framework, envolvendo dados espaciais. Qualquer dúvida ou melhoria no código serão bem vindas.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Um abraço e até a próxima o/</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-26657878460148992472014-04-19T11:06:00.000-03:002014-04-19T11:23:33.579-03:00Instalação do Mapserver no Ubuntu 14.04 via Terminal<br />
O <a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> 14.04 Trusty Tahr foi disponibilizado recentemente pela Canonical. Esta será uma versão LTS (Long Term Support) que terá suporte técnico durante 5 anos.<br />
<br />
Neste tutorial demonstrarei como instalar o <a href="http://mapserver.org/" target="_blank">MapServer</a> 6.4.1 nesta distribuição, utilizando o <a href="http://wiki.ubuntu-br.org/Terminal" target="_blank">Terminal</a>:<br />
<br />
<h4>
1 - Instalando o servidor Apache:</h4>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: x-small;"><span class="nv" style="color: teal;"> </span></span>sudo apt-get install apache2</pre>
<h4>
</h4>
<h4>
2 - Configurando as permissões do seu usuário na pasta de publicação:</h4>
<br />
Substitua a palavra "<b>marcello</b>" pelo nome do seu <b>usuário</b>:<br />
<br />
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo adduser marcello www-data<span style="font-size: x-small;"><span class="nv" style="color: teal;"> </span></span></pre>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo chown marcello:www-data -R /var/www<span style="font-size: x-small;"><span class="nv" style="color: teal;"> </span></span></pre>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo chmod 0755 -R /var/www</pre>
<div>
<h4>
</h4>
<h4>
3 – Instalando o PHP:</h4>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-get install php5</pre>
<h4>
</h4>
<h4>
4 – Instalando o Mapserver:</h4>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-get install cgi-mapserver mapserver-bin php5-mapscript</pre>
<h4>
</h4>
<h4>
5 – Habilitando o CGI no Apache:</h4>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>sudo a2enmod cgi && sudo service apache2 restart</pre>
<h4>
</h4>
<h4>
6 – Verificando a instalação do Mapserver CGI:</h4>
<br />
Abra o navegador e digite a url: <a href="http://localhost/cgi-bin/mapserv?" target="_blank">http://localhost/cgi-bin/mapserv?</a>, deverá surgir a seguinte mensagem:<br />
<br />
<div style="text-align: center;">
<span style="color: #990000;"><b><span style="font-family: Georgia,"Times New Roman",serif;"><span style="font-size: small;">No query information to decode. QUERY_STRING is set, but empty.</span></span></b></span></div>
</div>
<div>
<h4>
</h4>
<h4>
</h4>
<h4>
7 – Verificando a instalação do php-mapscript</h4>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>cd /var/www/html/</pre>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>touch info.php</pre>
</div>
<div>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span>echo '<?php phpinfo(); ?>' >> info.php</pre>
</div>
<div>
<div>
<br /></div>
<div>
Abra o navegador e digite a url: <a href="http://localhost/info.php" target="_blank">http://localhost/info.php</a>, procure pela seguinte ocorrência:<br />
<br />
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKehJ0xRdlWR9LdJyyTl7LTkQliNls-KM0uuiosZBYzelC9KzC-hBzwangyQfoZFTEb88yMJli6vmPFSUBkYg8QWk4E0LSa1CimmhZt7pxx7g8DZGWjFYAiRd-zx9KLhN0MCniXg/s1600/mapscript2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKehJ0xRdlWR9LdJyyTl7LTkQliNls-KM0uuiosZBYzelC9KzC-hBzwangyQfoZFTEb88yMJli6vmPFSUBkYg8QWk4E0LSa1CimmhZt7pxx7g8DZGWjFYAiRd-zx9KLhN0MCniXg/s1600/mapscript2.png" height="219" width="640" /></a></div>
<div>
<br /></div>
<div>
<br />
That's all folks! Um abraço e até a próxima!</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com2tag:blogger.com,1999:blog-38486525.post-90059309701342369302014-03-01T15:23:00.001-03:002014-07-20T17:42:48.541-03:00Mapas de relevo com a biblioteca GDALElaborei um script utilizando as bibliotecas <a href="http://www.gdal.org/" target="_blank">gdal</a> e <a href="http://www.imagemagick.org/" target="_blank">imagemagick</a> para criar mapas de relevo com o efeito Hillshade. Para rodá-lo, basta colocá-lo em uma pasta (como mostra a Figura 1) com os arquivos SRTM baixados da site da <a href="http://www.relevobr.cnpm.embrapa.br/download/%E2%80%8E" target="_blank">Embrapa</a>, junto com o shapefile contendo o limite da sua área de interesse e esta <a href="https://gist.github.com/marcellobenigno/9289976" target="_blank">palheta de cores</a>. Em seguida, é só digitar <b>./mosaic.sh</b><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmKL29En5aRw5sZj4qSljhhyphenhyphennAt1cR_v02201TB3gUjp7I9V7jot9DbTefrTG6neWwDKeWejs225n-hCRffObsUPmmSc9FRohP47PCU440C-_sc-QCDi5oZmWuDnyeIrYTQVPi0w/s1600/img11.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmKL29En5aRw5sZj4qSljhhyphenhyphennAt1cR_v02201TB3gUjp7I9V7jot9DbTefrTG6neWwDKeWejs225n-hCRffObsUPmmSc9FRohP47PCU440C-_sc-QCDi5oZmWuDnyeIrYTQVPi0w/s1600/img11.png" height="387" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Pasta contendo os arquivos necessários</td></tr>
</tbody></table>
<br />
Em função das cores definidas para cada cota no arquivo <a href="https://gist.github.com/marcellobenigno/9289976" target="_blank">my_classes.ctp</a>, o script cria um novo raster através do comando <a href="http://www.gdal.org/gdaldem.html" target="_blank">gdaldem</a> (Figura 2).<br />
<br />
<script src="https://gist.github.com/marcellobenigno/9289976.js"></script>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiogbFlpIwfxAFoZt8dBx-JLrXPG43zYGo7TVJTMHhB6fS5kMmTdxkpLrXyUl3ZTiY4rV7YiPWq3U4jJ3zELlx7bVUI9rwCdovGNAxuTHH5yCpSJ5sPN4JFnHXM_XrDOiXY-n1IJA/s1600/srtm_colorido_1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiogbFlpIwfxAFoZt8dBx-JLrXPG43zYGo7TVJTMHhB6fS5kMmTdxkpLrXyUl3ZTiY4rV7YiPWq3U4jJ3zELlx7bVUI9rwCdovGNAxuTHH5yCpSJ5sPN4JFnHXM_XrDOiXY-n1IJA/s1600/srtm_colorido_1.png" height="408" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Imagem SRTM colorida</td></tr>
</tbody></table>
<br />
Em seguida é gerado o arquivo Hillshade (Figura 3).<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD9MUtOmWO8gvokvnXNfb64XW4H8-Nifz-Uf3GBMUT324sAaZfT8GXAbAndhaVKajBshc9l5ySgoGt0ZxzB_RfvLpifQvP8JgRfSFy7pp1w15TMJER0fsheXVhu3iu19MFChMmtg/s1600/hillshade_1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD9MUtOmWO8gvokvnXNfb64XW4H8-Nifz-Uf3GBMUT324sAaZfT8GXAbAndhaVKajBshc9l5ySgoGt0ZxzB_RfvLpifQvP8JgRfSFy7pp1w15TMJER0fsheXVhu3iu19MFChMmtg/s1600/hillshade_1.png" height="408" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Relevo sombreado (Hillshade)</td></tr>
</tbody></table>
<br />
E os arquivos anteriores são unidos, como mostra a Figura 4.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjADJzMQ-wHtxI_Ei_R0EKr0vs3UrTmxCII8Xj9pnWN9irfMttxOCqiEeTRvKF-f3CExcB__i7fXU0Bt_d1AJ_4YBbiGyr0sR8Ijs3rPfuoSLLRWE_PnCl3ERAoCKxfLKFzT-9YiA/s1600/final_1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjADJzMQ-wHtxI_Ei_R0EKr0vs3UrTmxCII8Xj9pnWN9irfMttxOCqiEeTRvKF-f3CExcB__i7fXU0Bt_d1AJ_4YBbiGyr0sR8Ijs3rPfuoSLLRWE_PnCl3ERAoCKxfLKFzT-9YiA/s1600/final_1.png" height="408" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 4 - União do relevo sombreado com a imagem SRTM colorida</td></tr>
</tbody></table>
<br />
Por último, em função do limite do shapefile, o arquivo é "clipado". A Figura 5 mostra o resultado da utilização do script para o estado do Mato Grosso do Sul.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPnnfLaHMj0FNFtk6n32ny5hz94L7I2bfaKJheKkebV-FbYDHtwTY-3Z9yPsA5G-J-JjGQG7gPPWNTYhyphenhyphensMLQXxd_ImvA8GQzh0jqVwel3JzA840oa4w5CWw5JCYSDkKCQIEMhNA/s1600/final.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPnnfLaHMj0FNFtk6n32ny5hz94L7I2bfaKJheKkebV-FbYDHtwTY-3Z9yPsA5G-J-JjGQG7gPPWNTYhyphenhyphensMLQXxd_ImvA8GQzh0jqVwel3JzA840oa4w5CWw5JCYSDkKCQIEMhNA/s1600/final.png" height="564" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 5 - Resultado da utilização do script para o MS.</td></tr>
</tbody></table>
<br />
Lembrando que para utilizar o script, é necessário lhe dar permissões de execução após baixá-lo, através do comando abaixo:
<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ <span style="color: black;">sudo chmod +x mosaic.sh</span></span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;"></span></pre>
<script src="https://gist.github.com/marcellobenigno/9290207.js"></script><br />
<h3>
Referências:</h3>
<ul>
<li><a href="http://linfiniti.com/2010/12/a-workflow-for-creating-beautiful-relief-shaded-dems-using-gdal/" target="_blank">A workflow for creating beautiful relief shaded dems using GDAL</a></li>
<li><a href="http://developmentseed.org/blog/2009/jul/30/using-open-source-tools-make-elevation-maps-afghanistan-and-pakistan/" target="_blank">Creating Hillshades and Color Relief Maps Based on SRTM Data for Afghanistan and Pakistan</a></li>
<li><a href="http://thangbui.wordpress.com/2012/06/24/create-map-tiles-from-srtm-data-gdal-and-imagemagick/" target="_blank">Create map tiles from SRTM data, GDAL and ImageMagick</a></li>
<li><a href="http://blog.thematicmapping.org/2012/06/creating-hillshades-with-gdaldem.html" target="_blank">Creating hillshades with gdaldem</a></li>
</ul>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-2770838052011926492014-01-16T08:36:00.001-03:002014-01-25T18:29:07.762-03:00Conversão de Tabelas Espaciais para o Formato GeoJSON Utilizando PHPNeste exemplo irei utilizar o <a href="http://ellislab.com/codeigniter" target="_blank">CodeIgniter</a> para realizar a conversão de uma tabela espacial (rodovias) para o formato <a href="http://geojson.org/" target="_blank">GeoJSON</a>, utilizando <a href="http://ellislab.com/codeigniter/user-guide/overview/mvc.html" target="_blank">MVC</a>. <br />
<br />
Primeiro deve-se criar um <b>Model</b>. Com a função <i>geojson_output()</i>, observem que a geometria da tabela é convertida para <a href="http://geojson.org/" target="_blank">GeoJSON</a> e reprojetada para WGS-84:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/8453246.js"></script>
<br />
Em seguida o <b>Controller</b>, que vai receber os dados do<b> Model </b>e enviar para a<b> View</b>:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/8453425.js"></script>
<br />
Por último a <b>View</b>, que renderiza os dados no formato GeoJSON:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/8453456.js"></script>
<br />
Para ver os dados da tabela neste formato (Figura 1), é necessário acessar a url que contém o <b>"controller/método"</b> utilizado, no meu caso:<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="background-color: transparent; text-align: justify;">http://localhost/sirh/rodovias/geojson_link</span><span style="background-color: transparent; text-align: justify;"></span></pre>
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvKiJSPnEIjfiatwR2ebIVp-z_WtrJYpFFJswkEpWw1ggYjDlh_xzfmT0lmtHM7CJ3OENbEZtfeko6p_38bOQJ5CG2DYeDyt4XSTGPOuewCu2wWvZY8DSSLjcW9GzRkXb-Fdw-g/s1600/Captura+de+tela_2.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvKiJSPnEIjfiatwR2ebIVp-z_WtrJYpFFJswkEpWw1ggYjDlh_xzfmT0lmtHM7CJ3OENbEZtfeko6p_38bOQJ5CG2DYeDyt4XSTGPOuewCu2wWvZY8DSSLjcW9GzRkXb-Fdw-g/s1600/Captura+de+tela_2.png" height="408" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Resultado da conversão</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Seguindo a documentação do <a href="http://leafletjs.com/" target="_blank">Leaflet</a> é bastante simples carregar os dados neste formato. O resultado pode ser conferido na Figura 2.<br />
<br />
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwTBod3jMbmYZziknc6y53734dJyfG-QoHlS5gguNpRjiY9Qc0mEIOdz0CTA7AqEMTbX9Eq2HhGAFhGp2URhOmIQ6K4KaL9jCkA3HcK14RwMEyHTrHofSe3NvBBl6cLETMh1UXrg/s1600/Captura+de+tela.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwTBod3jMbmYZziknc6y53734dJyfG-QoHlS5gguNpRjiY9Qc0mEIOdz0CTA7AqEMTbX9Eq2HhGAFhGp2URhOmIQ6K4KaL9jCkA3HcK14RwMEyHTrHofSe3NvBBl6cLETMh1UXrg/s1600/Captura+de+tela.png" height="467" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - GeoJson exibido na interface do Leaflet</td></tr>
</tbody></table>
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-48083641141120650532013-12-03T11:18:00.000-03:002013-12-08T17:38:40.464-03:00Caracterização Morfométrica de Bacias Hidrográficas utilizando o GRASS<div style="text-align: justify;">
A <b>caracterização morfométrica</b> tem como objetivo esclarecer várias questões associadas ao relevo e a dinâmica do escoamento superficial de uma bacia hidrográfica. Tal caracterização é feita com base nas principais medidas físicas e serve de instrumento para diversas aplicações relacionadas aos recursos hídricos.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Utilizando a extensão <a href="http://grasswiki.osgeo.org/wiki/R.basin" target="_blank">r.basin</a> do <a href="http://grass.osgeo.org/" target="_blank">GRASS</a>, é possível extrair os atributos hidrológicos que compõem a caracterização morfométrica, para tanto, é necessário que o usuário informe a coordenada do exutório da bacia hidrográfica. Neste exemplo irei utilizar a imagem SRTM <a href="http://www.relevobr.cnpm.embrapa.br/download/pb/sb-24-z-c.htm" target="_blank">SB-24-Z-C</a> como área de estudo.</div>
<div style="text-align: justify;">
<br /></div>
<h3>
1 - Convertendo o sistema de projeção da imagem SRTM para UTM</h3>
<div>
<br /></div>
<div>
Utilizando o <a href="http://wiki.ubuntu-br.org/Terminal" target="_blank">terminal</a>, entre na pasta que contém a imagem e digite o seguinte comando:</div>
<div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent;">gdalwarp -s_srs "EPSG:4326" -t_srs "EPSG:31984" SB-24-Z-C.tif dem.tif</span><span style="font-size: x-small;">
</span></pre>
<div>
<span style="font-size: x-small;"><br /></span></div>
<div style="text-align: justify;">
Desta forma o raster será reprojetado para a projeção UTM Fuso 24 Sul (Datum SIRGAS 2000).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<h3 style="text-align: start;">
2 - Configurando a <i>Location</i> e o <i>Mapset</i> do GRASS</h3>
<div>
<br /></div>
<div>
Abra o GRASS na janela do <a href="http://wiki.ubuntu-br.org/Terminal" target="_blank">terminal</a> (digitando "grass") e siga os próximos passos:</div>
<div>
<br /></div>
<div>
<ul>
<li>Escolha <b><i>Location</i> <i>Wizard</i></b>:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj85bcIZC161dKdTnp9tha436dWg1-uc0MGIcM7LTwpbrFilR2UB8EO8AfE877pzNEhCKmupiojYWfrNkk1lwBJn333df4a9YsZUmfwUgLE7UqSH4OtIiFsT37QE-3b0_Q5x1xvRA/s1600/1-grass.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="624" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj85bcIZC161dKdTnp9tha436dWg1-uc0MGIcM7LTwpbrFilR2UB8EO8AfE877pzNEhCKmupiojYWfrNkk1lwBJn333df4a9YsZUmfwUgLE7UqSH4OtIiFsT37QE-3b0_Q5x1xvRA/s640/1-grass.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
</div>
<ul>
<li>Defina o nome da <i><b>Location</b></i> e clique em next:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGsYaOeAosz1Cs2r8quN0UUzgKlweAF4yQfXfTqUAbmHXsB9wIyy8be2EsHJShQy88qgH-rtve4h7rR63GRNOErGnAt9JeU0bXWWH5F-km4mxI1bAuatSJoy1Nhl0UP247tJ7ffg/s1600/2-titulo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="418" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGsYaOeAosz1Cs2r8quN0UUzgKlweAF4yQfXfTqUAbmHXsB9wIyy8be2EsHJShQy88qgH-rtve4h7rR63GRNOErGnAt9JeU0bXWWH5F-km4mxI1bAuatSJoy1Nhl0UP247tJ7ffg/s640/2-titulo.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<ul>
<li>Na próxima tela, escolha a opção indicada abaixo:</li>
</ul>
</div>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFWlQyq9DR_hnlz2Ii8J7Im6fC1xViAT0DlLPhREp-Kgq-XJvx1cAmpy_KO8pxWnnSrBHJ0W8TVdMQJ0B88-wz4XFJ5tdn3iCJ41zFm0jGbUZIvqJV8aSv3ug0wlB1H0nfTlda-g/s1600/3-definicao_location.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="418" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFWlQyq9DR_hnlz2Ii8J7Im6fC1xViAT0DlLPhREp-Kgq-XJvx1cAmpy_KO8pxWnnSrBHJ0W8TVdMQJ0B88-wz4XFJ5tdn3iCJ41zFm0jGbUZIvqJV8aSv3ug0wlB1H0nfTlda-g/s640/3-definicao_location.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<ul>
<li>Clique em "<b>Browse</b>" e procure o raster dem.tif:</li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4XgQ_iN9pluskCtSj4oxyoZ04HFOqWLdIcJeE6ar-jxkKt_5_NasFneAkA6yCqwXXl_1-DTKNixAQnOzSLUWntVFzoK1TPSK9c06S6O1Ahs_aDlk10r1Egvsj-Glbtm59S2Lg_w/s1600/4-dem.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="419" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4XgQ_iN9pluskCtSj4oxyoZ04HFOqWLdIcJeE6ar-jxkKt_5_NasFneAkA6yCqwXXl_1-DTKNixAQnOzSLUWntVFzoK1TPSK9c06S6O1Ahs_aDlk10r1Egvsj-Glbtm59S2Lg_w/s640/4-dem.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<ul>
<li>Será exibida a tela de sumário, clique em "<b>Finish</b>"</li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQfY99Tb3j_UQxzhb-Uo7-PavJn-97Ux6eu6ocUAu604T6ci3e8r12lpx_Yly4U2vVywdeGsfZPm47G8FwvqEjrIJmcVFOvwuvFoogwoyTc4sGyRh5BygXPAVsqDUdHW86OXkydA/s1600/5-finish.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="418" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQfY99Tb3j_UQxzhb-Uo7-PavJn-97Ux6eu6ocUAu604T6ci3e8r12lpx_Yly4U2vVywdeGsfZPm47G8FwvqEjrIJmcVFOvwuvFoogwoyTc4sGyRh5BygXPAVsqDUdHW86OXkydA/s640/5-finish.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<ul>
<li>No próximo passo, clique em "<b>Yes</b>":</li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcPcdym2Ej9y8HIEpY4-P1mQXONgYywo2j1ks_Ov0aPs1OC5c08e8gBpPrR6ymL09QLo0ey9lFE0ClkwNF_1obCSxCFlhFdc5kAk06CvtiKyd0fv3mOyom1F6Ej63wgmvHdulFfQ/s1600/6-importante.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="307" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcPcdym2Ej9y8HIEpY4-P1mQXONgYywo2j1ks_Ov0aPs1OC5c08e8gBpPrR6ymL09QLo0ey9lFE0ClkwNF_1obCSxCFlhFdc5kAk06CvtiKyd0fv3mOyom1F6Ej63wgmvHdulFfQ/s640/6-importante.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<ul>
<li>Defina o nome do <b>mapset</b> e clique em "<b>Start GRASS</b>":</li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWgFfvwnWutv_KI-beEJpUpbkoHyHrhIK3a1UV1k7g4yGxsLBo9PnAwt5UJ2IjQFzc5cnPF8RsezzT-Fvx5bNpEFN9EOmJ18TOqjbQi19D1fVGi0nvXHJQ35ne8sCSmgpaN9S8MQ/s1600/7-mapset.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="562" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWgFfvwnWutv_KI-beEJpUpbkoHyHrhIK3a1UV1k7g4yGxsLBo9PnAwt5UJ2IjQFzc5cnPF8RsezzT-Fvx5bNpEFN9EOmJ18TOqjbQi19D1fVGi0nvXHJQ35ne8sCSmgpaN9S8MQ/s640/7-mapset.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<h3 style="text-align: start;">
3 - Modificando as cores do Raster:</h3>
</div>
<div>
<br /></div>
<div>
No terminal onde a sessão do GRASS está aberto, digite:</div>
<div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">r.colors map=dem color=elevation</span><span style="font-size: x-small;">
</span></pre>
<div style="text-align: start;">
</div>
</div>
<div>
<div class="p1">
<br /></div>
<div class="p1">
Para visualizar o resultado no "<b>Map Display</b>", adicione esta camada através da opção "<b>Add rast map layer</b>" (Control + Shift + r):</div>
<div class="p1">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3wAS18Ecp8QkdOCbemJlwm-Sf_6aXQ0GMEYV3eh8di29bg_B7dbP1_eomTV3ziR3IQIexRp1aiB9AEbOIKDtTN4q8aX7iSCu9g7I0L9faLLmE8lUYx4d8k2VBM7ODhn-H120sZg/s1600/8-definindo_cores.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="483" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3wAS18Ecp8QkdOCbemJlwm-Sf_6aXQ0GMEYV3eh8di29bg_B7dbP1_eomTV3ziR3IQIexRp1aiB9AEbOIKDtTN4q8aX7iSCu9g7I0L9faLLmE8lUYx4d8k2VBM7ODhn-H120sZg/s640/8-definindo_cores.png" width="640" /></a></div>
<h3 style="text-align: start;">
</h3>
<div>
<br /></div>
<h3 style="text-align: start;">
4 - Preparando o MDE para a análise morfométrica:</h3>
<div class="p1">
<br /></div>
Com o comando <a href="http://grass.osgeo.org/grass64/manuals/r.fill.dir.html" target="_blank">r.fill.dir</a> são removidos os "sinks" (células cercadas por outras com maiores elevações), que produzem a descontinuidade do escoamento superficial descendente para uma célula vizinha.<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">r.fill.dir input=dem elevation=dem.filled </span><span style="background-color: transparent; text-align: justify;">direction=filled.dir</span></pre>
<h3 style="text-align: start;">
</h3>
<h3 style="text-align: start;">
</h3>
<br />
O próximo passo consiste em criar duas superfícies para análises hidrológicas através do comando <a href="http://grass.osgeo.org/grass64/manuals/r.watershed.html" target="_blank">r.watershed</a>, são elas: a superfície de fluxo acumulado (accumulation) e a rede de drenagem matricial (streams).</div>
<div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">r.watershed -fa elevation=dem.filled accumulation=accumulation \
stream=streams convergence=5 threshold=62</span></pre>
<h3 style="text-align: start;">
</h3>
<h3 style="text-align: start;">
</h3>
</div>
<div>
<b>OBS:</b> O <b>threshold</b> define o tamanho mínimo a ser considerado como uma área de contribuição para a bacia hidrográfica.<br />
Para áreas de 0,5 km<sup>2</sup> (500.000 m<sup>2</sup>) foi utilizado um valor igual a 62 (500.000 / 90x90), onde 90x90 é a resolução espacial de uma imagem SRTM).<br />
<br /></div>
<div>
<h3 style="text-align: start;">
5 - Instalando as extensões necessárias:</h3>
<div>
<br /></div>
Instale uma a uma, as extensões a seguir:<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.angle</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.basins</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.del</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.distance</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.extract</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.order</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.stream.pos</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="background-color: transparent; line-height: 1.4; text-align: justify;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; line-height: 1.4; text-align: justify;">g.extension extension=r.stream.preview</span></pre>
<div>
<span style="background-color: transparent; text-align: justify;">
</span></div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ g</span></span><span style="background-color: transparent; text-align: justify;">.extension extension=r.stream.stats</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.ipso</span></pre>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.wf</span></pre>
<br />
E por último, a extensão <a href="http://grasswiki.osgeo.org/wiki/R.basin" target="_blank">r.basin</a>:<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">g.extension extension=r.basin</span></pre>
<div>
<span style="background-color: transparent; text-align: justify;"><br /></span></div>
<br />
<h3 style="text-align: start;">
6 - Realizando a caracterização morfométrica:</h3>
<br />
Deve-se escolher como coordenada do exutório um ponto que toque a rede de drenagem matricial, neste caso a coordenada escolhida foi a seguinte: (<b>619.241,988946 E</b> || <b>9.207.668,119428 N</b>)<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: justify; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</div>
<pre style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #222222; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.4; margin: 9px 0px; orphans: auto; overflow-x: auto; padding: 5px 10px; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px;"><span style="font-size: x-small;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; text-align: justify;">r.basin map=dem.filled prefix=out \
easting=619241.988946 northing=9207668.119428 threshold=62</span></pre>
<div>
<br /></div>
<h3 style="text-align: start;">
7- Resultados:</h3>
</div>
<div>
<br /></div>
<div>
O comando <a href="http://grasswiki.osgeo.org/wiki/R.basin" target="_blank">r.basin</a> gera os seguintes resultados:</div>
<div>
<br /></div>
<div>
<ul>
<li>Layers: limite da bacia hidrográfica, rio principal, exutório e rede de drenagem da bacia:</li>
</ul>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv6uC7pLwEB6Cw1xU6Fcs_bs_rlhRDkBu2uPcqsO5-4MvWtfONRAYDAr6LBMbXLtM6OAhpYJ7Q10vSoAZHx8dtQ2wrk8bFN83ZHf-hlpQbjIOreQKSsNuWJ1ei2orl64qxcot4vg/s1600/resutado.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="542" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv6uC7pLwEB6Cw1xU6Fcs_bs_rlhRDkBu2uPcqsO5-4MvWtfONRAYDAr6LBMbXLtM6OAhpYJ7Q10vSoAZHx8dtQ2wrk8bFN83ZHf-hlpQbjIOreQKSsNuWJ1ei2orl64qxcot4vg/s640/resutado.png" width="640" /></a></div>
<div>
<ul>
<li>Gráfico: Curva hipsométrica:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdjedwb72Lmf5QOnDmRBWWLk574yjiMka2fczD1zmTSN_GucCX8zjCADhY79Dmjqv6IWKDUjE5MnzVB0s9HpHNQxs_VHQLfs_z9jmjFp742m4ZScnm1VkWefvmR1vATG_TdqB4JQ/s1600/out_dem_filled_Ipsometric.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdjedwb72Lmf5QOnDmRBWWLk574yjiMka2fczD1zmTSN_GucCX8zjCADhY79Dmjqv6IWKDUjE5MnzVB0s9HpHNQxs_VHQLfs_z9jmjFp742m4ZScnm1VkWefvmR1vATG_TdqB4JQ/s640/out_dem_filled_Ipsometric.png" width="640" /></a></div>
<div>
<br /></div>
</div>
<div>
<ul>
<li>Planilha: é gerado um arquivo csv contendo o resultado da análise:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjojBYfgRSR0SW-R3vJaJQoLV6XeT8vt1h7AMEaezidbKaZkOuax81m31irZpsr7jPy65WCf2GomQFG4rQIdyx6MVJQKDXL28_9XChWxcSSsjoGjjdZGKbwGPZUJVxoTprBhhv5yw/s1600/11-planilha.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="628" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjojBYfgRSR0SW-R3vJaJQoLV6XeT8vt1h7AMEaezidbKaZkOuax81m31irZpsr7jPy65WCf2GomQFG4rQIdyx6MVJQKDXL28_9XChWxcSSsjoGjjdZGKbwGPZUJVxoTprBhhv5yw/s640/11-planilha.png" width="640" /></a></div>
<div>
<br /></div>
</div>
<div>
<br /></div>
<div>
<ul>
<li>Saída no terminal:</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9TCjfMyS2fRXuJYQzqS65wNKV-xveZJ25_FeNbw8eftMMwk1FVWFF6RGBTLMTwtly_v9omhFpXpyG3EFR3FU8HSQIffclxl5d4wHTf4cGPqMdsAmQMMsI-In0P3FeyRVgdlOhFg/s1600/terminal.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9TCjfMyS2fRXuJYQzqS65wNKV-xveZJ25_FeNbw8eftMMwk1FVWFF6RGBTLMTwtly_v9omhFpXpyG3EFR3FU8HSQIffclxl5d4wHTf4cGPqMdsAmQMMsI-In0P3FeyRVgdlOhFg/s640/terminal.png" width="640" /></a></div>
<div>
<br /></div>
</div>
<div>
<br /></div>
</div>
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"></span></div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com7tag:blogger.com,1999:blog-38486525.post-34840752748110929192013-10-16T11:07:00.000-03:002013-11-11T08:20:45.646-03:00Instalação do PostGIS 2.0 no Ubuntu via Terminal<div style="text-align: justify;">
<span style="font-size: small;">Este tutorial é uma atualização da postagem: </span></div>
<ul style="text-align: justify;">
<li><a href="http://profmarcello.blogspot.com.br/2007/03/instalando-extenso-espacial-postgis-no_05.html">Instalando a Extensão Espacial PostGIS no Ubuntu – Guia Rápido</a> </li>
</ul>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
1 - Atualizando a Distribuição:</h4>
<h4 style="text-align: justify;">
</h4>
<div style="text-align: justify;">
<span style="font-size: small;">Antes de começar a instalação do PostGIS 2.0, é importante atualizar a lista de pacotes e realizar a atualização do sistema. Também é necessário adicionar os repositórios indicados pelo <a href="http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1204" target="_blank">Wiki do PostGIS</a>:</span><br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: small;">sudo apt-get install python-software-properties
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-add-repository ppa:sharpie/for-science
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-add-repository ppa:sharpie/postgis-stable
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>sudo apt-get update </span><span style="font-size: small;">&& sudo apt-get upgrade -y</span></pre>
</div>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
2 - Instalando o PostgreSQL, PostGIS e o PgAdmin:</h4>
<h4 style="text-align: justify;">
</h4>
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span>sudo apt-get install postgresql-9.1 postgresql-9.1-postgis-2.0 pgadmin3</span></pre>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
3 - Criando o banco de dados postgis:</h4>
<h4 style="text-align: justify;">
</h4>
<div style="text-align: justify;">
Troque o seu usuário para o usuário <b>postgres</b> com os comandos:</div>
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: small;">sudo su
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>su postgres
</span></pre>
E crie o banco de dados <b>postgis:</b>
<br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: small;">createdb postgis</span></pre>
Em seguida, crie um usuário para acessar o SGBD com o comando <b>createuser nome_do_usuario</b>, onde <b>nome_do_usuario</b> pode ser o seu usuário Ubuntu, no meu caso o comando ficou assim:<br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ <span style="color: black;">postgres@ubuntu:/home/marcello$ createuser marcello -P</span>
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) <span style="color: black;">y</span></span></span><span style="font-size: small;"></span></pre>
<div style="text-align: justify;">
No ambiente de desenvolvimento é mais prático que esta senha seja a mesma do seu usuário, porém isso é opcional. Agora troque o usuário postgres para o seu usuário, no meu caso:</div>
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: small;">su marcello</span></pre>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
4 - Carregando as funções espaciais no banco postgis:</h4>
<div>
<br /></div>
<div>
Acesse o banco e digite a instrução <b>CREATE EXTENSION postgis;</b></div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: small; line-height: 1.4;"><span class="nv" style="color: teal;">$ </span></span><span style="background-color: transparent; line-height: 22px;"><span style="font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">psql postgis
psql (9.1.10)
Type "help" for help.
postgis=# <span style="color: red;">CREATE EXTENSION postgis;</span></span></span></pre>
<h4 style="text-align: justify;">
<span style="font-weight: normal;">Ou se preferir, carregue individualmente os módulos da extensão, da seguinte forma:</span></h4>
<div>
<span style="font-weight: normal;"><br /></span></div>
Navegue até a pasta <b>/usr/share/postgresql/9.1/contrib/postgis-2.0/</b>:<br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span>cd /usr/share/postgresql/9.1/contrib/postgis-2.0/</span></pre>
E carregue os arquivos SQL a seguir:<br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span><span style="font-size: small;">psql -f postgis.sql -d postgis
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>psql -f spatial_ref_sys.sql -d postgis
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>psql -f legacy.sql -d postgis
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>psql -f rtpostgis.sql -d postgis
</span><span style="font-size: small;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span></span>psql -f topology.sql -d postgis</span><span style="font-size: small;"></span></pre>
<br />
<h4 style="text-align: justify;">
5 - Criando um banco de dados espacial a partir do banco postgis:</h4>
<h4 style="text-align: justify;">
</h4>
Para criar novos bancos de dados espaciais a partir do banco postgis criado anteriormente, utilize o comando <b>createdb</b> com a flag <b>-T</b> (template), exemplo:<br />
<pre style="background-color: whitesmoke; border-radius: 3px 3px 3px 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono','DejaVu Sans Mono',Monaco,monospace; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-size: small;"><span class="nv" style="color: teal;">$ </span>createdb bd_espacial -T postgis</span></pre>
<h4 style="text-align: justify;">
</h4>
<h4 style="text-align: justify;">
6 - Acessando o banco criado com o PgAdmin:</h4>
<h4 style="text-align: justify;">
</h4>
Abra o PgAmin e acesse o menu "file > Add Server...", configure-o como mostra a figura abaixo, lembrando de adicionar o seu usuário:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFF59diPpSUFjDz8Jp-Lmrk1ducAZFR1IJFtYpJQIQDZfWKkszm_hFcnPNGJQ6ru_dyjQGAZHJ9QKnxL8jPYBnM2AbaRP4j_htOCZ4C3n3u0f6fEYdILV7N5MYkPgpMKBnMfjCag/s1600/pgadmin.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFF59diPpSUFjDz8Jp-Lmrk1ducAZFR1IJFtYpJQIQDZfWKkszm_hFcnPNGJQ6ru_dyjQGAZHJ9QKnxL8jPYBnM2AbaRP4j_htOCZ4C3n3u0f6fEYdILV7N5MYkPgpMKBnMfjCag/s400/pgadmin.png" width="400" /></a></div>
<br />
<div style="text-align: justify;">
A instalação foi concluída, é possível ver a versão do PostGIS no banco "bd_espacial" utilizando: <b>SELECT postgis_version();</b> , como mostra a figura abaixo:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ5_vXtrakvqU3rIbjdIMq47OnCMZnlKThtH9EzBQZfCuTVCNlndUe0L2Xwb6TTpeXpOsYr4_hgTvsJ0Eg0n67ekZtqaDADOpgKMGJmdI-NBEU6OIt93xMrKMlTeyEiC_VFy6gig/s1600/final.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="356" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ5_vXtrakvqU3rIbjdIMq47OnCMZnlKThtH9EzBQZfCuTVCNlndUe0L2Xwb6TTpeXpOsYr4_hgTvsJ0Eg0n67ekZtqaDADOpgKMGJmdI-NBEU6OIt93xMrKMlTeyEiC_VFy6gig/s640/final.png" width="640" /></a></div>
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com2tag:blogger.com,1999:blog-38486525.post-56043456456098684502013-09-27T08:40:00.001-03:002013-09-27T08:45:17.432-03:00Krigagem Ordinária no R<div style="text-align: justify;">
O código abaixo exemplifica a utilização da Krigagem Ordinária utilizando o <a href="http://www.r-project.org/" target="_blank">R</a> dentro de uma sessão do <a href="http://grass.osgeo.org/" target="_blank">GRASS</a>. O intuito desta postagem é mostrar a codificação básica necessária para se chegar a um primeiro resultado e não será abordado aqui como realizar o ajuste do variograma.<br />
<br />
<script src="https://gist.github.com/marcellobenigno/6405268.js"></script><br />
<br />
Foram utilizados 300 pontos cotados para gerar a superfície mostrada na Figura 1.</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieD_RxKlrrGk9iboLjCHkFZ1z9KG4wC5w7FYLBdILb_KJ1WkxjHKequ5l0HZtbflgF79m4BAF8nBW-aRGEFmtYyqp3tQBap2-XmI7X0KPVKK5lIz-hRC7Gs28M8LFCCo2xC13IZg/s1600/krig.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieD_RxKlrrGk9iboLjCHkFZ1z9KG4wC5w7FYLBdILb_KJ1WkxjHKequ5l0HZtbflgF79m4BAF8nBW-aRGEFmtYyqp3tQBap2-XmI7X0KPVKK5lIz-hRC7Gs28M8LFCCo2xC13IZg/s640/krig.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Resultado da Krigagem</td></tr>
</tbody></table>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-75851730032830954782013-08-09T09:06:00.002-03:002013-08-09T09:06:39.469-03:00PostGIS: Snapping points to linesEsta é uma releitura da postagem <a href="http://profmarcello.blogspot.com.br/2012/02/grass-snapping-points-to-lines.html" target="_blank">GRASS: Snapping points to lines</a> utilizando a extensão <a href="http://postgis.net/" target="_blank">PostGIS</a>, desta forma ficou bem mais simples e rápida a solução, confira:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/6193060.js"></script>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-I8SNLykDup2g_UR2eFeif2GjxR678-IWcYDgdINK3EiRM5rGZAqw6FFROHn3_qd06NVoU0ahhHTOxkDhx2D7ylPf19IzbQ9-rQJSfvKtwCqGS-9kjKSFcupKQiraBZbIQ42M_g/s1600/sql.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="396" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-I8SNLykDup2g_UR2eFeif2GjxR678-IWcYDgdINK3EiRM5rGZAqw6FFROHn3_qd06NVoU0ahhHTOxkDhx2D7ylPf19IzbQ9-rQJSfvKtwCqGS-9kjKSFcupKQiraBZbIQ42M_g/s400/sql.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Consulta no plugin Rt SQL Layer (QGIS)</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlX_QHhrzyC3bbZYp7EWhw7kUCVFV6Za8PfNsu7pA2AHyxtFhu5ErzSoT5uFugKPehemaPKq-Cfkyb9bfmH2L5qfu3LyX1_Mk8d8ZDRPM7pm02e1CWDB-385hP-zif6_WuLTPZOA/s1600/qgis.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlX_QHhrzyC3bbZYp7EWhw7kUCVFV6Za8PfNsu7pA2AHyxtFhu5ErzSoT5uFugKPehemaPKq-Cfkyb9bfmH2L5qfu3LyX1_Mk8d8ZDRPM7pm02e1CWDB-385hP-zif6_WuLTPZOA/s640/qgis.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Resultado no QGIS (Layer nearpoints)</td></tr>
</tbody></table>
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-4086986137290371552013-08-04T12:21:00.001-03:002013-08-04T14:59:47.728-03:00Renomeando e Ordenando Campos de um Shapefile via Terminal<div>
<div style="text-align: left;">
<span style="text-align: justify;">Quando trabalhamos com dados vetoriais, frequentemente temos que renomear e ordenar os campos que compõem um arquivo .dbf de um shapefile. O que muita gente não sabe é que isso pode ser feito sem a necessidade de abrir um </span><i style="text-align: justify;">software</i><span style="text-align: justify;"> de SIG, utilizando a biblioteca </span><a href="http://www.gdal.org/ogr/" style="text-align: justify;" target="_blank"><b>OGR</b></a><span style="text-align: justify;"> através do seguinte comando:</span></div>
</div>
<div style="text-align: justify;">
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span style="font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;"><span style="color: #333333;"><b>ogr2ogr</b></span><span style="color: #333333;"> </span></span></span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;">-a_srs <EPSG:num></span></span><span style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"><span style="color: #333333;"> </span></span><span style="color: #274e13; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"><novo_shapefile></span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"> <shapefile> </span><span style="color: red; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;">-sql</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"> </span><span style="color: blue; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;">"SELECT campo1 AS novo_campo1, campo_2 AS novo_campo2, ..., campoN AS novo_campoN FROM shapefile"</span></pre>
</div>
<div style="text-align: justify;">
Isto pode ser útil principalmente se o arquivo tiver muitos megabytes (MB), pois este processo pode ser bem demorado, independente do <i>software</i> que você esteja utilizando. Vejamos o exemplo a seguir:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Primeiro utilizando o comando <b><a href="http://www.gdal.org/ogrinfo.html" target="_blank">ogrinfo</a></b>, para obter as informações necessárias sobre o shapefile <b>munipb.shp</b>:</div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;"><b>ogrinfo -summary munipb.shp munipb</b>
INFO: Open of `munipb.shp'
using driver `ESRI Shapefile' successful.
Layer name: munipb
Geometry: Polygon
Feature Count: 224
Extent: (-38.764870, -8.302541) - (-34.793335, -6.026173)
Layer SRS WKT:
GEOGCS["GCS_South_American_1969",
DATUM["South_American_Datum_1969",
SPHEROID["GRS_1967_Modified",6378160.0,298.25]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]
NOMEMUNIC: String (50.0)
ARp: Integer (10.0)
UF: String (2.0)
ID_UF: Real (11.0)
REGIAO: String (20.0)
MESOREGIAO: String (50.0)
MICROREGIA: String (50.0)
geocode: String (12.0)
Area_km2: Real (6.2)
per_km: Real (6.2)
id_: Integer (10.0)</span></span></pre>
<div style="text-align: justify;">
O novo shapefile (<b>municipios.shp</b>) será reestruturado com os seguintes campos<b> fid</b> (campo do tipo autoincremento criado automaticamente), <b>geocodigo</b> (geocode), <b>nome</b> (NOMEMUNIC), <b>micro</b> (MICROREGIA), <b>meso</b> (MESOREGIAO), e <b>area_km2</b> (Area_km2):</div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;"><b style="color: #333333;">ogr2ogr</b><span style="color: #333333;"> </span></span></span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;">-a_srs EPSG:4291 </span></span><span style="color: #274e13; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;">municipios.shp</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"> munipb.shp </span><span style="color: red; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;">-sql</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;"> </span><span style="color: blue; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 16px;">"SELECT fid, geocode AS geocodigo, nomemunic AS nome, microregia AS micro, mesoregiao AS meso, area_km2 AS area_km2 FROM munipb"</span></pre>
O resultado pode ser visto com o comando <b>ogrinfo</b> ou em qualquer <i>software</i> de SIG (Figura 1):<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;"><b>ogrinfo -summary municipios.shp municipios
</b>INFO: Open of `municipios.shp'
using driver `ESRI Shapefile' successful.
Layer name: municipios
Geometry: Polygon
Feature Count: 224
Extent: (-38.764870, -8.302541) - (-34.793335, -6.026173)
Layer SRS WKT:
GEOGCS["SAD69",
DATUM["South_American_Datum_1969",
SPHEROID["GRS_1967",6378160,298.247167427]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]]
<b>fid</b>: Integer (10.0)
<b>geocodigo</b>: String (12.0)
<b>nome</b>: String (50.0)
<b>micro</b>: String (50.0)
<b>meso</b>: String (50.0)
<b>area_km2</b>: Real (6.2)</span></span></pre>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjejzp2UOaQU6DdHaDNJB-FEaZyzOcV3r7uxI5dZcZRLw2x1pmOwPCbNeHQs_rmLHm7dpiYMjegW0W5V-0-KQ0W2MjICLMBIUhHSLWszKuLbyrtscahDROtIpg6Iv6H3REIl1fJ3w/s1600/tabela.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="371" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjejzp2UOaQU6DdHaDNJB-FEaZyzOcV3r7uxI5dZcZRLw2x1pmOwPCbNeHQs_rmLHm7dpiYMjegW0W5V-0-KQ0W2MjICLMBIUhHSLWszKuLbyrtscahDROtIpg6Iv6H3REIl1fJ3w/s400/tabela.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Tabela reestruturada aberta no QGIS</td></tr>
</tbody></table>
<br />Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-15860984856671514122013-07-20T13:24:00.000-03:002013-07-20T19:00:15.826-03:00QGIS: cáculo da precipitação média pelo método de Thiessen<div style="text-align: justify;">
O cálculo da precipitação média em uma bacia hidrográfica é realizado através de dados coletados por pluviômetros que estão em áreas próximas e/ou dentro da mesma. Por definição a precipitação média é a lâmina d'água de altura uniforme sobre toda a área considerada, associada a um período de tempo.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
O método de Thiessen é um dos mais usuais para a determinação da precipitação média, consiste em atribuir um fator de peso aos totais precipitados em cada pluviômetro, proporcionais a área de influência de cada um (VILLELA, 1975). Este método será demonstrado a seguir no <i>Software</i> <a href="http://www.qgis.org/" target="_blank">Quantum GIS</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Na figura abaixo temos três <i>layers </i>abertos no QGIS, <b>rainfall_gauges</b> (estações pluviométricas com dados totais mensais de precipitação), <b>streams</b> (rede de drenagem) e <b>basin</b> (bacia hidrográfica em estudo).</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBiRIIfQ_m9Rh8pG3xoHdMQ7an7OgD2693uKjDfbfe4FFO20hJchy3bI2HhhGBZiLz63JACIkCti2HSch6uULplu1BrE3Tb3YAn77mDsPuin4vzrWf2Lu16Af7Efp2G_z8QLHsEg/s1600/1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBiRIIfQ_m9Rh8pG3xoHdMQ7an7OgD2693uKjDfbfe4FFO20hJchy3bI2HhhGBZiLz63JACIkCti2HSch6uULplu1BrE3Tb3YAn77mDsPuin4vzrWf2Lu16Af7Efp2G_z8QLHsEg/s640/1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="text-align: justify;">Para criar os polígonos de Thiessen, acesse o menu <b>Vector > Geometry Tools > Voronoi Polygons</b>:</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNewYgH4OshyphenhyphenIGHFCiNCVN9nhD_VMp3a2XhtEheM5iJaPxTon_K-EaGGxItrVIBZ8bHCPLHADuUxZv8Ust2mCmQ5yUS3dvF3D1v2-eaZWpjs5W2Xd6NeCn5i8Qmt-o4TkTy4yTzw/s1600/2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="241" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNewYgH4OshyphenhyphenIGHFCiNCVN9nhD_VMp3a2XhtEheM5iJaPxTon_K-EaGGxItrVIBZ8bHCPLHADuUxZv8Ust2mCmQ5yUS3dvF3D1v2-eaZWpjs5W2Xd6NeCn5i8Qmt-o4TkTy4yTzw/s400/2.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Escolha a camada dos postos pluviométricos, se necessário aplique um <i>buffer</i> para que o <i>layer</i> gerado cubra toda a bacia:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCHp0mYHe8QalGuPi2gfygPWOsvPzxChIch55kjJ19f0iXESsSgcVdFZyjr8_xSoRGNarfyrUVivRuM9zZ8_9FO2RUvjrp8YAkjW2rIPSL1Vam_Q6s8qhZ0toS_Kfq8zsHdeNhKg/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCHp0mYHe8QalGuPi2gfygPWOsvPzxChIch55kjJ19f0iXESsSgcVdFZyjr8_xSoRGNarfyrUVivRuM9zZ8_9FO2RUvjrp8YAkjW2rIPSL1Vam_Q6s8qhZ0toS_Kfq8zsHdeNhKg/s400/3.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Em seguida corte o <i>layer</i> criado em função do limite da bacia. Vá em <b>Vector > Geoprocessing Tools > Clip</b>:<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivmCuajGSdg_tcnscMpRf2W0a3az_i7fZm1yyS6RW1s6gUZwcNp_vv60HSD1uG5mxTCic74sTUKFlAKInFTMN58pm9LzbJ31Buj6vTpxXxZT3txhnyX2ZlurOwyE4020Qs0xiQ6A/s1600/4.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivmCuajGSdg_tcnscMpRf2W0a3az_i7fZm1yyS6RW1s6gUZwcNp_vv60HSD1uG5mxTCic74sTUKFlAKInFTMN58pm9LzbJ31Buj6vTpxXxZT3txhnyX2ZlurOwyE4020Qs0xiQ6A/s400/4.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<br />
<span id="goog_1331482687"></span>
Em <b>Input vector layer</b> escolha o <i>layer</i> dos polígonos de Thiessen e em <b>Clip layer</b> escolha a bacia hidrográfica:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiewJ5oWdGmOgRXOjFse0VGg21U84bbh1FIuaoRwELfzLTX_v8yLOxel6KIzy0L6h9SG7mIo7dlI4EOwQrB31sIjeLn212_FOTBxxXWTDUBlI8vrr9uWPOqLWOear17KDE-rv3Xtw/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="311" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiewJ5oWdGmOgRXOjFse0VGg21U84bbh1FIuaoRwELfzLTX_v8yLOxel6KIzy0L6h9SG7mIo7dlI4EOwQrB31sIjeLn212_FOTBxxXWTDUBlI8vrr9uWPOqLWOear17KDE-rv3Xtw/s400/5.png" width="400" /></a></div>
<br /></div>
<div>
Com as áreas de influência dos postos pluviométricos definidas (figura abaixo), serão criados alguns campos na tabela de atributos.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_cuLBNyZ-goLFUoL2hi709VBUfdA5Y62CvCZhRLB9PeDfPrWPQkOqAKCuKRhZeVjm2V4uGSbU4MbPrTI-0c6MLMRVC4vRjq2tORXj7_mv0SQHbsaUSSjrP98zTREx7cJOgwvM7g/s1600/6.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="348" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_cuLBNyZ-goLFUoL2hi709VBUfdA5Y62CvCZhRLB9PeDfPrWPQkOqAKCuKRhZeVjm2V4uGSbU4MbPrTI-0c6MLMRVC4vRjq2tORXj7_mv0SQHbsaUSSjrP98zTREx7cJOgwvM7g/s640/6.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br /></td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Habilite o modo de edição e clique em <b>Open field calculator</b>:</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7eCvesyIaHaT9V6xGY21BRr5W9ZFhl6HW1DAvnGHiFwErhE30179BgiNdc0YM9TlG0EfB7ie7jZJ5sCWT_n6vhly2pz3TL-YmN_JK_k7YkMysmfFGp-DZvFHz7TfYDwjRmMGuYA/s1600/8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7eCvesyIaHaT9V6xGY21BRr5W9ZFhl6HW1DAvnGHiFwErhE30179BgiNdc0YM9TlG0EfB7ie7jZJ5sCWT_n6vhly2pz3TL-YmN_JK_k7YkMysmfFGp-DZvFHz7TfYDwjRmMGuYA/s400/8.png" width="400" /></a></div>
<br />
Crie o campo <b>area_km2</b>, neste caso os dados estão em UTM e para obter os resultados em km<sup>2</sup> deve-se dividir por 1.000.000. Salve o resultado e saia do modo de edição.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHACo4HcBqTG3_-MnH1np1kHZS9PNpt0KZPjUSWOIjY_t_gkfhGvFQeScAP8VWPpGk6MGOCCwvq1NerUvjQzF3vYdudD1644NJf8i3wBCKl-t7JeVJlfFWWvCDDzPimE_GBxnjJg/s1600/9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="380" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHACo4HcBqTG3_-MnH1np1kHZS9PNpt0KZPjUSWOIjY_t_gkfhGvFQeScAP8VWPpGk6MGOCCwvq1NerUvjQzF3vYdudD1644NJf8i3wBCKl-t7JeVJlfFWWvCDDzPimE_GBxnjJg/s400/9.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div style="text-align: justify;">
Em seguida, vá em <b>Vector > Analysis Tools > Basic statistics</b>:</div>
</div>
<div>
<br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_bPcjIldkPnGxc8l4UZ1_UdKEZHu2VGRW8JBJFaGkKsvoS70R5rq6nADZSuAY6256KY_7NkHralBVI4j4P5NNyPd7FjyAetnKE6PzylhcO3HBWJkb6g8y3IMFcFbsD706tgOcUg/s1600/10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_bPcjIldkPnGxc8l4UZ1_UdKEZHu2VGRW8JBJFaGkKsvoS70R5rq6nADZSuAY6256KY_7NkHralBVI4j4P5NNyPd7FjyAetnKE6PzylhcO3HBWJkb6g8y3IMFcFbsD706tgOcUg/s400/10.png" width="400" /></a></div>
<br />
<br />
<div style="text-align: justify;">
Obtenha as estatísticas do Layer <b>basin_thiessen</b>, deve ser anotado o valor da soma das áreas (Sum = <b>3179.0643</b>), que corresponde a área total da bacia.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl9mXGH-3V1MNwXQCkAnIbCAFuJviuRMq6pBgXsviAn7VcMU1egsAAwJ5Io_OIJ2leZgVlB2HO9oD8UReS_8ZiQt8dBaeveJh8SMFJ08MhKaQYwe2VXLYoVixHqvpPnLxDob42qg/s1600/11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhl9mXGH-3V1MNwXQCkAnIbCAFuJviuRMq6pBgXsviAn7VcMU1egsAAwJ5Io_OIJ2leZgVlB2HO9oD8UReS_8ZiQt8dBaeveJh8SMFJ08MhKaQYwe2VXLYoVixHqvpPnLxDob42qg/s400/11.png" width="245" /></a></div>
<br />
<div style="text-align: justify;">
Habilite o modo de edição mais uma vez para o <i>layer</i> <b>thiessen_basin</b> e crie mais um campo (<b>area_per</b>) contendo o valor da área de cada polígono dividida pela área total da bacia, em seguida salve a edição:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL06IPTiqugMmaJRf9oAxab_5C4fKkQSD15xwfYxONbkjvkofaMpLeDQkxP6Nnp59Yh4YEGR67-9aXXZblvI7MesKyFlyMdI9iBxXWXgcsUS7LlfZTAB5xuD5UqaaLhDoHAZn0Jg/s1600/12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL06IPTiqugMmaJRf9oAxab_5C4fKkQSD15xwfYxONbkjvkofaMpLeDQkxP6Nnp59Yh4YEGR67-9aXXZblvI7MesKyFlyMdI9iBxXWXgcsUS7LlfZTAB5xuD5UqaaLhDoHAZn0Jg/s400/12.png" width="400" /></a></div>
<br />
<div style="text-align: justify;">
O último campo a ser criado armazenará o valor da precipitação ponderada (<b>rainfall_p</b>), obtido a partir da multiplicação dos valores dos campos <b>rainfall_m</b> e <b>area_per</b>, em seguida salve as alterações e saia do modo de edição:</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9L47lvaNcKbenlvrwllc_cr-7DXeYY6vluLdgnno5E4wu6bWLcDtqaCw6l0XfeF_hyWBLGvmhTWqt6d8yPeJazjXll6Z53U6OHVtjBebqhivKHizKw_uQWrp-BH8BooNvx_ExOQ/s1600/13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9L47lvaNcKbenlvrwllc_cr-7DXeYY6vluLdgnno5E4wu6bWLcDtqaCw6l0XfeF_hyWBLGvmhTWqt6d8yPeJazjXll6Z53U6OHVtjBebqhivKHizKw_uQWrp-BH8BooNvx_ExOQ/s400/13.png" width="400" /></a></div>
<br />
<br />
<span style="text-align: justify;">Para obter o valor da precipitação média, acesse o menu </span><b style="text-align: justify;">Vector > Analysis Tools > Basic statistics </b><span style="text-align: justify;">e escolha o campo <b>rainfall_p</b>:</span><br />
<span style="text-align: justify;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbmQjz8j_9kVvY9GfzoL_XR3nPWv3U7UioWZpn0x3YvkgeE3wJUFXieWI6aX2Z9DloptXr5zs7sv_X0lOS_yjUq_HznQ7X35kQ2v1KlG38oxIy63_0V-jzpBkP5KLHUru4i4PjRA/s1600/15.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbmQjz8j_9kVvY9GfzoL_XR3nPWv3U7UioWZpn0x3YvkgeE3wJUFXieWI6aX2Z9DloptXr5zs7sv_X0lOS_yjUq_HznQ7X35kQ2v1KlG38oxIy63_0V-jzpBkP5KLHUru4i4PjRA/s400/15.png" width="352" /></a></div>
<br />
<div style="text-align: justify;">
Em <b>Sum </b>temos o resultado para a precipitação média mensal, que é de <b>24,72 mm</b>.</div>
<br />
O mesmo procedimento pode ser realizado no GRASS através dos comandos abaixo:<br />
<script src="https://gist.github.com/marcellobenigno/6042047.js"></script>
<br />
<h3>
Referências:</h3>
</div>
VILLELA, sm; MATOS, A. Hidrologia aplicada. 1975.Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com1tag:blogger.com,1999:blog-38486525.post-40241351428213992912013-07-14T18:04:00.001-03:002013-07-14T18:10:03.001-03:00Pivot Table no PostgreSQL<div>
<div style="text-align: justify;">
Pivot Table (ou Crosstab) é uma análise que resulta na inversão de linhas por colunas em uma consulta SQL. Funciona de forma semelhante a uma matriz inversa e seu uso resume uma série de registos em uma tabela mais fácil de ser interpretada, por exemplo:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOxa3_AvbEpg08L0qlLqXWObao2QMBM0LoC9vRjRDCZ_-D6RlXw5cbKo7f8ShC_fTpremX64QG0J162nUbTw4TH282d5VdhgDIdj04oiQov07_hbqCehyZvYvY4XLThg1k-fIX3Q/s1600/fig1_1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOxa3_AvbEpg08L0qlLqXWObao2QMBM0LoC9vRjRDCZ_-D6RlXw5cbKo7f8ShC_fTpremX64QG0J162nUbTw4TH282d5VdhgDIdj04oiQov07_hbqCehyZvYvY4XLThg1k-fIX3Q/s640/fig1_1.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Conjunto de dados</td></tr>
</tbody></table>
<br />
<div style="text-align: justify;">
Digamos que a partir do conjunto de dados da Figura 1 seja necessário totalizar a quantidade de acidentes por sexo para cada bairro. O resultado pode ser visto na Figura 2.</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhem3nTkpZxiI9W8pMOX84giWscbHg8p2WIsROt-5r0K-Y17Uzxq76mlBLtx-6PzcIzJLCxDHkJphHUb4kGEtXyxLVpj3nsbaSzFRUHPnLssBf1wdcKCu7rbqqU9UHQW4X0fvKYOA/s1600/fig2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhem3nTkpZxiI9W8pMOX84giWscbHg8p2WIsROt-5r0K-Y17Uzxq76mlBLtx-6PzcIzJLCxDHkJphHUb4kGEtXyxLVpj3nsbaSzFRUHPnLssBf1wdcKCu7rbqqU9UHQW4X0fvKYOA/s640/fig2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Exemplo de Pivot Table</td></tr>
</tbody></table>
<br />
Utilizando a função de agregação <b><i>SUM()</i></b> em conjunto com a expressão <b><i>CASE</i></b> obtemos o resultado da Pivot Table:<br />
<br />
<script src="https://gist.github.com/marcellobenigno/5996003.js"></script>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-27697319013314807032013-06-18T09:53:00.001-03:002013-06-18T10:41:18.534-03:00Configuração de Layers WMS do Mapserver no Leaflet<div style="text-align: justify;">
Aqui temos um exemplo de como configurar a biblioteca <a href="http://leafletjs.com/" target="_blank">Leaflet</a> com algumas camadas <a href="http://mapserver.org/ogc/wms_server.html" target="_blank">WMS</a> do Mapserver.<br />
<br />
<h3>
Configuração do Mapfile:</h3>
</div>
<div>
</div>
<script src="https://gist.github.com/marcellobenigno/5804964.js"></script>
<br />
<h3>
Configuração da aplicação com o Leaflet:</h3>
<script src="https://gist.github.com/marcellobenigno/5805038.js"></script>
<br />
<h3>
Resultado:</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsgo7gh8K9vxr5Tm7mxwyGmjkgq2vZHgCoj_TnJIfWxpoA-wwCKZVYrSbEXPVg4K6VdR8Xq7DOWkk2dtVBmsmJ84IKItQVz9xfr-dWIBb-i-qdsJPAIE_JSWC8-0tfPzsNtSLuNg/s1600/leaflet.png" imageanchor="1"><img border="0" height="556" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsgo7gh8K9vxr5Tm7mxwyGmjkgq2vZHgCoj_TnJIfWxpoA-wwCKZVYrSbEXPVg4K6VdR8Xq7DOWkk2dtVBmsmJ84IKItQVz9xfr-dWIBb-i-qdsJPAIE_JSWC8-0tfPzsNtSLuNg/s640/leaflet.png" width="640" /></a></div>
<div>
<br /></div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-29913819326066626542013-05-30T11:17:00.000-03:002013-05-30T11:25:20.678-03:00Script para criação de mapas de declividade no GRASSO script a seguir cria um mapa de declividade a partir de um Modelo Digital de Terreno, de acordo com classificação proposta por Lepsch (1991), descrita na Tabela 1.<br />
<br />
<table id="tabela" style="margin: auto;">
<tbody>
<tr>
<th><span style="font-family: Verdana, sans-serif;">Classe de Declividade </span></th>
<th><span style="font-family: Verdana, sans-serif;">Porcentagem</span></th>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Plano</span></td>
<td><span style="font-family: Verdana, sans-serif;">0 - 2</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Suave Ondulado </span></td>
<td><span style="font-family: Verdana, sans-serif;">2 - 5</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Moderadamente Ondulado</span></td>
<td><span style="font-family: Verdana, sans-serif;">5 - 10</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Ondulado</span></td>
<td><span style="font-family: Verdana, sans-serif;">10 - 15</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Forte Ondulado</span></td>
<td><span style="font-family: Verdana, sans-serif;">15 - 45</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Montanhoso</span></td>
<td><span style="font-family: Verdana, sans-serif;">45 - 70</span></td>
</tr>
<tr>
<td><span style="font-family: Verdana, sans-serif;">Escarpado</span></td>
<td><span style="font-family: Verdana, sans-serif;">> 70</span></td></tr>
</tbody></table>
<div style="text-align: center;">
<div style="text-align: justify;">
<div style="text-align: center;">
Tabela 1 - Classes de declividade (LEPSH, 1991)<br />
<br /></div>
</div>
</div>
<script src="https://gist.github.com/marcellobenigno/5677647.js"></script>
Para utilizar o script é necessário fazer o seu <i>download</i> (salve-o na pasta home, por exemplo) e lhe dar permissões de execução através do comando abaixo:<br />
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">sudo chmod +x declividade.sh</span></pre>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Em seguida execute o comando dentro de uma sessão do GRASS:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrY-_opQsXZOkm_fFIGEnwOc-dzrIzeU25Twc3mlnJfsykNh_ojOTe9_ZcTgK1XgdgwBKBY0URD9edXsUsof8wCHEUINQ-H-6apXtgeIf_WTQfpCXNbDTZPBYhnJQmcOBSEpAjkw/s1600/t2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrY-_opQsXZOkm_fFIGEnwOc-dzrIzeU25Twc3mlnJfsykNh_ojOTe9_ZcTgK1XgdgwBKBY0URD9edXsUsof8wCHEUINQ-H-6apXtgeIf_WTQfpCXNbDTZPBYhnJQmcOBSEpAjkw/s400/t2.png" width="400" /></a></div>
<br />
<div>
<br /></div>
<div>
Resultado:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE_JVN4HRsiKeC7rG5gos9a2E0PzEFeUhk8fvgmgJdyoEg143x11qzVpIU8pDzVq_b_qKRD08ZVyscprQR8EPG_gvcZ7TtJn2S8O0aq-skROLcVi9VwSuIoyuY6t0pt2JJsI4-JQ/s1600/slope.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="250" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE_JVN4HRsiKeC7rG5gos9a2E0PzEFeUhk8fvgmgJdyoEg143x11qzVpIU8pDzVq_b_qKRD08ZVyscprQR8EPG_gvcZ7TtJn2S8O0aq-skROLcVi9VwSuIoyuY6t0pt2JJsI4-JQ/s400/slope.png" width="400" /></a></div>
<br /></div>
<h4>
REFERÊNCIAS:</h4>
<div style="text-align: justify;">
<b><br /></b>
<b>LEPSCH, I. F</b>. Manual para levantamento utilitário do meio físico e classificação de terras no sistema de capacidade de uso. Campinas : Sociedade Brasileira de Ciência do Solo, 1991.</div>
<style>
#tabela,#tabela td, #tabela th
{
border:1px solid black;
}
</style>Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-49780737413923820812013-05-24T10:23:00.003-03:002013-05-24T10:39:25.586-03:00Python: Geocodificação com a biblioteca pygeocoder<span style="font-family: Arial, Helvetica, sans-serif;"><span style="text-align: justify;">A biblioteca </span><a href="http://code.xster.net/pygeocoder/" style="text-align: justify;">pygeocoder</a><span style="text-align: justify;"> para a linguagem Python é uma mão na roda para quem precisa geocodificar com da API do Google. Com ela é possível encontrar as coordenadas de um determinado endereço, ou um endereço a partir de coordenadas conhecidas (x,y), processo conhecido como geocodificação reversa.</span></span><br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">Vejamos como instalar e utilizar esta biblioteca:</span><br />
<br /></div>
<div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">1 - Instalação do Pip, que é um sistema de gerenciamento, usado para instalar e gerenciar pacotes de software escritos na linguagem de programação Python:</span></div>
<div class="highlight" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; text-align: start;">
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">sudo apt-get install python-pip</span></pre>
<div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">2 - Instalação da biblioteca requests (caso seja necessário):</span></div>
<div class="highlight">
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">sudo pip install requests</span></pre>
</div>
</div>
<div>
<div style="text-align: justify;">
3 - Instalação da biblioteca <a href="http://code.xster.net/pygeocoder">pygeocoder</a>:</div>
<div class="highlight">
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4; margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px;"><span class="nv" style="color: teal;">$ </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">sudo pip install </span><span style="background-color: white; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;">pygeocoder</span></pre>
</div>
</div>
<div>
<div style="color: black; font-family: 'Times New Roman'; font-size: medium; line-height: normal; text-align: justify;">
<br /></div>
<div>
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">4 - Obtendo as coordenadas a partir de um endereço:</span></div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span class="kn" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">from</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"> </span><span class="nn" style="color: #555555; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">pygeocoder</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"> </span><span class="kn" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">import</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"> </span><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">Geocoder
<span class="n" style="line-height: 1.4; text-align: center;">endereco</span><span style="color: #333333; line-height: 1.4; text-align: center;"> </span><span class="o" style="line-height: 1.4; text-align: center;">=</span><span style="color: #333333; line-height: 1.4; text-align: center;"> </span><span class="n" style="line-height: 1.4; text-align: center;">Geocoder</span><span class="o" style="line-height: 1.4; text-align: center;">.</span><span class="n" style="line-height: 1.4; text-align: center;">geocode</span><span class="p" style="line-height: 1.4; text-align: center;">(</span><span class="s" style="text-align: center;"><span style="color: #b45f06;"><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="line-height: 1.4;">"</span></span><span style="font-family: Arial, Verdana, Lucida Grande, Lucida, Helvetica, sans-serif;"><span style="line-height: 19.1875px; white-space: normal;">Rua Violeta Formiga, 80, João Pessoa</span></span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="line-height: 1.4;">"</span></span></span></span><span class="p" style="line-height: 1.4; text-align: center;">)
</span></span><span class="k" style="color: #004080; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">print</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">(endereco</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">[</span><span class="mi" style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"><span style="color: purple;">0</span></span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">]</span><span class="o" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">.</span><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">coordinates</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">)</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">
</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"><b>>>></b> (</span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;">-7.0821068, -34.8407296</span></span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">)</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">
</span><span class="k" style="color: #004080; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">print</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">(endereco</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">[</span><span class="mi" style="font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"><span style="color: purple;">0</span></span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">])</span><span style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">
</span><span style="background-color: transparent; font-size: 12px; line-height: 16px; text-align: justify;"><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><b>>>></b> Rua Violeta Formiga, </span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">80</span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"> - Aeroclube, João Pessoa - Paraíba, Brazil</span></span></pre>
</div>
</div>
<div>
<br />
<div style="text-align: justify;">
<span style="font-family: Arial, Helvetica, sans-serif;">5 - Obtendo um endereço a partir das coordenadas:
</span></div>
<pre style="background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); margin-bottom: 9px; margin-top: 9px; overflow-x: auto; padding: 5px 10px; text-align: start;"><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">coordenadas</span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 1.4;"> </span></span><span class="o" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">=</span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 1.4;"> </span></span><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">Geocoder</span><span class="o" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">.</span><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">reverse_geocode</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">(</span><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 16px;">-7.134660, -34.873325</span></span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">)</span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 1.4;">
</span></span><span class="k" style="color: #004080; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">print</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">(</span><span class="n" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">coordenadas</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">[</span><span class="mi" style="color: #009999; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">0</span><span class="p" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;">])</span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 1.4;">
</span></span><span class="o" style="color: #333333; font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, monospace; font-size: 12px; line-height: 1.4;"><b>>>></b></span><span style="color: #333333; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"><span style="font-size: 12px; line-height: 1.4;"> </span></span><span style="background-color: transparent; font-size: 12px; line-height: 16px; text-align: justify;"><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">Avenida Primeiro de Maio, </span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">792</span><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">-</span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">866</span><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;"> - Jaguaribe, João Pessoa - Paraíba, </span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">58015</span><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">-</span><span style="color: purple; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">430</span><span style="color: #009999; font-family: Bitstream Vera Sans Mono, DejaVu Sans Mono, Monaco, monospace;">, Brazil</span></span></pre>
</div>
</div>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-63911497371464138692013-02-27T15:30:00.000-03:002013-03-03T08:35:31.750-03:00Georreferenciamento de dados vetoriais usando o R e o PostGIS<div style="text-align: justify;">
Quem já trabalhou com o ArcGIS provavelmente já deve ter utilizado a extensão <i><a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001t000000t5000000.htm" target="_blank">Spatial Adjustement</a> </i>que permite o ajuste de bases vetoriais distintas a partir de pontos de controle (conhecido como georreferenciamento de vetores). Neste tutorial irei apresentar uma solução semelhante utilizando a função <a href="http://postgis.refractions.net/documentation/manual-2.0/ST_Affine.html" target="_blank">ST_Affine</a> do <a href="http://postgis.net/" target="_blank">PostGIS</a> e o <i>software</i> estatístico <a href="http://www.r-project.org/" target="_blank">R</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Na Figura 1 temos duas camadas vetoriais, a de cor vermelha teve problemas no seu georreferenciamento e será ajustada a partir da base de cor verde. Para isso, primeiro é necessário importar os <i>shapefiles</i> para um banco de dados geográfico e depois visualizar as tabelas criadas no QGIS:<br />
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi738UzP9lUVC89VX3EyxzIhyRU09KS0kID6_fRXeZxt7EtU4m8LpQRh2yBGDl6u1D98IM0654vCk4BiN-j1liS2oD-yeafGeLXEXc7NkhwEcyESYrRpWH7OwgiUedHXa_8DsCXbw/s1600/lotes.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="338" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi738UzP9lUVC89VX3EyxzIhyRU09KS0kID6_fRXeZxt7EtU4m8LpQRh2yBGDl6u1D98IM0654vCk4BiN-j1liS2oD-yeafGeLXEXc7NkhwEcyESYrRpWH7OwgiUedHXa_8DsCXbw/s400/lotes.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 1 - Bases cadastrais levantadas por empresas diferentes</td></tr>
</tbody></table>
<div style="text-align: justify;">
Devem ser criadadas duas camadas vetoriais do tipo ponto no BDG onde foram importados os <i>shapefiles</i>. Observa-se na Figura 2 que a localização dos pontos vermelhos correspondem aos pontos verdes (origem -> destino).</div>
<div style="text-align: justify;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu_DYlLf3Edv6_ZaWJQhBQjLHPC0YBDDjExFc0ia9juXkXpJL1d_qO7nSAmUjzIisyLQU6TyjFCjz-bdIpFO29Bbib-0PxwP8iopZucjj9lahuEYsMzUvc1uGcfIO5dzG3cmDmdA/s1600/qgis.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="387" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu_DYlLf3Edv6_ZaWJQhBQjLHPC0YBDDjExFc0ia9juXkXpJL1d_qO7nSAmUjzIisyLQU6TyjFCjz-bdIpFO29Bbib-0PxwP8iopZucjj9lahuEYsMzUvc1uGcfIO5dzG3cmDmdA/s640/qgis.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 2 - Pontos de controle criados</td></tr>
</tbody></table>
Em seguida, em uma sessão no R via terminal deve-se digitar os seguintes comandos:<br />
<pre class="brush:ruby">#carregando a biblioteca e o driver do PostgreSQL
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
#conexão com o BD
con <- dbConnect(drv, dbname="cadastro",
user="marcello",
pass="<minha_senha>")
#query 1 - coordenadas x,y dos pontos de destino
pts_ok <- data.matrix(dbGetQuery(con,
"SELECT ST_X(geom) AS x,
ST_Y(geom) AS y
FROM pontos_ok"))
#query 2 - coordenadas dos pontos de origem
pts_err <- data.matrix(dbGetQuery(con,
"SELECT ST_X(geom) AS x,
ST_Y(geom) AS y
FROM pontos_errados"))
#regressão linear: modele pts_ok
#como função estatística de pts_err
parameters <- lm(pts_ok ~ pts_err)
#visualizando a matriz transposta dos coeficientes
t(coef(parameters))
</pre>
<br />
<div style="text-align: justify;">
Como resultado, teremos os coeficientes da equação que lineariza os pontos com as coordenadas erradas (pts_err) em função dos pontos de referência (pts_ok).</div>
<div class="mw-geshi" dir="ltr" style="background-color: #f9f9f9; border: 1px dashed rgb(47, 111, 171); margin: 1em 0px; padding: 1em;">
<div class="bash source-bash">
<pre class="de1" style="background-image: none; border: 0px none white; padding: 0px; vertical-align: top;"><span style="font-size: 12px; line-height: 14.390625px;"><b> (Intercept) pts_errx pts_erry
x 1312943.9 1.0138267 -0.143060
y -163870.4 0.1389882 1.013313</b></span></pre>
</div>
</div>
Tais coeficientes são os parâmetros de entrada da função <a href="http://postgis.refractions.net/documentation/manual-2.0/ST_Affine.html" style="text-align: justify;" target="_blank">ST_Affine</a>:
<br />
<div class="mw-geshi" dir="ltr" style="background-color: #f9f9f9; border: 1px dashed rgb(47, 111, 171); font-family: sans-serif; font-size: 12px; line-height: 19.1875px; margin: 1em 0px; padding: 1em;">
<div class="bash source-bash" style="font-family: monospace; line-height: normal;">
<pre class="de1" style="background-image: none; border: 0px none white; font-size: 1em; line-height: 1.2em; padding: 0px; vertical-align: top;"><b>Formato de saída no R:
| xoff a b |
| yoff d e |
Formato de entrada no PostGIS:
ST_Affine(geom, a, b, d, e, xoff, yoff)</b></pre>
</div>
</div>
<br />
Por último, são executadas as seguintes instruções no BDG:<br />
<pre class="brush:sql">--criação de uma cópia da tabela errada:
CREATE TABLE lotes_corrigidos AS
SELECT * FROM lotes_errados;
--em seguida o georreferenciamento dos lotes:
UPDATE lotes_corrigidos
SET geom =
ST_Affine(geom,
1.0138267, -0.143060,
0.1389882, 1.013313,
1312943.9, -163870.4);
</pre>
<br />
<div style="text-align: justify;">
Finalizando, a Figura 3 mostra o resultado da base corrigida, o resultado foi satisfatório considerando a quantidade de pontos utilizada:</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzgeU7RxIUW6d4MKcUX872Oj0JDAT51OSYvTCjTqYTgBVndIb0Tb1-tkAmoVbt2F3G9yACoPhRSnMTcnhF9SlVsIehxiphdhBgxT4K6Yg7iMZ0JIeyss2ZQoP2MhI4lMX-an3bww/s1600/qgis2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzgeU7RxIUW6d4MKcUX872Oj0JDAT51OSYvTCjTqYTgBVndIb0Tb1-tkAmoVbt2F3G9yACoPhRSnMTcnhF9SlVsIehxiphdhBgxT4K6Yg7iMZ0JIeyss2ZQoP2MhI4lMX-an3bww/s640/qgis2.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Figura 3 - Resultado do georreferenciamento (lotes_corrigidos)</td></tr>
</tbody></table>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0tag:blogger.com,1999:blog-38486525.post-68144873957631115932013-02-19T20:01:00.000-03:002013-05-24T10:27:09.197-03:00PostGIS: Triggers e Procedures (Parte 2)<div style="text-align: justify;">
Complementando o <a href="http://profmarcello.blogspot.com.br/2013/02/postgis-triggers-e-procedures-parte-1.html" target="_blank">post anterior</a>, imagine o seguinte cenário: um mapa que mostre de forma esquemática, adutoras que serão projetadas para abastecer alguns municípios. Neste caso o objetivo é ter uma ideia dos comprimentos das adutoras (representados pela distância entre as sedes municipais), quantidade de municípios abastecidos e o nome dos mesmos.
</div>
<pre class="brush:sql">CREATE TABLE adutoras (
gid serial PRIMARY KEY,
nome_adutora varchar(50),
-- campo alimentado pela trigger
comp_trecho_km numeric(10,3),
-- campo alimentado pela trigger
qtde_municipios_abast int,
-- campo alimentado pela trigger
municipios_abastecidos varchar(400)
);
-- adição do campo geom
SELECT AddGeometryColumn (
'public',
'adutoras',
'geom',
'4291', --Lat/Long - Datum SAD69
'LINESTRING',
2
);
-- Procedure
CREATE OR REPLACE FUNCTION pipeline_geometry_field()
RETURNS trigger AS
$$
BEGIN
SELECT string_agg(municipios.nome,', ')
INTO NEW.municipios_abastecidos
FROM municipios
WHERE ST_Intersects(NEW.geom, municipios.geom);
SELECT COUNT(municipios.*)
INTO NEW.qtde_municipios_abast
FROM municipios
WHERE ST_Intersects(NEW.geom, municipios.geom);
NEW.comp_trecho_km:=ST_Length(Geography((NEW.geom))/1000);
RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';
-- Trigger
CREATE TRIGGER fill_pipeline_geometry_field
BEFORE INSERT OR UPDATE ON adutoras
FOR EACH ROW EXECUTE PROCEDURE pipeline_geometry_field();
</pre>
<br />
<div style="text-align: justify;">
O vídeo a seguir mostra a implementação do código acima, a partir da edição da tabela adutora no QGIS, observa-se o preenchimento automático dos campos após o salvamento da feição no Banco de Dados:<br />
<br />
<div style="text-align: center;">
<iframe allowfullscreen="" frameborder="0" height="313" mozallowfullscreen="" src="http://player.vimeo.com/video/60035032?autoplay=1&loop=1" webkitallowfullscreen="" width="500"></iframe> <br />
<a href="http://vimeo.com/60035032">Triggers and Procedures in PostGIS</a> from <a href="http://vimeo.com/user16571325">Marcello Benigno</a> on <a href="http://vimeo.com/">Vimeo</a>.</div>
</div>
Marcello Benignohttp://www.blogger.com/profile/04788803214628621473noreply@blogger.com0