"geom-type or SRID not allowed" when importing/converting shapefile into spatialite

727 views
Skip to first unread message

gilles.s...@gmail.com

unread,
Jun 25, 2013, 7:48:28 AM6/25/13
to spatiali...@googlegroups.com
Hello

I would like to import a shapefile into a spatialite db but it dos not work.
The shp contains ~300000 polygons with holes. Sadly I'm not allowed to share it.
I can import it into QGIS and do some geoprocessing on it without problem.

I tried with spatialite_tool :

spatialite_tool -i -shp "/home/Parcellaire_2010" -d data/carto/carto.sqlite -t parcellaire -c CP1252 -s 31370

I got this :

SQLite version: 3.7.9
SpatiaLite version: 3.1.0-RC2
load shapefile error: <parcellaire.Geometry violates Geometry constraint [geom-type or SRID not allowed]>
load shapefile error: <cannot rollback - no transaction is active>
Some ERROR occurred


I tried ogr2ogr (thanks to a previous post from this forum) with or without forcing geometry types with argument -nlt. The database is created but the table is empty

ogr2ogr -f "SQLite" "/home/parcellaire.sqlite" -dsco SPATIALITE=YES -lco FORMAT=SPATIALITE -nln parcellaire -nlt MULTIPOLYGON "/home/Parcellaire_2010.shp"

I got this :

ERROR 1: sqlite3_step() failed:
  parcellaire.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed] (19)
ERROR 1: ROLLBACK transaction failed: cannot rollback - no transaction is active
ERROR 1: Terminating translation prematurely after failed
translation of layer Parcellaire_2010 (use -skipfailures to skip errors)

I also tried with the -skipfailures argument  :
ogr2ogr -skipfailures -f "SQLite" "/home/parcellaire.sqlite" -dsco SPATIALITE=YES -lco FORMAT=SPATIALITE -nln parcellaire -nlt MULTIPOLYGON "/home/Parcellaire_2010.shp"
(...)
ERROR 1: sqlite3_step() failed:
  parcellaire.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed] (19)
ERROR 1: COMMIT transaction failed: cannot commit - no transaction is active
More than 1000 errors or warnings have been reported. No more will be reported from now.

I tried to remove all columns but one numeric column from the dbf. I also tried with SpatialiteGUI. Without any success.
Any idea about the origin of these problems and how it can be solved ?

Thanks !
Gilles

Jukka Rahkonen

unread,
Jun 25, 2013, 8:37:27 AM6/25/13
to spatiali...@googlegroups.com
Hi,

What does this show for you

ogrinfo -al -so /home/Parcellaire_2010.shp


-Jukka Rahkonen-

gilles.s...@gmail.com kirjoitti:
> --
> You received this message because you are subscribed to the Google Groups
> "SpatiaLite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to spatialite-use...@googlegroups.com.
> To post to this group, send email to spatiali...@googlegroups.com.
> Visit this group at http://groups.google.com/group/spatialite-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


gilles.s...@gmail.com

unread,
Jun 25, 2013, 8:59:35 AM6/25/13
to spatiali...@googlegroups.com, jukka.r...@latuviitta.fi
Hello

This is what I get :

-----------------------------------------------------------------------------------
INFO: Open of `Parcellaire_2010.shp'
      using driver `ESRI Shapefile' successful.

Layer name: Parcellaire_2010
Geometry: Polygon
Feature Count: 282751
Extent: (42262.499996, 21162.503853) - (295155.733409, 167657.460158)
Layer SRS WKT:
PROJCS["Belge_Lambert_1972",
    GEOGCS["GCS_Belge_1972",
        DATUM["Reseau_National_Belge_1972",
            SPHEROID["International_1924",6378388.0,297.0]],
        PRIMEM["Greenwich",0.0],
        UNIT["Degree",0.0174532925199433]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["False_Easting",150000.01256],
    PARAMETER["False_Northing",5400088.4378],
    PARAMETER["Central_Meridian",4.367486666666666],
    PARAMETER["Standard_Parallel_1",49.8333339],
    PARAMETER["Standard_Parallel_2",51.16666733333333],
    PARAMETER["Latitude_Of_Origin",90.0],
    UNIT["Meter",1.0]]
CAMPAGNE: Integer (9.0)
CULT_COD: String (10.0)
CULT_LIB: String (254.0)
X: Integer (9.0)
Y: Integer (9.0)
AREA_ha: Real (19.11)
VERSION: String (30.0)
Shape_Leng: Real (19.11)
Shape_Area: Real (19.11)
---------------------------------------------------------------------------------------

And this is what I have with ogrInfo from R rgdal package. I was surprised by the "wkbPolygon with 3 dimension".
When I create a subset of this shp around some points of interrest, I'm able to import the subset of polygons into spatialite and R. In R I just have a message that z dimension has been discarded

---------------------------------------------------------------------------------------
> ogrInfo("/home/cartography/Wallonie/parcelaire agricole/parcellaire_2010/", "Parcellaire_2010")
Source: "/home/cartography/Wallonie/parcelaire agricole/parcellaire_2010/", layer: "Parcellaire_2010"
Driver: ESRI Shapefile number of rows 282751
Feature type: wkbPolygon with 3 dimensions
Extent: (42262.5 21162.5) - (295155.7 167657.5)
CRS: +proj=lcc +lat_1=49.8333339 +lat_2=51.16666733333333 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.01256 +y_0=5400088.4378 +ellps=intl +units=m +no_defs 
LDID: 87
Number of fields: 9
        name type length typeName
1   CAMPAGNE    0      9  Integer
2   CULT_COD    4     10   String
3   CULT_LIB    4    254   String
4          X    0      9  Integer
5          Y    0      9  Integer
6    AREA_ha    2     19     Real
7    VERSION    4     30   String
8 Shape_Leng    2     19     Real
9 Shape_Area    2     19     Real
---------------------------------------------------------------------------------------

Jukka Rahkonen

unread,
Jun 25, 2013, 9:26:28 AM6/25/13
to spatiali...@googlegroups.com
Hi,

Perhaps there is something wrong with the shapefile. The -skipfailures
should help with them but try if you can convert the original shapefile
into a new shapefile. Or then you can try to open the original shapefile
with OpenJUMP or Kosmo GIS which both have good tools for checking
topologies. OpenJUMP may need 64-bit Java for your dataset because it must
all fit into memory and 32-bit Java has a limit at about 1 GB of memory.

-Jukka Rahkonen-
> Le mardi 25 juin 2013 14:37:27 UTC+2, Jukka Rahkonen a �crit :
>>
>> Hi,
>>
>> What does this show for you
>>
>> ogrinfo -al -so /home/Parcellaire_2010.shp
>>
>>
>> -Jukka Rahkonen-
>>
>> gilles.s...@gmail.com <javascript:> kirjoitti:
>> > email to spatialite-use...@googlegroups.com <javascript:>.
>> > To post to this group, send email to
>> spatiali...@googlegroups.com<javascript:>.

Felix Obermaier

unread,
Jun 25, 2013, 10:53:12 AM6/25/13
to spatiali...@googlegroups.com
you may also try
-nlt GEOMETRY
or
-explodecollections

> Jukka Rahkonen <jukka.r...@latuviitta.fi> hat am 25. Juni 2013 um 15:26
> geschrieben:
Reply all
Reply to author
Forward
0 new messages