Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling Tiger Geocoder in postgis version 2.1

I have used homebrew to update to the most recent version of postgis. (2.1)

brew unlink postgis
brew install postgis

I then have created a migration to alter the postgis extension to 2.1

rails g migration alter_postgis_version

def change
  execute %q{ALTER EXTENSION postgis UPDATE TO "2.1.0";}
end

Edit:

Ran the brew commands in the first comment and now am getting the following error when I migrate:

PG::UndefinedObject: ERROR:  type "geometry" does not exist:
CREATE EXTENSION postgis_tiger_geocoder;/me/.rvm/gems/ruby-2.0.0- 
p247@freight_alert/gems/activerecord4.0.0/
lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'

I have postgis set up under a schema of postgis, so if I run

$: set search_path = "$user", postgis,public;
$: \d
                             List of relations
 Schema  |           Name           |   Type   |       Owner       
---------+--------------------------+----------+-------------------
 postgis | geography_columns        | view     | me
 postgis | geometry_columns         | view     | me
 etc..

$: \d geometry_columns

                View "postgis.geometry_columns"
      Column       |          Type          | Modifiers 
-------------------+------------------------+-----------
 f_table_catalog   | character varying(256) | 
 f_table_schema    | character varying(256) | 
 f_table_name      | character varying(256) | 
 f_geometry_column | character varying(256) | 
 coord_dimension   | integer                | 
 srid              | integer                | 
 type              | character varying(30)  | 

However if I try to run:

$: CREATE EXTENSION postgis_tiger_geocoder;
ERROR:  type "geometry" does not exist

This doesn't make any sense to me since geometry_columns is in the list of relations.

like image 303
tomciopp Avatar asked Aug 20 '13 06:08

tomciopp


2 Answers

Make sure postgis schema is in your database search_path. Afterward, reconnect to your database and try again. Should look something like this.

ALTER DATABASE mydb SET search_path = public, postgis;

There is a small bug we introduced in postgis_tiger_geocoder so might want to use he 2.1.1 one or manually patch the loader described here:

http://www.postgresonline.com/journal/archives/317-CREATE-SCHEMA-IF-NOT-EXISTS-in-9.3-and-tiger-geocoder.html

like image 175
LR1234567 Avatar answered Nov 01 '22 00:11

LR1234567


Ran into this. Went away after I reinstalled geos, gdal, and libspatialite (relinking each as well). I can't say this is the recipe to copy/paste, but play with it and see if you can get it to work:

brew reinstall gdal
brew unlink gdal && brew link gdal
brew reinstall geos
brew unlink geos && brew link geos
brew reinstall libspatialite
brew unlink libspatialite && brew link libspatialite

You might have to do it in a different order, or redo one after the other in a way that gets the libraries in order. Don't uninstall postgis-2.0.x either, since you'll need the (both) libraries to soft-upgrade.

like image 43
Ken Avatar answered Oct 31 '22 22:10

Ken