Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Functions returning geometries
Collections
13. ST_Area
Summary

Instruction

Well done! Now, you know that the ST_Area function returns the area of a polygon, but what happens if we pass in a collection to this function? Simply put, it calculates the total area of all polygons in the collection! This simplifies matters quite a bit, eliminating the need to call an aggregate function like SUM if you already have a collection on hand. For instance:

SELECT 
  id, 
  ST_Area(ST_Transform(geo_data,26910)) 
FROM sf_chains;

For each collection, the query above will show its id and the total area of all polygons it contains.

Exercise

What is the total area of all Tranquil Jewel Hotels in San Francisco (collection with id = 1)? Provide the answer in square meters.

Stuck? Here's a hint!

Remember to use ST_Tranform with an SRID of 26910 before you calculate ST_Area.