Quantcast

[gdal-dev] I can't get ogr2ogr to overwrite an existing table

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[gdal-dev] I can't get ogr2ogr to overwrite an existing table

Stephen Woodbridge
Hi all,

I'm having trouble figuring out how to overwrite an existing table with
ogr2ogr. I have tried various combos of arguments without success.

What am I doing wrong?

ogr2ogr -t_srs EPSG:4326 -nln roads -nlt PROMOTE_TO_MULTI -f PostgreSQL
-overwrite -lco OVERWRITE=YES -lco PRECISION=NO -lco GEOMETRY_NAME=geom
-lco FID=gid "PG:dbname=buildings host=localhost port=5435 user=postgres
active_schema=census" /data/census/tmp-10195/tl_2016_06013_roads.shp

ERROR 1: CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY ("gid") )
ERROR:  relation "roads" already exists

ERROR 1: Terminating translation prematurely after failed
translation of layer tl_2016_06013_roads (use -skipfailures to skip errors)


ogr2ogr -t_srs EPSG:4326 -nln census.roads -nlt PROMOTE_TO_MULTI -f
PostgreSQL -overwrite -lco OVERWRITE=YES -lco PRECISION=NO -lco
GEOMETRY_NAME=geom -lco FID=gid "PG:dbname=buildings host=localhost
port=5435 user=postgres" /data/census/tmp-10747/tl_2016_06013_roads.shp

ERROR 1: CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY ("gid") )
ERROR:  relation "roads" already exists

ERROR 1: Terminating translation prematurely after failed
translation of layer tl_2016_06013_roads (use -skipfailures to skip errors)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: I can't get ogr2ogr to overwrite an existing table

Saulteau Don
just a guess, thinking off the top of my head but does it need the -update flag too?

On Fri, Apr 7, 2017 at 1:59 PM, Stephen Woodbridge <[hidden email]> wrote:
Hi all,

I'm having trouble figuring out how to overwrite an existing table with ogr2ogr. I have tried various combos of arguments without success.

What am I doing wrong?

ogr2ogr -t_srs EPSG:4326 -nln roads -nlt PROMOTE_TO_MULTI -f PostgreSQL -overwrite -lco OVERWRITE=YES -lco PRECISION=NO -lco GEOMETRY_NAME=geom -lco FID=gid "PG:dbname=buildings host=localhost port=5435 user=postgres active_schema=census" /data/census/tmp-10195/tl_2016_06013_roads.shp

ERROR 1: CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY ("gid") )
ERROR:  relation "roads" already exists

ERROR 1: Terminating translation prematurely after failed
translation of layer tl_2016_06013_roads (use -skipfailures to skip errors)


ogr2ogr -t_srs EPSG:4326 -nln census.roads -nlt PROMOTE_TO_MULTI -f PostgreSQL -overwrite -lco OVERWRITE=YES -lco PRECISION=NO -lco GEOMETRY_NAME=geom -lco FID=gid "PG:dbname=buildings host=localhost port=5435 user=postgres" /data/census/tmp-10747/tl_2016_06013_roads.shp

ERROR 1: CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY ("gid") )
ERROR:  relation "roads" already exists

ERROR 1: Terminating translation prematurely after failed
translation of layer tl_2016_06013_roads (use -skipfailures to skip errors)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: I can't get ogr2ogr to overwrite an existing table

Even Rouault-2
In reply to this post by Stephen Woodbridge

On vendredi 7 avril 2017 15:59:49 CEST Stephen Woodbridge wrote:

> Hi all,

>

> I'm having trouble figuring out how to overwrite an existing table with

> ogr2ogr. I have tried various combos of arguments without success.

>

> What am I doing wrong?

 

I'm not sure. Similar requests work for me with GDAL 2.1. Maybe try to manually drop the table (if it is a table...)

 

Seeing the 'CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY ("gid") )' statement, it makes me wonder if you are not using an older GDAL version (Newer versions will issue a CREATE TABLE with all columns) that might have trouble with overwriting existing tables and schemas.

 

Note for everyone: please mention the version you are using.

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: I can't get ogr2ogr to overwrite an existing table

Stephen Woodbridge
On 4/8/2017 12:29 PM, Even Rouault wrote:

> On vendredi 7 avril 2017 15:59:49 CEST Stephen Woodbridge wrote:
>
>  > Hi all,
>
>  >
>
>  > I'm having trouble figuring out how to overwrite an existing table with
>
>  > ogr2ogr. I have tried various combos of arguments without success.
>
>  >
>
>  > What am I doing wrong?
>
> I'm not sure. Similar requests work for me with GDAL 2.1. Maybe try to
> manually drop the table (if it is a table...)
>
> Seeing the 'CREATE TABLE "census"."roads" ( "gid" SERIAL, PRIMARY KEY
> ("gid") )' statement, it makes me wonder if you are not using an older
> GDAL version (Newer versions will issue a CREATE TABLE with all columns)
> that might have trouble with overwriting existing tables and schemas.
>
> Note for everyone: please mention the version you are using.

Sorry, I know that:

$ ogrinfo --version
GDAL 1.10.1, released 2013/08/26

on Ubuntu 14.04.5 LTS

ok, it is not as convenient but I can drop the table rather than rely on
-overwrite.

Thanks,
   -Steve

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Loading...