Geography Reference
In-Depth Information
Figure 53: Calculated Land Areas
You'll notice that all our results are in square degrees or fractions thereof. This is because
our geometry was added to the database in WGS84 (SRID 4326) coordinates. Most of the
calculation functions will return their answers in the same units that the source geometry
uses. Converting our area results to meters is not difficult.
SRID 27700, if you recall, is measured in meters so all we need to do is transform our
geometry from SRID 4326 to SRID 27700. We can do this using ST_Transform .
The transform function takes the geometry to be transformed as the first parameter, and the
SRID to transform it to as the second. Using the function on our data gives us the following
SQL:
SELECT name2,ST_Area(ST_Transform(the_geom,27700)) FROM ukcountys LIMIT 5
Figure 54: Geometry Converted from Square Degrees to Meters
Once you have the data converted from square degrees to meters, you can then use normal
SQL order by clauses and other aggregate functions to arrange the areas from largest to
smallest, or add a price column. For example, the following code outputs the five largest
counties in the U.K. and their areas in square meters.
SELECT name2,ST_Area(ST_Transform(the_geom,27700)) FROM ukcountys order by
ST_Area(ST_Transform(the_geom,27700)) desc LIMIT 5
Search WWH ::




Custom Search