Importante

La traduzione è uno sforzo comunitario you can join. Questa pagina è attualmente tradotta al 66.67%.

18.1. Lezione: Lavorare con i Database utilizzando il Browser di QGIS

Nei precedenti 2 moduli hai esaminato i concetti di base, le caratteristiche e le funzioni dei database relazionali e le estensioni che consentono di archiviare, gestire, interrogare e manipolare i dati spaziali in un database relazionale. Questa sezione approfondirà come puoi usare efficacemente i database spaziali in QGIS.

Obiettivo di questa lezione: Imparare a interagire con i database spaziali usando l’interfaccia QGIS Browser.

18.1.1. ★☆☆ Passo dopo passo: Aggiunta di Tabelle di Database a QGIS utilizzando il Browser

Hai già analizzato come aggiungere tabelle da un database come layer QGIS, ora puoi dare un’occhiata a ciò in modo più dettagliato e osservare i diversi modi in cui ciò può essere fatto in QGIS. Inizia guardando la nuova interfaccia del browser.

  • Start a new empty map in QGIS.

  • Open the Browser by clicking the Browser tab. If you do not see this tab, you can enable it by going to View ► Panels ► Browser.

  • Open the PostgreSQL portion of the tree and you should find your previously configured connection available (you may need to click the Refresh button at the top of the browser window).

../../../_images/browser_panel.png
  • Facendo doppio clic su una delle tabelle/layer elencati qui, lo aggiungerai alla mappa.

  • Con clic sul tasto destro su una tabella/layer in questa vista, otterrai alcune opzioni. Fai clic sulla voce Proprietà per esaminare le proprietà del layer.

../../../_images/postgis_layer_properties.png

Nota

Of course you can also use this interface to connect to PostgreSQL databases hosted on a server external to your workstation. Right clicking on the PostgreSQL entry in the tree will allow you to specify connection parameters for a new connection.

18.1.2. ★☆☆ Seguire: Aggiunta di un insieme filtrato di record come Layer

Ora che hai visto come aggiungere un’intera tabella come layer QGIS, può essere utile imparare come aggiungere un insieme filtrato di record da una tabella come layer usando le interrogazioni che abbiamo appreso nelle sezioni precedenti.

  • Avvia una nuova mappa vuota

  • Click the Add PostgreSQL Layers button or select Layer ► Add PostgreSQL Layers from the menu.

  • In the Add PostgreSQL Table(s) dialog that comes up, connect to the postgis_demo connection.

  • Expand the public schema and you should find the three tables we were working with previously.

  • Click the lines layer to select it, but instead of adding it, click the Set Filter button to bring up the Query Builder dialog.

  • Costruisci la seguente espressione usando i pulsanti o inserendola direttamente:

    "roadtype" = 'major'
    
../../../_images/pg_table_filter.png
  • Clicca su OK per completare la creazione del filtro e clicca su Aggiungi per aggiungere il layer filtrato alla tua mappa.

  • Rename the lines layer in the tree to roads_primary.

Noterai che solo le Primary Roads sono state aggiunte alla tua mappa piuttosto che l’intero layer.

18.1.3. In Conclusione

Hai visto come interagire con i database spaziali usando il Browser di QGIS e come aggiungere layer alla tua mappa sulla base di una query di filtraggio.

18.1.4. Cosa Segue?

Successivamente vedrai come lavorare con l’interfaccia DB Manager in QGIS per una serie più completa di operazioni di gestione del database.