Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5883 closed defect (duplicate)

Failure to convert directly from edigeo to postgis

Reported by: landry Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 1.11.2
Severity: normal Keywords:
Cc:

Description

Usecase: i need to batch-insert thousands of .THF files into a single postgis database.

using ogr2ogr fails because the THF files include several layers from various geometry types, and it trips on a mismatch on types:

ogr2ogr -f PostgreSQL 'PG:dbname=pci2015 user=postgres' outdir/blah.THF

Warning 1: Geometry to be inserted is of type Multi Polygon, whereas the layer geometry type is Polygon.
Insertion is likely to fail
ERROR 1: INSERT command for new feature failed.
ERROR:  Geometry type (MultiPolygon) does not match column type (Polygon)

Command: INSERT INTO "tronfluv_id" ("wkb_geometry" , "object_rid", "tex2", "tex", "creat_date", "update_date") VALUES ('010600002032BF0D000...
418FC2F5E84F035941713D0AD7B1632641B81E85AB4F035941'::GEOMETRY, 'Objet_584563', '(RiviÚre)', 'l''Alli
er', 20060222, 20140228) RETURNING "ogc_fid"
ERROR 1: Unable to write feature 0 from layer TRONFLUV_id.

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

The insertion of sublayers work fine as lon as the geometry type is the same, ie i got ogr2ogr creating 7 layers with POLYGON geometry_columns, but the insertion failed as soon as it hit a sublayer from another type.

On this layer, ogr2ogr says:

Layer name: COMMUNE_id
Geometry: Polygon
Layer name: LIEUDIT_id
Geometry: Polygon
Layer name: SECTION_id
Geometry: Polygon
Layer name: SUBDSECT_id
Geometry: Polygon
Layer name: PARCELLE_id
Geometry: Polygon
Layer name: BATIMENT_id
Geometry: Polygon
Layer name: TRONFLUV_id
Geometry: Polygon
Layer name: TSURF_id
Geometry: Polygon
Layer name: TLINE_id
Geometry: Line String
Layer name: ZONCOMMUNI_id
Geometry: Line String
Layer name: BORNE_id
Geometry: Point
Layer name: ID_S_OBJ_Z_1_2_2
Geometry: Point
Layer name: NUMVOIE_id
Geometry: Point
Layer name: SYMBLIM_id
Geometry: Point
Layer name: TPOINT_id
Geometry: Point
Layer name: VOIEP_id
Geometry: Point
Layer name: PARCELLE_id_LABEL
Geometry: Point
Layer name: SECTION_id_LABEL
Geometry: Point
Layer name: LIEUDIT_id_LABEL
Geometry: Point
Layer name: TRONFLUV_id_LABEL
Geometry: Point
Layer name: ZONCOMMUNI_id_LABEL
Geometry: Point
Layer name: NUMVOIE_id_LABEL
Geometry: Point
Layer name: VOIEP_id_LABEL
Geometry: Point

Here there seems to be a mismatch with the Geometry found by ogrinfo (which things TRONFLUV_ID) is of type Geometry and the THF file which contains a multipolygon ? If i break the THF file to distinct shapefiles, ogrinfo still thinks TRONFLUV_id contains 'Polygon' and not multipolygons. So.. dunno if the issue is in the edigeo driver, the postgis driver which is too strict, or the data itself..

Change History (3)

comment:1 by landry, 9 years ago

Of course, directly trying to insert from shape to postgis produces the same error... so maybe the edigeo driver is wrong here in not recognizing a multipolygon layer ?

ogr2ogr -f PostgreSQL 'PG:dbname=pci2015 user=postgres' /tmp/TRONFLUV_id.shp

comment:2 by landry, 9 years ago

Resolution: duplicate
Status: newclosed

Ok now i see http://trac.osgeo.org/gdal/ticket/4939 and various qgis tickets about it like http://hub.qgis.org/issues/5109..

comment:3 by landry, 9 years ago

-nlt PROMOTE_TO_MULTI fixes the issue with 1.11.2

Note: See TracTickets for help on using tickets.