Geography Reference
In-Depth Information
In the case of the GNIS data, symbolizing all of it by type would result
in a blob of dots and colors, with lots of overlap. Using the same Post-
GIS layer to create our “virtual” layers turns out to be an efficient way
to get just the data we want out of a large dataset. Though we didn't
demonstrate it, your queries to create a layer can be more complex than
just a simple this='that' query by using operators such as AND and OR to
select rows on more than one condition.
Before we leave this topic, we should mention one more thing. Once you
have created a layer using a PostGIS query, you can change it using the
Query Builder button found on the General tab of the vector Layer Prop-
erties dialog box. Clicking the button opens the query builder, allowing
to modify (or completely change) the query that defines the layer.
Creating a Spatial View
If you are a SQL wizard (or wizard-in-training), you can accomplish
the same effect as our “virtual layers” using database views. Whether
you choose to do this depends on how frequently you need to access
the filtered data. If you always use a certain subset of a given layer,
creating a spatial view is a good solution. For example, to make our
schools layer always available, we can create a view using psql , the
PostgreSQL interactive terminal (of course, you could use any tool that
can access PostgreSQL and execute queries).
$ psql gis_data
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
Type:
\copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
gis_data= # create view school_view as select * from gnis where type = 'school';
CREATE VIEW
gis_data= #
This creates a view for us that includes all the columns from the gnis
table but includes only those features that are schools. When you fire
up QGIS and connect to the database, you'll find the school_view in the
list of available PostGIS layers.
 
 
Search WWH ::




Custom Search