Geography Reference
In-Depth Information
features for a specific area will be slow. Again, we use a bit of DDL in
line 47, taken straight from the PostGIS manual, to create the index.
The last step is to get out the vacuum and sweep up the dust. Well,
not really, but we do need to run VACUUM ANALYZE on our new table.
In the PostgreSQL world, this command reclaims space for use and
updates the statistics for a table or tables to ensure that query exe-
cution is planned efficiently. Even if you don't quite understand that
explanation, just run it anyway—your data will be happy, and you will
be happy.
Our new table is now ready to use. We can view it by any application
that supports PostGIS layers, assuming it doesn't rely on our old friend
the geometry_columns table. Take a look back at Section 7.3 , The geom-
etry_columns Table, on page 104 if you need a refresher. QGIS doesn't
require an entry in the geometry_columns —it can scan the database and
find all tables that have a spatial column. If your client (or server) soft-
ware relies on the geometry_columns table, you can easily add a record
using something similar to the following:
insert into geometry_columns
values('', 'public', 'quakes_demo', 'geom', 2, 4326, 'POINT');
Now every application that supports PostGIS should be able to find the
layer. In Figure 13.5 , on the following page, you can see the results of
our scripting work, loaded into QGIS.
The earthquakes are rendered in graduated symbols, with the worst
being big red dots. I also added the NASA JPL world mosaic as a back-
drop. The big red dot you see is the site of the March 1964 Alaska
earthquake, which registered approximately 9.2 on the Richter scale.
You may be wondering why we added an integer primary key when
we created the table in line 12. Well, first, it's always good to have a
primary key in your tables. And second, if we want to use the table in
QGIS, it requires a primary key in order to manage selection sets and
other bookkeeping tasks behind the scenes.
Transforming Coordinates
For our last example, we take a look at a simple way to transform coor-
dinates using a PostGIS-enabled database. Why would you want to do
this? Well, let's look at the process first and then revisit that question.
Harrison has some old musty topographic maps he used to mark bird
sightings back in the old days before he had a GPS. Now he wants to
 
 
Search WWH ::




Custom Search