I used to generate shapefile from PostgreSQL database that is installed with PostGIS tables as templates (geometry_columns and spatial_ref_sys)

Shapefiles generated just fine using the following command:

 $pgsql2shp -f <path to new shapefile> -g <geometry column name> \   -h <hostname> -U <username> "<query>"

No I have a new database with PostGIS 2.0 which installed as a plugin. There is no PostGIS templates. So when I tried generating shapefiles using the above command I got the following error:

enter image description here

Any idea how can i export shapefiles in this case?

  • 1
    i think this answer might help.. you might need to upgrade your version of pgsql2shp. – Steven Kay Oct 11 '15 at 6:34
  • Thanks Steven! I think this is my problem and I'd appreciate it if you let me know how can I upgrade pgsql2shp. I couldn't find anything in the documentation. – Shadin Oct 11 '15 at 17:23
  • 1
    How did you install PostGIS binaries - from a package and if so which one? you might just be using the wrong version or have two. Also Linux distros often have the client utils in a separate package, so it's possible you didn't install the accompanying PostGIS client tools – LR1234567 Oct 12 '15 at 4:28
  • Thanks! and yes, I installed it from a package. PostGIS version is 2.1.5 while pgsql2shp version is 1.5. So I guess I should upgrade pgsql2shp? or should I install it? I appreciate it if you let me know how to do it. – Shadin Oct 12 '15 at 4:53

Problem solved. I just needed to load legacy support in PostGIS:

In my case:

$psql -d DBName -f /usr/share/postgresql/9.3/contrib/postgis-2.1/legacy.sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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