Opened 18 years ago
Closed 14 years ago
#1027 closed defect (fixed)
ogr2ogr shp import to postgres failed
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | 1.7.0 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: |
Description
Trying to import a polygon shp file into postgres produces the error message below ! I imported the shp file via shp2pgsql and psql - that works fine ! I although checked the geometry on Postgres and it is valid ! This bug is reproducible - If you need any sample shp files please drop me a line ! cheers chris ------ C:\Program Files\FWTools1.0.0a7\bin>ogr2ogr -f PostgreSQL -a_srs EPSG:4326 PG:"host=test user=postgres dbname=test" -sql "SELECT id, name from test" D:\data\test.shp ERROR 1: INSERT command for new feature failed. ERROR: new row for relation "test" violates check constraint "enforce_geotype_wkb_geometry" Command: INSERT INTO "test" (wkb_geometry , "id", "name") VALUES (GeometryFr omText('MULTIPOLYGON (((-5.349999904632568 33.25,-5.34833288192749 33.2475013732 91016,-5.349705696105957 33.247501373291016,-5.349999904632568 33.25)),((-6.3524 99961853027 32.333610534667969,-6.12166690826416 32.889167785644531,-6.113446235 656738 32.895561218261719,-5.641666889190674 33.247501373291016,-5.3497056961059 57 33.247501373291016,-5.267134666442871 32.540836334228516,-5.22333288192749 32 .161388397216797,-6.352499961853027 32.333610534667969)))'::TEXT,4326) , 348, 'MEKNES') ERROR 1: Terminating translation prematurely after failed translation from sql statement.
Change History (1)
comment:1 by , 14 years ago
Milestone: | → 1.7.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The likely cause is that the shapefile reports the geometry type as being POLYGON, but there are MULTIPOLYGON in it. So adding -nlt MULTIPOLYGON to the ogr2ogr command line should fix the problem.
As this is a issue that many people encounter, in r17948, I've added an explicit warning when trying to insert a feature with an incompatible geometry type