Skip to content

Instantly share code, notes, and snippets.

@walkermatt
Created November 26, 2013 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walkermatt/7655745 to your computer and use it in GitHub Desktop.
Save walkermatt/7655745 to your computer and use it in GitHub Desktop.
Test case to reproduce ogr2ogr error loading feature types with no geometry into PostgreSQL 9.1 / PostGIS 1.5. Sample data has been munged to avoid copyright issues.
<?xml version="1.0"?>
<FeatureCollection osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb" gml="http://www.opengis.net/gml" fid="GDS-1389940-6811" xsi="http://www.w3.org/2001/XMLSchema-instance" xlink="http://www.w3.org/1999/xlink" schemaLocation="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd">
<description>Ordnance Survey, (c) Crown Copyright. All rights reserved, 2013-10-28</description>
<roadMember>
<Road fid="osgbfoo">
<version>5</version>
<versionDate>2006-02-06</versionDate>
<theme>Road Network</theme>
<changeHistory>
<changeDate>2003-03-13</changeDate>
<reasonForChange>New</reasonForChange>
</changeHistory>
<changeHistory>
<changeDate>2004-11-11</changeDate>
<reasonForChange>Modified</reasonForChange>
</changeHistory>
<changeHistory>
<changeDate>2005-09-29</changeDate>
<reasonForChange>Modified</reasonForChange>
</changeHistory>
<changeHistory>
<changeDate>2005-12-13</changeDate>
<reasonForChange>Modified</reasonForChange>
</changeHistory>
<descriptiveGroup>Named Road</descriptiveGroup>
<roadName>A LANE</roadName>
<networkMember href="#osgbbar">
<networkMember_ref>osgbbar</networkMember_ref>
</networkMember>
<networkMember href="#osgbcar">
<networkMember_ref>osgbcar</networkMember_ref>
</networkMember>
</Road>
</roadMember>
</FeatureCollection>
<?xml version="1.0"?>
<FeatureCollection osgb="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb" gml="http://www.opengis.net/gml" fid="GDS-1389940-6811" xsi="http://www.w3.org/2001/XMLSchema-instance" xlink="http://www.w3.org/1999/xlink" schemaLocation="http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd">
<description>Ordnance Survey, (c) Crown Copyright. All rights reserved, 2013-10-28</description>
<roadMember>
<Road fid="osgblar">
<version>2</version>
<versionDate>2005-09-12</versionDate>
<theme>Road Network</theme>
<changeHistory>
<changeDate>2004-10-08</changeDate>
<reasonForChange>New</reasonForChange>
</changeHistory>
<descriptiveGroup>Named Road</descriptiveGroup>
<roadName>A CLOSE</roadName>
<networkMember href="#osgbde">
<networkMember_ref>osgbde</networkMember_ref>
</networkMember>
</Road>
</roadMember>
</FeatureCollection>
# Load into a fresh schema which does not already contain a road table
# Load the first file
ogr2ogr -append -skipfailures -f PostgreSQL PG:"dbname=loader active_schema=osmm_itn host=localhost user=username password=password" a.gml
# Load the second file
ogr2ogr -append -skipfailures -f PostgreSQL PG:"dbname=loader active_schema=osmm_itn host=localhost user=username password=password" b.gml
# Error output
ERROR 1: Layer road already exists, CreateLayer failed.
Use the layer creation option OVERWRITE=YES to replace it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment