| 
				     | 
				
| (2 intermediate revisions by the same user not shown) | 
| Line 1: | 
Line 1: | 
| − | == Quantas estradas existem sem qualquer tipo de classificação, por concelho?==
  |   | 
|   |  |   |  | 
| − | 
  |   | 
| − | 1º Passo: Importar ''shapefile'' da CAOP com os concelhos:
  |   | 
| − | [http://www.igeo.pt/produtos/cadastro/caop/download/CAOP20090_Shapes/Cont_AAd_CAOP20090.zip]
  |   | 
| − | 
  |   | 
| − | 
  |   | 
| − | 2º Passo: Converter para o Sistema de coordenadas da Base de Dados descarregada do OSM
  |   | 
| − | 
  |   | 
| − | 
  |   | 
| − | 3º Passo: Sintaxe da query:
  |   | 
| − | 
  |   | 
| − | <syntaxhighlight>
  |   | 
| − | 
  |   | 
| − | select count(*), portugal.municipio
  |   | 
| − | from planet_osm_roads, portugal
  |   | 
| − | where highway is null
  |   | 
| − | and st_contains (way, way)
  |   | 
| − | group by portugal.municipio
  |   | 
| − | order by count (planet_osm_roads) desc
  |   | 
| − | 
  |   | 
| − | </syntaxhighlight>
  |   | 
| − | 
  |   | 
| − | 
  |   | 
| − | 4º Passo: Alterar highways sem classificação para "unclassifield":
  |   | 
| − | 
  |   | 
| − | <syntaxhighlight lang="sql">
  |   | 
| − | 
  |   | 
| − | update planet_osm_roads set highway = 'unclassified'
  |   | 
| − | where planet_osm_roads.highway is null
  |   | 
| − | 
  |   | 
| − | </syntaxhighlight>
  |   |