Enabling Postgis - gecko-8/devwiki GitHub Wiki

Up

Enable The Extensions

  1. Execute the following commands one at a time

    create extension postgis;
    create extension fuzzystrmatch;
    create extension postgis_tiger_geocoder;
    create extension postgis_topology;
    
  2. Then these

    alter schema tiger owner to rds_superuser;
    alter schema tiger_data owner to rds_superuser;
    alter schema topology owner to rds_superuser;
    
  3. And then

    CREATE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$;
    
  4. And finally execute this script

    SELECT exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO rds_superuser;')
      FROM (
        SELECT nspname, relname
        FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid) 
        WHERE nspname in ('tiger','topology') AND
        relkind IN ('r','S','v') ORDER BY relkind = 'S')
    s;  
    

Confirm Everything is Working

  1. Execute this script

    SET search_path=public,tiger;
    
  2. Then this one

    select na.address, na.streetname, na.streettypeabbrev, na.zip
    from normalize_address('1 Devonshire Place, Boston, MA 02109') as na;
    

    You should see the following

    address | streetname | streettypeabbrev |  zip
    ---------+------------+------------------+-------
          1 | Devonshire | Pl               | 02109
    
  3. Execute this script

    select topology.createtopology('my_new_topo',26986,0.5);
    

    And you should see

    createtopology
    ----------------
                  1