Beginner: adding srid 900913 problem

231 views
Skip to first unread message

Roman Baumgaertner

unread,
Apr 26, 2013, 2:04:38 PM4/26/13
to geod...@googlegroups.com
Hi All,

I am a beginner in GeoDjango. I followed the installation instructions and reached the point where I need to add the missing row in the geodjango.db table for SRID 900913.

$ python manage.py shell
>>> from django.contrib.gis.utils import add_srs_entry
>>> add_srs_entry(900913)

By executing the command I get the following error 

Exception: The `add_srs_entry` utility only works with spatial backends.

To create the table spatial_ref_sys I downloaded the init_spatialite-2.4.sql file from http://www.gaia-gis.it/spatialite-2.4.0/

I noticed by executing the command

 spatialite geodjango.db < init_spatialite-2.4.sql 

that I am getting the error

spatialite geodjango.db < init_spatialite-2.4.sql 
SpatiaLite version ..: 4.0.0 Supported Extensions:
- 'VirtualShape' [direct Shapefile access]
- 'VirtualDbf' [direct DBF access]
- 'VirtualXL' [direct XLS access]
- 'VirtualText' [direct CSV/TXT access]
- 'VirtualNetwork' [Dijkstra shortest path]
- 'RTree' [Spatial Index - R*Tree]
- 'MbrCache' [Spatial Index - MBR cache]
- 'VirtualSpatialIndex' [R*Tree metahandler]
- 'VirtualFDO' [FDO-OGR interoperability]
- 'SpatiaLite' [Spatial SQL - OGC]
PROJ.4 version ......: Rel. 4.8.0, 6 March 2012
GEOS version ........: 3.3.8-CAPI-1.7.8
the SPATIAL_REF_SYS table already contains some row(s)
 InitSpatiaMetaData() error:"table spatial_ref_sys already exists"
0
Error: near line 22: PRIMARY KEY must be unique


Thanks in advance for your help!

--Roman



Claude Paroz

unread,
Apr 27, 2013, 3:23:47 AM4/27/13
to geod...@googlegroups.com
Le vendredi 26 avril 2013 à 11:04 -0700, Roman Baumgaertner a écrit :
> Hi All,
>
>
> I am a beginner in GeoDjango. I followed the installation instructions
> and reached the point where I need to add the missing row in the
> geodjango.db table for SRID 900913.
>
>
> $ python manage.py shell
> >>> from django.contrib.gis.utils import add_srs_entry
> >>> add_srs_entry(900913)
>
>
> By executing the command I get the following error
>
>
> Exception: The `add_srs_entry` utility only works with spatial
> backends.

That's a bug with the spatialite backend (fixed in master only).
You could workaround it by using this code before calling add_srs_entry:

from django.db import connection
connection.ops.confirm_spatial_components_versions()


> To create the table spatial_ref_sys I downloaded
> the init_spatialite-2.4.sql file
> from http://www.gaia-gis.it/spatialite-2.4.0/
>
>
> I noticed by executing the command
>
>
> spatialite geodjango.db < init_spatialite-2.4.sql
>
>
>
> that I am getting the error
>
>
> spatialite geodjango.db < init_spatialite-2.4.sql
> SpatiaLite version ..: 4.0.0 Supported Extensions:
> - 'VirtualShape' [direct Shapefile access]
> - 'VirtualDbf' [direct DBF access]
> - 'VirtualXL' [direct XLS access]
> - 'VirtualText' [direct CSV/TXT access]
> - 'VirtualNetwork' [Dijkstra shortest path]
> - 'RTree' [Spatial Index - R*Tree]
> - 'MbrCache' [Spatial Index - MBR cache]
> - 'VirtualSpatialIndex' [R*Tree metahandler]
> - 'VirtualFDO' [FDO-OGR interoperability]
> - 'SpatiaLite' [Spatial SQL - OGC]
> PROJ.4 version ......: Rel. 4.8.0, 6 March 2012
> GEOS version ........: 3.3.8-CAPI-1.7.8
> the SPATIAL_REF_SYS table already contains some row(s)
> InitSpatiaMetaData() error:"table spatial_ref_sys already exists"
> 0
> Error: near line 22: PRIMARY KEY must be unique
>
If you are using SpatiaLite 4, there is no need to populate
spatial_ref_sys, as it already exists (as the error message suggests).

Claude

--
www.2xlibre.net

Reply all
Reply to author
Forward
0 new messages