Geography Reference
In-Depth Information
Brandon is the closest to Durham; Barnard Castle is the farthest away.
Now let's take a look at capturing items in a given radius. Again, we'll use Durham city as our
center point, and cast a radius of 10 miles around this point. Then we will list any town that
falls in that radius, irrespective of its county.
SELECT t.name,t.admin_name,round((ST_Distance(c.geometry,t.geometry) /
1609.344)::numeric, 1) as distanceinmiles
FROM ukcitys AS c, uktowns as t
WHERE c.name = 'DURHAM' AND ST_Distance(c.geometry,t.geometry) <= 16093.44
Figure 59: Towns within 10 Miles of Durham
There are 14 towns within 10 miles of Durham city, and as you can see not all of them are in
County Durham.
You can also rewrite the SQL with the ST_Dwithin(a,b,distance) function as follows:
SELECT t.name,t.admin_name,round((ST_Distance(c.geometry,t.geometry) /
1609.344)::numeric, 1) as distanceinmiles
FROM ukcitys AS c, uktowns as t
WHERE c.name = 'DURHAM' AND ST_Dwithin(c.geometry,t.geometry, 16093.44)
Search WWH ::




Custom Search