-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPostGIS_Queries.sql
29 lines (22 loc) · 1.08 KB
/
PostGIS_Queries.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
CREATE TABLE NEAR
(NAME VARCHAR(15), LOCATION geometry);
INSERT INTO NEAR(NAME,LOCATION)
VALUES('Portland',ST_GeomFromText('POINT(-118.2843712 34.0327259)')),
('Expo/Ver',ST_GeomFromText('POINT(-118.2933875 34.0180606)')),
('Verm/Jeff',ST_GeomFromText('POINT(-118.2940507 34.025635)')),
('Jeff/Fig',ST_GeomFromText('POINT(-118.2825227 34.022263)')),
('Fig/Expo',ST_GeomFromText('POINT(-118.2838941 34.0191765)')),
('Marshall',ST_GeomFromText('POINT(-118.2879678 34.0188291)')),
('SAL',ST_GeomFromText('POINT(-118.2916626 34.0194804)')),
('Theta',ST_GeomFromText('POINT(-118.2830349 34.0272608)')),
('Ralphs',ST_GeomFromText('POINT(-118.2929814 34.0318453)'));
SELECT ST_AsText(ST_ConvexHull(ST_Collect(location))) FROM NEAR;
--POLYGON((-118.2933875 34.0180606,-118.2940507 34.025635,-118.2929814 34.0318453,-118.2843712 34.0327259,-118.2830349 34.0272608,-118.2825227 34.022263,-118.2838941 34.0191765,-118.2933875 34.0180606))
SELECT n2.NAME
FROM NEAR AS n1, NEAR AS n2
WHERE n1.NAME='Portland' AND n1.NAME<>n2.NAME
ORDER BY ST_DISTANCE(n1.location,n2.location)
LIMIT 3
--Theta
--Ralphs
--Jeff/Fig