As noted in the title, I'm getting the following error:
ERROR 1: AddGeometryColumn failed for layer pretty_polys, layer creation has failed. ERROR 1: Terminating translation prematurely after failed translation of layer mybeautifulshapefile (use -skipfailures to skip errors)
I'm just adding a shapefile to PostGIS using ogr2ogr (PG connection data is all fake placeholders, obviously):
ogr2ogr \ -f PostgreSQL \ PG:"host='000.00.000.00' port='5432' user='nullislandpatriot' password='nullisland4eva' dbname='data_i_like'" \ "data/mybeautifulshapefile.shp" \ -nln pretty_polys \ -nlt POLYGON
I've tried to identify many possible sources for the error, but I can't seem to figure out what's wrong, and the error isn't descriptive enough.
So my question is, how can I drill down into this error to find out why AddGeometryColumn is failing?
Here are some of the things I have already tried:
- using different files. I receive this error with any file, including the natural earth countries shapefile
- checking the permissions in PostgreSQL. I have read and write access to
the public schema that is being used. Though I should note that I am not
the superuser, and we had to give explicit permission to allow me to access
- editing the
-nltoption to make sure I'm using the correct geometry type.
- checking different arrangements of
-t_srs, and not using them at all.
- lots of other things before I tried the natural earth data, like PRECISION=NO, different database schemas, text encoding, ...
My assumption is that the error has something to do with permissions or settings in PostgreSQL or the syntax for the connection info, since I get the same error for well-known shapefiles like Natural Earth. I've tried the connection info withou the interior single quotes.
I also tried
CPL_DEBUG=ON, which shows me a bit more of what is working:
Shape: DBF Codepage = UTF-8 for /Users/bgolder/Downloads/ne_10m_admin_0_countries/ne_10m_admin_0_countries.shp Shape: Treating as encoding 'UTF-8'. OGR: OGROpen(/Users/bgolder/Downloads/ne_10m_admin_0_countries/ne_10m_admin_0_countries.shp/0x7f9a79d00720) succeeded as ESRI Shapefile. PG: DBName="'data_i_like'" PG: PostgreSQL version string : 'PostgreSQL 9.1.9 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, 64-bit' PG: PostGIS version string : '2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1' OGR_PG_NOTICE: NOTICE: CREATE TABLE will create implicit sequence "countries_ogc_fid_seq" for serial column "countries.ogc_fid" OGR_PG_NOTICE: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "countries_pkey" for table "countries" ERROR 1: AddGeometryColumn failed for layer countries, layer creation has failed. ERROR 1: Terminating translation prematurely after failed translation of layer ne_10m_admin_0_countries (use -skipfailures to skip errors) GDAL: In GDALDestroy - unloading GDAL shared library.
- PostGIS 2.0, with PostgreSQL 9.1.9 on Ubuntu 12.04
- GDAL 1.11.0 (on OS X 10.9.3, installed via Homebrew)