2

I am issuing the following statement

ogr2ogr -a_srs EPSG:27700 -f "MapInfo file" "test.tab" PG:"host=xxx user=xxx dbname=xxx password=xxx active_schema=xxx" -sql "Select * from sale_region"

and I am getting the following message on completion:

ERROR 1: ERROR: function getsrid(geometry) does not exist

LINE 1: SELECT getsrid("wkb_geometry") FROM (Select * from sale_regi...

HINT: No function matches the given name and argument types. You might need to add explicit type casts."

All of the data appears to be in the generated file (I have also tried with exporting to SHP and Geojson with the same message appearing).

I think the error message has somethign to do with the SQL and/or that my geometry column is called wkb_geometry in the table. So I'm obviously doing something wrong somewhere and am worried that some data may have been lost in translation. If anyone can put my mind at rest or tell me whats wrong with the code, it'd be very much appreciated.

I did try:

ogr2ogr -a_srs EPSG:27700 -f "MapInfo file" "test.tab" PG:"host=xxx user=xxx dbname=xxx password=xxx active_schema=xxx" "sale_region"

and although it completed with no errors at the command line, it produced an empty MapInfo table.

1 Answer 1

1

I was having a similar issue and this did the trick. And instructions for installation here.

The first url links to the postgis-users forum with the same question.

"

alumno at linux-8hd6:/media/datoscurso/datos/dbf> ogr2ogr -f "KML" /tmp/ejemplo.kml PG:"host=localhost user=postgres dbname=s7" -dsco NameField=etiqueta -sql "Select etiqueta, geom from ej1.pusos, ej1.pusoscod where ej1.pusos.tuso = ej1.pusoscod.codigo_uso" ERROR 1: ERROR: function getsrid(geometry) does not exist LINE 1: SELECT getsrid("geom") FROM (Select etiqueta, geom from ej1....

A newer OGR might have fixed this. Meanwhile load the legacy.sql file shipped with postgis."

The second url links to the postgis install instructions for legacy.sql which is basically a single line that you can run from the command line on the machine hosting the DB:

"psql -d [yourdatabase] -f legacy.sql"

1
  • 1
    Welcome to GIS.SE. You may want to add some of the text from those links to your answer, especially if you have personal experience using them to solve the problem. If those links change, your answer will become useless.
    – Dan C
    Dec 5, 2013 at 16:37

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.