Introduction
Geometry vs. Geography
Summary

Instruction

The calculation we performed with the geometry type was unacceptable and very inaccurate. This proves that for great distances or large areas on the Earth, we should perform calculations with the geography type, not geometry.

Unfortunately, there aren't many functions that support the geography type. Among the functions we got to know in this course, only the following functions support geography columns:

  • ST_AsText,
  • ST_Area,
  • ST_DWithin,
  • ST_Distance,
  • ST_Intersects,
  • ST_Length,
  • ST_Perimeter.

Their usage is exactly the same as in the case of geometry columns. Here's a simple example:

SELECT 
  name, 
  ST_Perimeter(boundaries) 
FROM usa_states;

The query above finds the perimeter of each USA state.

Exercise

What is the total area of Nevada in square kilometers?

Stuck? Here's a hint!

Remember to divide the result of ST_Area by a million to get square kilometers.

Console

Code editor

Result

TableConsole