Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Points
Polygons
29. ST_Perimeter
Summary

Instruction

Excellent! Now let's get to know some basic functions we can use to work with polygons. The first is ST_Perimeter. It returns the perimeter of the polygon (in other words, the length of the linestrings that constitute the polygon).

SELECT 
  ST_Perimeter(
    ST_Transform(
      boundaries,26910))
FROM sf_hotels 
WHERE id = 1;

In the query above, we show the perimeter of the hotel with id = 1. Note that we changed the SRID to obtain the result in meters.

Exercise

There is a beautiful Japanese Tea Garden in Golden Gate Park. Check how many meters of reed fence would be needed to surround it and thus make it even more mysterious and secluded. Display the name column and the length of the fence expressed in meters. Name the column fence_length.

Use the sf_sights table.

Stuck? Here's a hint!

Use ST_Perimeter combined with ST_Transform. Remember that the SRID should be 26910.