Project

General

Profile

1 11496 psarando
BEGIN;
2
3
-- create indexes
4
CREATE INDEX "gadm2_iso_idx" ON gadm2 (iso);
5
CREATE INDEX "gadm2_geom_gist" ON gadm2 USING GIST (geom);
6
CREATE INDEX "gadm2_name_0_idx" ON gadm2 (name_0);
7
CREATE INDEX "gadm2_name_1_idx" ON gadm2 (name_1);
8
9
-- physically reorder tuples on disk in country name index order
10
-- nb: i _think_ this helped, but am not 100% sure
11
CLUSTER gadm2 USING gadm2_name_0_idx;
12
13
-- create simplified country polygons
14
SELECT AddGeometryColumn('public', 'gadm2', 'simple_geom', 4326, 'MULTIPOLYGON', 2 );
15
UPDATE gadm2 SET simple_geom = (SELECT st_simplify(geom, 0.001));
16
CREATE INDEX "gadm2_simple_geom_gist" ON gadm2 USING gist (simple_geom);
17
-- ... and create geography versions ...
18
-- note workaround to exclude Antarctica because it has an invalid
19
-- western extent of -180.000015258789
20
ALTER TABLE gadm2 ADD COLUMN simple_geog geography;
21
UPDATE gadm2 SET simple_geog = simple_geom::geography WHERE name_0<>'Antarctica';
22
CREATE INDEX "gadm2_simple_geog_gist" ON gadm2 USING gist (simple_geog);
23
24
COMMIT;