4

When using osm2pgsql to import massachusetts-latest.osm.bz2 into PostGIS 2.0.1 database osm (running on PostgreSQL 9.1 on an Ubuntu 12.04), I get the error failed: ERROR: operator class "gist_geometry_ops" does not exist for access method "gist".

I have ran the enabler .sql scripts including legacy.sql. Truncating the tables and reimporting does not help. Any idea what is causing this error?

Command

osm2pgsql massachusetts-latest.osm.osm.bz2 -d osm -U postgres -P 5432 --hstore -W

Output:

Reading in file: massachusetts-latest.osm.bz2
Processing: Node(23054k) Way(2370k) Relation(5058)  parse time: 300s

Node stats: total(23054254), max(2147478725)
Way stats: total(2370244), max(215072011)
Relation stats: total(5058), max(2855687)

Writing way (2370k)

Writing relation (5058)
Committing transaction for planet_osm_point
Sorting data and creating indexes for planet_osm_point
Committing transaction for planet_osm_line
Committing transaction for planet_osm_roads
Sorting data and creating indexes for planet_osm_line
Committing transaction for planet_osm_polygon
Sorting data and creating indexes for planet_osm_roads
Sorting data and creating indexes for planet_osm_polygon
CREATE INDEX planet_osm_roads_index ON planet_osm_roads USING GIST (way GIST_GEOMETRY_OPS) TABLESPACE pg_default;
 failed: ERROR:  operator class "gist_geometry_ops" does not exist for access method "gist"

Error occurred, cleaning up

2 Answers 2

4

There’s a thorough explanation in the PostGIS FAQ:

In PostGIS 2, the default geometry operator class gist_geometry_ops was changed to gist_geometry_ops_2d and the gist_geometry_ops was completely removed.

Simply remove the gist_geometry_ops statement, changing this:

CREATE INDEX idx_my_table_geom ON my_table USING gist(geom gist_geometry_ops);

To this:

CREATE INDEX idx_my_table_geom ON my_table USING gist(geom);
0

Edit2: Over at BostonGIS, Regina Obe responded to a user with this error as follows--

I think that error happens if you already loaded the data or parts of it. you might want to try truncating your table or if loading multiple files, make sure areas don't overlap

Edit1: Did you see this thread at openstreetmap.org, which seems to be a similar issue, complete with a solution?


GIST is used to create spatial indices, and it's an integral function in PostGIS.

Are you very sure the PostGIS extension is setup on that schema instance? Just because one schema in a PostGRESql database has the PostGIS extension, it doesn't mean they all do. Try running this query to get the PostGIS version integrated into your schema (basically proving its really functioning):

SELECT PostGIS_full_version();

If that query returns a valid result, I'm baffled. But it seems like it could be an easy mistake---creating a schema without basing it on the PostGIS template. I apologize if I'm just wasting your time!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.