<div dir="ltr"><div>I wonder if part of the problem is that you haven't included the -update flag as well in the ogr2ogr command.</div><div><br></div><div><span style="font-size:12.8000001907349px">ogr2ogr -update -append -f PostgreSQL PG:"host=localhost user=postgres dbname=data_itn" raw_itn/6360199_sn6103_2c7157.</span><u style="font-size:12.8000001907349px"></u><span style="font-size:12.8000001907349px">gz</span></div><div><br></div><div>Then like the warning says, there's also the lco option of -lco OVERWRITE=YES</div><div>Which also overwrites an existing layer, but it will retain any VIEWS in the postgresql database that are built using the layer you're appending or updating.</div><div><br></div><div><br></div><div><br></div><div>Donovan<br><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 22, 2015 at 1:33 PM, Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 3/22/2015 3:32 PM, Even Rouault wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le dimanche 22 mars 2015 20:18:12, Stephen Woodbridge a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I have a directory of gml files. I can load any of them into postgis<br>
without a problem. What I'm having a problem with is appending each file<br>
to the existing tables. I'm using : GDAL 1.10.1, released 2013/08/26<br>
<br>
$ ogrinfo raw_itn/6360199_sn6103_2c7157.<u></u>gz<br>
Had to open data source read-only.<br>
INFO: Open of `raw_itn/6360199_sn6103_<u></u>2c7157.gz'<br>
        using driver `GML' successful.<br>
1: Road (None)<br>
2: RoadLink (Line String)<br>
3: RoadNode (Point)<br>
<br>
$ ogrinfo raw_itn/6360199_sn6101_2c5532.<u></u>gz<br>
Had to open data source read-only.<br>
INFO: Open of `raw_itn/6360199_sn6101_<u></u>2c5532.gz'<br>
        using driver `GML' successful.<br>
1: RoadLinkInformation (Point)<br>
2: Road (None)<br>
3: RoadLink (Line String)<br>
4: RoadNodeInformation (None)<br>
5: RoadNode (Point)<br>
<br>
Here is want I am trying:<br>
<br>
dropdb -U postgres -h localhost data_itn<br>
createdb -U postgres -h localhost data_itn<br>
psql -U postgres -h localhost data_itn -c "create extension postgis"<br>
psql -U postgres -h localhost data_itn -c "create schema itn"<br>
psql -U postgres -h localhost data_itn -c "alter database data_itn set<br>
search_path to itn, public, pg_catalog"<br>
<br>
# this loads fine<br>
<br>
ogr2ogr -append -f PostgreSQL PG:"host=localhost user=postgres<br>
dbname=data_itn" raw_itn/6360199_sn6101_2c5532.<u></u>gz<br>
<br>
# all successive tries to append to the existing tables fails<br>
<br>
ogr2ogr -append -f PostgreSQL PG:"host=localhost user=postgres<br>
dbname=data_itn" raw_itn/6360199_sn6103_2c7157.<u></u>gz<br>
ERROR 1: Layer road already exists, CreateLayer failed.<br>
Use the layer creation option OVERWRITE=YES to replace it.<br>
ERROR 1: Terminating translation prematurely after failed<br>
translation of layer Road (use -skipfailures to skip errors)<br>
<br>
If I don't install extension postgis then there is no problem reported<br>
and it appears to load all the data by appending the tables with the<br>
geometry in a colum wkb_geometry::bytea.<br>
<br>
How can I load the data into postgis. I have over 700 gml files to load.<br>
</blockquote>
<br>
Defining PG_LIST_ALL_TABLES=YES as environment variable should solve this. By<br>
default non-spatial tables are not listed when opening a PG database, and<br>
ogr2ogr is confused as it doesn't see the existing table as existing, so it<br>
tries to recreate it. With trunk, ogr2ogr & the PG driver have been improved<br>
so that specifying  PG_LIST_ALL_TABLES=YES is not needed in that scenario.<br>
<br>
Wondering if we shouldn't list all tables (excluding system tables) by<br>
default...<br>
</blockquote>
<br></div></div>
Thank you this is a very helpful response. I saw the PG_LIST_ALL_TABLES=YES in the documentation, but but never connect that with this problem.<br>
<br>
If there is not a huge downside to listing all tables I can't see that it is a problem because it only happens once after a connection. Or maybe it only needs to be done if -append is set.<br>
<br>
Anyway, Thanks for the help with this.<br>
<br>
-Steve<div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
    -Steve<br>
<br>
---<br>
This email has been checked for viruses by Avast antivirus software.<br>
<a href="http://www.avast.com" target="_blank">http://www.avast.com</a><br>
<br>
______________________________<u></u>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/gdal-dev</a><br>
</blockquote>
<br>
</blockquote>
<br>
<br>
---<br>
This email has been checked for viruses by Avast antivirus software.<br>
<a href="http://www.avast.com" target="_blank">http://www.avast.com</a><br>
<br>
______________________________<u></u>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/gdal-dev</a><br>
</div></div></blockquote></div><br></div>