Introduction
Points
9. GPS coordinates
Linestrings
Polygons
Summary

Instruction

Very good! Before we continue, let's take a close look at the result we got in the previous exercise:

POINT(37.4689849135265 -122.432973622832)

Inside the parentheses, we have the coordinates of our point. But how exactly do we interpret those numbers? Simply put, these are GPS Coordinates representing latitude and longitude, respectively. You may think of them as representing the global address of any place on Earth.

Lines of latitude run east-west and are parallel to the equator. Lines of longitude run north-south and are parallel to a line from the North Pole to the South Pole that runs through Greenwich in London (known as the Greenwich Meridian, or the Prime Meridian). Given both the latitude and longitude of any point on Earth, you can find its accurate location.

Long Lat

Coming back to our point with the X and Y coordinates, the X coordinate is the latitude, and the Y coordinate is the longitude.

Note that, by way of convention, GPS coordinates are usually provided in the reverse order: longitude first and latitude second. In PostGIS X = longitude and Y = latitude. Pay special attention to this fact when you read or save points.

Exercise

Click Next exercise to continue.

Console

Code editor

Result

TableConsole