Debugging ogr2ogr “AddGeometryColumn failed” and “Terminating translation prematurely after failed...
How to find all the available tools in mac terminal?
How would a mousetrap for use in space work?
Is it cost-effective to upgrade an old-ish Giant Escape R3 commuter bike with entry-level branded parts (wheels, drivetrain)?
How come Sam didn't become Lord of Horn Hill?
Closed form of recurrent arithmetic series summation
Uniqueness of spanning tree on a grid.
Where are Serre’s lectures at Collège de France to be found?
Why aren't air breathing engines used as small first stages
An adverb for when you're not exaggerating
Is "Reachable Object" really an NP-complete problem?
Is it common practice to audition new musicians one-on-one before rehearsing with the entire band?
What do you call a floor made of glass so you can see through the floor?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Do jazz musicians improvise on the parent scale in addition to the chord-scales?
Would "destroying" Wurmcoil Engine prevent its tokens from being created?
Can melee weapons be used to deliver Contact Poisons?
In what way is everyone not a utilitarian
How does the math work when buying airline miles?
Trademark violation for app?
Using audio cues to encourage good posture
Irreducible of finite Krull dimension implies quasi-compact?
What is homebrew?
What does the "x" in "x86" represent?
Around usage results
Debugging ogr2ogr “AddGeometryColumn failed” and “Terminating translation prematurely after failed translation of layer”
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Converting GeoJSON to Shapefile using ogr2ogr?error of data conversion value getting while importing shapefile in shp2pgsql-gui on ubuntuWhy do I get an error when I try and clip a shapefile to a shapefile using ogr2ogr?ogr2ogr bringing up “memory allocation error”CSRS to NAD83 datum shift with ogr2ogr using grid shift file failsogr2ogr export postgreSQL to ESRI file GDB wkbUnknown layer geometry typeExport spatial data from SQL Server to ESRI shapefile using OSGeoogr2ogr issues in clipping tab to shp where tab has points and lines togetherError while Importing data from .SHP files to spatialite using OGR2OGRogr2ogr merge fgdb (while importing to PostGIS)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
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
spatial_ref_sys
, andgeometry_columns
. - editing the
-nlt
option to make sure I'm using the correct geometry type. - checking different arrangements of
-a_srs
,-s_srs
,-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.
Specs:
- 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)
postgis shapefile postgresql ogr2ogr
|
show 1 more comment
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
spatial_ref_sys
, andgeometry_columns
. - editing the
-nlt
option to make sure I'm using the correct geometry type. - checking different arrangements of
-a_srs
,-s_srs
,-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.
Specs:
- 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)
postgis shapefile postgresql ogr2ogr
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
3
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
1
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09
|
show 1 more comment
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
spatial_ref_sys
, andgeometry_columns
. - editing the
-nlt
option to make sure I'm using the correct geometry type. - checking different arrangements of
-a_srs
,-s_srs
,-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.
Specs:
- 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)
postgis shapefile postgresql ogr2ogr
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
spatial_ref_sys
, andgeometry_columns
. - editing the
-nlt
option to make sure I'm using the correct geometry type. - checking different arrangements of
-a_srs
,-s_srs
,-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.
Specs:
- 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)
postgis shapefile postgresql ogr2ogr
postgis shapefile postgresql ogr2ogr
edited Jul 18 '14 at 6:33
BenjaminGolder
asked Jul 17 '14 at 11:31
BenjaminGolderBenjaminGolder
93341330
93341330
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
3
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
1
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09
|
show 1 more comment
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
3
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
1
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
3
3
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
1
1
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09
|
show 1 more comment
4 Answers
4
active
oldest
votes
AddGeometryColumn is a PostGIS function, so the error should be happening on the database... the source code for the client is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
and it says (v1.11):
osCommand.Printf(
"SELECT AddGeometryColumn(%s,%s,%s,%d,'%s',%d)",
pszEscapedSchemaNameSingleQuote, pszEscapedTableNameSingleQuote,
OGRPGEscapeString(hPGConn, pszGFldName).c_str(),
nSRSId, pszGeometryType, nDimension );
hResult = OGRPG_PQexec(hPGConn, osCommand.c_str());
if( !hResult
|| PQresultStatus(hResult) != PGRES_TUPLES_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"AddGeometryColumn failed for layer %s, layer creation has failed.",
pszLayerName );
Obviously it would have been better if it had logged the exact command run (osCommand.c_str()
), but oh well, that's just the client. You can still look at the database server logs for errors, and find e.g.:
ERROR: permission denied for relation spatial_ref_sys
STATEMENT: INSERT INTO spatial_ref_sys (srid,srtext,proj4text) VALUES ([...])
or:
ERROR: AddGeometryColumn() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7)"
PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 at SQL statement
STATEMENT: SELECT AddGeometryColumn([...])
add a comment |
It appears to have been a different root cause (the above issue was resolved via permissions), but I ran into the same error when importing to PostGIS with ogr2ogr:
ERROR 1: Terminating translation prematurely after failed
translation of layer mybeautifulshapefile (use -skipfailures to
skip errors)
In my case it was a lingering shapefile (TIGER census places) precision bug, and the solution was fairly simple for anyone else who comes across it. Add this flag to ogr2ogr:
-lco PRECISION=NO
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
add a comment |
I got the same error so I show the errorlog from postgres and got this:
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('bm','g_popis_tisk_b','geom',900914,'POINT',2)
So the problem was, that the function was defined more than once with different parameters but some non-compulsory. It was probably caused by importing data (and functions) from other databases with another version of postgis.
http://postgis.net/docs/AddGeometryColumn.html
add a comment |
hi I'd also met this issue , After investigate , It due to there is limitation of PG_extension in which 900914 is not allowed. After change to 4326 then , It work, there is no issue anymore .
using below ogr command (add -t_srs EPSG:4326 parameter )
ogr2ogr -t_srs EPSG:4326 -f PostgreSQL PG:"host=
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f107518%2fdebugging-ogr2ogr-addgeometrycolumn-failed-and-terminating-translation-premat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
AddGeometryColumn is a PostGIS function, so the error should be happening on the database... the source code for the client is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
and it says (v1.11):
osCommand.Printf(
"SELECT AddGeometryColumn(%s,%s,%s,%d,'%s',%d)",
pszEscapedSchemaNameSingleQuote, pszEscapedTableNameSingleQuote,
OGRPGEscapeString(hPGConn, pszGFldName).c_str(),
nSRSId, pszGeometryType, nDimension );
hResult = OGRPG_PQexec(hPGConn, osCommand.c_str());
if( !hResult
|| PQresultStatus(hResult) != PGRES_TUPLES_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"AddGeometryColumn failed for layer %s, layer creation has failed.",
pszLayerName );
Obviously it would have been better if it had logged the exact command run (osCommand.c_str()
), but oh well, that's just the client. You can still look at the database server logs for errors, and find e.g.:
ERROR: permission denied for relation spatial_ref_sys
STATEMENT: INSERT INTO spatial_ref_sys (srid,srtext,proj4text) VALUES ([...])
or:
ERROR: AddGeometryColumn() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7)"
PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 at SQL statement
STATEMENT: SELECT AddGeometryColumn([...])
add a comment |
AddGeometryColumn is a PostGIS function, so the error should be happening on the database... the source code for the client is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
and it says (v1.11):
osCommand.Printf(
"SELECT AddGeometryColumn(%s,%s,%s,%d,'%s',%d)",
pszEscapedSchemaNameSingleQuote, pszEscapedTableNameSingleQuote,
OGRPGEscapeString(hPGConn, pszGFldName).c_str(),
nSRSId, pszGeometryType, nDimension );
hResult = OGRPG_PQexec(hPGConn, osCommand.c_str());
if( !hResult
|| PQresultStatus(hResult) != PGRES_TUPLES_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"AddGeometryColumn failed for layer %s, layer creation has failed.",
pszLayerName );
Obviously it would have been better if it had logged the exact command run (osCommand.c_str()
), but oh well, that's just the client. You can still look at the database server logs for errors, and find e.g.:
ERROR: permission denied for relation spatial_ref_sys
STATEMENT: INSERT INTO spatial_ref_sys (srid,srtext,proj4text) VALUES ([...])
or:
ERROR: AddGeometryColumn() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7)"
PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 at SQL statement
STATEMENT: SELECT AddGeometryColumn([...])
add a comment |
AddGeometryColumn is a PostGIS function, so the error should be happening on the database... the source code for the client is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
and it says (v1.11):
osCommand.Printf(
"SELECT AddGeometryColumn(%s,%s,%s,%d,'%s',%d)",
pszEscapedSchemaNameSingleQuote, pszEscapedTableNameSingleQuote,
OGRPGEscapeString(hPGConn, pszGFldName).c_str(),
nSRSId, pszGeometryType, nDimension );
hResult = OGRPG_PQexec(hPGConn, osCommand.c_str());
if( !hResult
|| PQresultStatus(hResult) != PGRES_TUPLES_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"AddGeometryColumn failed for layer %s, layer creation has failed.",
pszLayerName );
Obviously it would have been better if it had logged the exact command run (osCommand.c_str()
), but oh well, that's just the client. You can still look at the database server logs for errors, and find e.g.:
ERROR: permission denied for relation spatial_ref_sys
STATEMENT: INSERT INTO spatial_ref_sys (srid,srtext,proj4text) VALUES ([...])
or:
ERROR: AddGeometryColumn() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7)"
PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 at SQL statement
STATEMENT: SELECT AddGeometryColumn([...])
AddGeometryColumn is a PostGIS function, so the error should be happening on the database... the source code for the client is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp
and it says (v1.11):
osCommand.Printf(
"SELECT AddGeometryColumn(%s,%s,%s,%d,'%s',%d)",
pszEscapedSchemaNameSingleQuote, pszEscapedTableNameSingleQuote,
OGRPGEscapeString(hPGConn, pszGFldName).c_str(),
nSRSId, pszGeometryType, nDimension );
hResult = OGRPG_PQexec(hPGConn, osCommand.c_str());
if( !hResult
|| PQresultStatus(hResult) != PGRES_TUPLES_OK )
{
CPLError( CE_Failure, CPLE_AppDefined,
"AddGeometryColumn failed for layer %s, layer creation has failed.",
pszLayerName );
Obviously it would have been better if it had logged the exact command run (osCommand.c_str()
), but oh well, that's just the client. You can still look at the database server logs for errors, and find e.g.:
ERROR: permission denied for relation spatial_ref_sys
STATEMENT: INSERT INTO spatial_ref_sys (srid,srtext,proj4text) VALUES ([...])
or:
ERROR: AddGeometryColumn() - invalid SRID
CONTEXT: SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7)"
PL/pgSQL function addgeometrycolumn(character varying,character varying,character varying,integer,character varying,integer,boolean) line 5 at SQL statement
STATEMENT: SELECT AddGeometryColumn([...])
edited Feb 19 '16 at 20:58
answered Feb 19 '16 at 11:55
Josip RodinJosip Rodin
1454
1454
add a comment |
add a comment |
It appears to have been a different root cause (the above issue was resolved via permissions), but I ran into the same error when importing to PostGIS with ogr2ogr:
ERROR 1: Terminating translation prematurely after failed
translation of layer mybeautifulshapefile (use -skipfailures to
skip errors)
In my case it was a lingering shapefile (TIGER census places) precision bug, and the solution was fairly simple for anyone else who comes across it. Add this flag to ogr2ogr:
-lco PRECISION=NO
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
add a comment |
It appears to have been a different root cause (the above issue was resolved via permissions), but I ran into the same error when importing to PostGIS with ogr2ogr:
ERROR 1: Terminating translation prematurely after failed
translation of layer mybeautifulshapefile (use -skipfailures to
skip errors)
In my case it was a lingering shapefile (TIGER census places) precision bug, and the solution was fairly simple for anyone else who comes across it. Add this flag to ogr2ogr:
-lco PRECISION=NO
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
add a comment |
It appears to have been a different root cause (the above issue was resolved via permissions), but I ran into the same error when importing to PostGIS with ogr2ogr:
ERROR 1: Terminating translation prematurely after failed
translation of layer mybeautifulshapefile (use -skipfailures to
skip errors)
In my case it was a lingering shapefile (TIGER census places) precision bug, and the solution was fairly simple for anyone else who comes across it. Add this flag to ogr2ogr:
-lco PRECISION=NO
It appears to have been a different root cause (the above issue was resolved via permissions), but I ran into the same error when importing to PostGIS with ogr2ogr:
ERROR 1: Terminating translation prematurely after failed
translation of layer mybeautifulshapefile (use -skipfailures to
skip errors)
In my case it was a lingering shapefile (TIGER census places) precision bug, and the solution was fairly simple for anyone else who comes across it. Add this flag to ogr2ogr:
-lco PRECISION=NO
answered Sep 12 '14 at 16:21
Bill MorrisBill Morris
468318
468318
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
add a comment |
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
What does Precision=NO do?
– HeikkiVesanto
Feb 19 '16 at 12:00
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
I am thoroughly ashamed to say I have no idea - I've completely forgotten. The -lco flag is for driver-specific parameters, so it's meant to modify the shapefile handling in some way. Many apologies I can't be more specific.
– Bill Morris
Feb 19 '16 at 14:37
1
1
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
Precision may be "YES" to force new fields created on this layer to try and represent the width and precision information, if available using NUMERIC(width,precision) or CHAR(width) types. If "NO" then the types FLOAT8, INTEGER and VARCHAR will be used instead. The default is "YES". (gdal.org/drv_pg.html)
– dbaston
Feb 19 '16 at 16:16
add a comment |
I got the same error so I show the errorlog from postgres and got this:
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('bm','g_popis_tisk_b','geom',900914,'POINT',2)
So the problem was, that the function was defined more than once with different parameters but some non-compulsory. It was probably caused by importing data (and functions) from other databases with another version of postgis.
http://postgis.net/docs/AddGeometryColumn.html
add a comment |
I got the same error so I show the errorlog from postgres and got this:
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('bm','g_popis_tisk_b','geom',900914,'POINT',2)
So the problem was, that the function was defined more than once with different parameters but some non-compulsory. It was probably caused by importing data (and functions) from other databases with another version of postgis.
http://postgis.net/docs/AddGeometryColumn.html
add a comment |
I got the same error so I show the errorlog from postgres and got this:
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('bm','g_popis_tisk_b','geom',900914,'POINT',2)
So the problem was, that the function was defined more than once with different parameters but some non-compulsory. It was probably caused by importing data (and functions) from other databases with another version of postgis.
http://postgis.net/docs/AddGeometryColumn.html
I got the same error so I show the errorlog from postgres and got this:
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('bm','g_popis_tisk_b','geom',900914,'POINT',2)
So the problem was, that the function was defined more than once with different parameters but some non-compulsory. It was probably caused by importing data (and functions) from other databases with another version of postgis.
http://postgis.net/docs/AddGeometryColumn.html
answered Jan 20 '16 at 12:32
SimonaSimona
1
1
add a comment |
add a comment |
hi I'd also met this issue , After investigate , It due to there is limitation of PG_extension in which 900914 is not allowed. After change to 4326 then , It work, there is no issue anymore .
using below ogr command (add -t_srs EPSG:4326 parameter )
ogr2ogr -t_srs EPSG:4326 -f PostgreSQL PG:"host=
New contributor
add a comment |
hi I'd also met this issue , After investigate , It due to there is limitation of PG_extension in which 900914 is not allowed. After change to 4326 then , It work, there is no issue anymore .
using below ogr command (add -t_srs EPSG:4326 parameter )
ogr2ogr -t_srs EPSG:4326 -f PostgreSQL PG:"host=
New contributor
add a comment |
hi I'd also met this issue , After investigate , It due to there is limitation of PG_extension in which 900914 is not allowed. After change to 4326 then , It work, there is no issue anymore .
using below ogr command (add -t_srs EPSG:4326 parameter )
ogr2ogr -t_srs EPSG:4326 -f PostgreSQL PG:"host=
New contributor
hi I'd also met this issue , After investigate , It due to there is limitation of PG_extension in which 900914 is not allowed. After change to 4326 then , It work, there is no issue anymore .
using below ogr command (add -t_srs EPSG:4326 parameter )
ogr2ogr -t_srs EPSG:4326 -f PostgreSQL PG:"host=
New contributor
New contributor
answered 10 mins ago
Nancy baoNancy bao
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f107518%2fdebugging-ogr2ogr-addgeometrycolumn-failed-and-terminating-translation-premat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you tried adding the data from the same computer Postgis is running on? Maybe OSX and Ubuntu don't like each other...
– AndreJ
Jul 18 '14 at 7:04
@AndreJoost we did try that, and received a different error. We are currently testing out a change in PostgreSQL permissions, which looks promising at the moment.
– BenjaminGolder
Jul 18 '14 at 7:27
This is bedeviling me at the moment with the TIGER "places" shapefile. I've isolated geometry types and still have the same error.
– Bill Morris
Sep 11 '14 at 18:11
3
After lots of trial and much error, we discovered that the source of the problem was a permissions issue. The user account did not have sufficient permissions to access all the schemas involved. I will still give the answer to anyone who can show a good debugging process.
– BenjaminGolder
Sep 11 '14 at 22:06
1
By turning on the SQL statement logging in PostgreSQL you at least get all the SQL recorded so you can see what tables and objects are queried and check their permissions.
– user30184
Sep 12 '14 at 8:09