Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Tasks
11. Task 7

Instruction

Very good!

The last exercise will be a special task. You'll need to know a bit about PostgreSQL's PostGIS extension. First, we will explain the fundamentals of PostGIS, which will help you understand how to write the query.

PostGIS allows you to store and process geographical data in PostgreSQL. For example, with PostGIS you can store geographical coordinates (latitude and longitude) for points on a map or area boundaries (e.g. for buildings, cities, or states). PostGIS uses a data type named geometry or geography to store this data. The format for these data types looks like this:

3F545952C0CBDE2613B7C84

Obviously, this is not human-readable, but various tools can interpret and display this data. We'll explore this feature in the exercise.

PostGIS also provides various functions that work on geographical data. These functions can compute the distance between two places, find the area of a place, see if a point is within a certain area, etc. You can discover them in our PostGIS course. This course is free throughout July 2020!

Exercise

Display states' names, the name of their capitals, and the capital's map coordinates. Use this code:

SELECT
  name,
  capital,
  boundaries,
  capital_coordinates
FROM state;

Copy the code above, run it, and go to the Map tab to see states' boundaries and the location of their capitals.