Basic PostGIS queries

Now that we have access to our layers in PostGIS, let's try some queries. Visualizing a whole layer from a database can involve a lot of traffic as databases are often on remote servers distributing all kinds of data. To have only the required data which we would like to work with, we can query those tables and visualize only the results in QGIS. As a warm up, remove the administrative boundaries layer and build an expression querying it from the database.

  1. Open an SQL window in the database manager.
  2. In Chapter 3, Using Vector Data Effectively, we discussed a traditional SQL query for selecting everything from a table. Let's use the most basic select query on our administrative boundary layer--SELECT * FROM adm1;.

Get Practical GIS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.