Geography Reference
In-Depth Information
Next we'll select a few records from the table to examine the coordi-
nates, just so we can see that our transform works when we're all done:
gis_data= # select gid, astext(shape) as coordinates from towns limit 5;
gid | coordinates
-----+----------------------------------
1 | POINT(-820805.1875 506479.46875)
2 | POINT(-384408.6875 1333234.375)
3 | POINT(88849.421875 881200.0625)
4 | POINT(-565926.875 1174128)
5 | POINT(-307637.65625 1451385.5)
(5 rows)
Now we can create the view using the transform function to convert from
the projected coordinate system to WGS 84 geographic (EPSG:4326).
We know the EPSG code is 4326 because we looked it up using one
of the methods that you'll learn about in just a moment. We can now
create the view:
gis_data= # create view towns_geo as select gid, name, class, pop,
transform(shape,4326) as shape from towns;
CREATE VIEW
gis_data= #
Now we can use our towns_geo view as a layer in QGIS. Just to make
sure the transform works, let's select a few records to see whether the
coordinates look like they are geographic:
gis_data= # select gid, astext(shape) as coordinates from towns_geo limit 5;
gid | coordinates
-----+-------------------------------------------
1 | POINT(-157.571463607738 51.336408724444)
2 | POINT(-155.770900879198 53.6566126757253)
3 | POINT(-153.605243492496 52.4282023272413)
4 | POINT(-156.577035823078 53.203783217787)
5 | POINT(-155.42947766785 53.9856939176996)
(5 rows)
gis_data= #
Sure enough, our view is returning coordinates in WGS 84 geographic.
The view gives us a quick way to transform our data on the fly and be
able to visualize it with our other data. Our original data isn't changed—
we're just doing a transform on the fly.
If it comes down to it, you can always transform your data, creating a
new dataset in the appropriate projection. We'll cover transformation for
both vector and raster layers in more detail later when we look at using
command-line utilities. If you're curious, see Section 11.2 , Coordinate
 
 
Search WWH ::




Custom Search