Author: Not specified Language: sql
Description: Not specified Timestamp: 2018-03-28 03:41:26 +0000
View raw paste Reply
  1.  
  2. -- 0- Create table -----------------------------------------
  3.  
  4. CREATE TABLE locations (
  5.     id serial NOT NULL PRIMARY KEY,
  6.     name varchar(255),
  7.     lat numeric,
  8.     lon numeric,
  9.     geom geometry(POINT,4326)
  10. );
  11.  
  12. INSERT INTO locations (id, name, lat, lon)
  13. VALUES
  14.     (1, 'Home', 34.032641, -118.288675),
  15.     (2, 'Ralphs @Vermont', 34.032260, -118.290778),
  16.     (3, 'University Auto Service', 34.028050, -118.291490),
  17.     (4, 'Kaprielian Hall', 34.022371, -118.291114),
  18.     (5, 'Trader Joes @USCVillage', 34.025767, -118.284774),
  19.     (6, 'Lyon Center', 34.024151, -118.287960),
  20.     (7, 'Jefferson Parking Structure', 34.024795, -118.290019),
  21.     (8, 'True Light Preschool', 34.027951, -118.288294),
  22.     (9, 'Tommy Trojan', 34.020549, -118.285455);
  23.  
  24. UPDATE locations
  25. SET geom = ST_SetSRID(ST_MakePoint(lon, lat), 4326);
  26.  
View raw paste Reply