[postgis-devel] shp2pgsql bug interpreting data type

Michael Toews mwtoews at sfu.ca
Mon Jan 26 21:52:08 PST 2009


Hi,

I've tried loading SHP data from a Canadian topo data source CanVec http://geogratis.gc.ca/geogratis/en/product/search.do?id=28954 (try searching 094a02). But I get errors with 094a02_3_0_TR_1190009_2.shp:

> shp2pgsql -s 4326 -c 094a02_3_0_TR_1190009_2.shp tr_119 > tr_119.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]

> psql -U postgres -f tr_119.sql postgis
BEGIN
psql:tr_119.sql:12: NOTICE:  CREATE TABLE will create implicit sequence "tr_119_gid_seq" for serial column "tr_119.gid"
psql:tr_119.sql:12: NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "tr_119_pkey" for table "tr_119"
CREATE TABLE
                     addgeometrycolumn
-----------------------------------------------------------
 public.tr_119.the_geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2

(1 row)
psql:tr_119.sql:14: ERROR:  invalid input syntax for integer: "-"
psql:tr_119.sql:15: ERROR:  current transaction is aborted, commands ignored until end of transaction block
ROLLBACK



The error here is appears to be two-fold. In this particular dataset, the column "id_canac" is interpreted to be int4, but OGR sees the datatype as double precision (as established by ogrinfo and ogr2ogr to the same PG database). Secondly, the value '-' is attempted to be inserted into "id_canac" which doesn't work for either int4 or float8 datatypes.

Here is my version info of shp2pgsql:
RCSID: $Id: shp2pgsql.c 2764 2008-04-12 16:44:55Z pramsey $ RELEASE: 1.3.3



More information about the postgis-devel mailing list