Geography Reference
In-Depth Information
Figure 51: Data Output with EWKT Geometry
You may have noticed that in these examples I've been calling the functions without the ST_
in front. ST_ is a legacy tag from when systems were called Spatial and Temporal systems.
In most modern GIS databases, you can freely switch between using the prefix and leaving it
out since most systems define the function both with and without the ' ST_ ' prefix. One or two
functions are defined only with the ST_ prefix, so if something seems to be missing in your
data, try both spellings before you give up.
As you can see, the main difference between AsText and AsEWKT is the addition of the SRID
in the output.
Let's try one more, this time with the data output in GeoJSON format:
SELECT gid,number,name,admin_name,ST_AsGeoJSON(geometry) FROM ukcitys LIMIT 5
Figure 52: Data Output with GeoJSON Geometry
What Else Can We Do with Spatial SQL?
We can do tons of things with spatial SQL. A better question is what can't we do? However,
as a developer, you're most likely only interested in simple tasks, so we'll continue by looking
at a few real-world scenarios and what our database can do to help us.
Scenario 1: Largest land mass
Let's suppose you have a number of land plots for sale, and you have them all in a nice
mapping system that potential buyers can browse via a map-enabled website. One thing you
may want to know is which plot has the largest area so you can price them appropriately.
This is achieved very simply by using the area functions provided by the database.
SELECT name2,ST_Area(the_geom) FROM ukcountys LIMIT 5
 
Search WWH ::




Custom Search