Once again I try to import a shapefile to my remote PostGIS database using og2ogr. Last time it was an Odyssey but I have managed to solve all the issues and report them one by one here.
I have checked everything:
- Permissions of files,
- Path of shapefiles,
- Validity of shapefile,
- triple checked my ogr2ogr command,
- used ogrinfo to validate my connection to the DB and check the shapefile,
- granted roles on my user and on the required tables (e.g. spatial_ref_sys)
- if the table already exists
- etc.
This is my ogr2ogr command:
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=my_user password=my_pass dbname=my_db_name" -nlt GEOMETRY my_shape_file.shp
And the error I get (also checked the PostgreSQL log files) is:
ERROR 1: AddGeometryColumn failed for layer wld_bnd_adm2_gaul_2015, layer creation has failed.
ERROR 1: Terminating translation prematurely after failed
translation of layer wld_bnd_adm2_gaul_2015 (use -skipfailures to skip errors)
Last time I got this error cause I haven't GRANTED permissions to my user. That have solved the problem:
GRANT ALL ON TABLE spatial_ref_sys TO my_user_name;
But not this time.
And that's what I see on my log file:
ERROR: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) is not unique at character 8
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
STATEMENT: SELECT AddGeometryColumn('public','wld_bnd_adm2_gaul_2015','wkb_geometry',4326,'GEOMETRY',2)
-nlt GEOMETRY
I don't think GEOMETRY is a valid parameter here. I think you need to pass in the geometry type, like POLYGON, LINESTRING, etc.