From the course: Advanced PostgreSQL
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Computing the distance between locations - PostgreSQL Tutorial
From the course: Advanced PostgreSQL
Computing the distance between locations
It's pretty exciting to have some real cities or places data for the UK. Let's run some queries on this data. The first thing I'm going to do here is look at the two sensors that we have located in Wells and Truro. So I'm going to select the sensor location from places where name is equal to Wells or name is equal to Truro. And I get two sensor locations here. Now let's visualize this on a map. I'm going to select this select the option to view this on a map. And there you can see the two cities. They don't seem very far apart. Now, I'm curious about how far apart these two sensors are, how far apart these locations are. So I'm going to run a simple ST distance query. So I select the ST_Distance between a.sensor location and b.sensor location, where A is Wells and B is Truro. An important detail to observe here in this query that I'm representing the sensor location as geometry coordinates. Remember, geometry does not take into account the spherical nature of the Earth, the Earth's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Spatial data analysis using PostGIS5m 44s
-
(Locked)
The WKT and WKB format1m 39s
-
(Locked)
Geometry and geography data types3m 7s
-
(Locked)
Spatial reference systems2m 30s
-
(Locked)
Creating a table to hold geometry types3m 6s
-
(Locked)
Working with basic geometry types4m 12s
-
(Locked)
Extracting coordinate values, computing length, and area3m 51s
-
(Locked)
Representing real-world data4m 56s
-
(Locked)
Computing the distance between locations3m 22s
-
(Locked)
Computing locations within a distance and representing lines on a map3m 17s
-
(Locked)
Importing shapefiles4m 16s
-
-
-
-
-