ogr2ogr PostGIS => Spatialite

525 views
Skip to first unread message

Stéphane Henriod

unread,
Aug 1, 2011, 9:17:35 AM8/1/11
to SpatiaLite Users
Dear all,

I am having a problem with ogr2ogr while exporting a PostGIS table to
Spatialite with this statement:

ogr2ogr -f "SQLite" admin.sqlite -nlt "MULTIPOLYGON"
PG:"host=localhost user=postgres port=5432 dbname=mydb
password=mypassword" myschema.mytable -dsco SPATIALITE=yes -dsco
FORMAT=SPATIALITE

Which gives me the following error messages:

ERROR 4: Unable to open EPSG support file gcs.csv
Try setting the GDAL_DATA environment variable to point to the
directory containing EPSG csv files

ERROR 1: sqlite3_step() failed: too much data for one table row

ERROR 1: Terminating translation prematurely after failed translation
of layer myschema.mytable

A few background information:
- I am on Windows 7 Pro 64bits
- I have several versions of GDAL on this computer but the PATH
variable points to gdal 1.7
- The GDAL_DATA variable points to the correct folder (C:\Fwtools
\data)
- I can export myschema.mytable to a SpatiaLite table without any
problem using Quantum GIS. Unfortunately I don-t know how to display
the command that is triggered by the "save as" command...

If anyone has an idea, please feel free to show me direction!

Thanks a lot in advance!

Stephane

a.fu...@lqt.it

unread,
Aug 1, 2011, 10:27:27 AM8/1/11
to spatiali...@googlegroups.com
Hi St�phane,

Just FYI the current implementation of ogr2ogr has
several serious problems and doesn't seems able at
all to create any valid SpatiaLite's DB.

the main problem in current ogr2ogr is a conceptual
one: ogr2ogr pretends to create a spatialite db
*without* loading libspatialite itself: and this
will inexorably end up in a seriously damaged,
broken and not at all usable DB.
In other words: ogr2ogr can actually generate
a generic sqlite db internally storing spatialite
geometries: but this one isn't obviously a *genuine*
spatialite DB

I'm currently working so to contribute a valid
spatialite driver to OGR: a careful and comprehensive
testing program is performed exactly on these days by
some "good-will power user", so we can reasonably
hope in a quick final release of this new OGR driver.

BTW the errors you are reporting seem rather odd:
I've recently performed several ogr2ogr testing on
Windows7 Pro 64bits, but I've never seen nothing
like this.

Just as an interim suggestion: you can easily export
your PostGIS table as a Shapefile (using pgsql2shp),
then importing the output SHP in spatialite.

bye Sandro

Stéphane Henriod

unread,
Aug 1, 2011, 12:37:12 PM8/1/11
to spatiali...@googlegroups.com
Dear Sandro,

thank you very much for your answer!

Although I am by far not a specialist of these issues, let me know if I can help in any way, as a beta-tester of the new driver or whatever!

What I am trying to achieve is basically to create a simple batchfile that will export certain tables of my PostGIS database into gml, shp and spatialite with no more than a double-click! So your interim solution will unfortunately not be completely appropriate for my case.

Also, I was putting big hopes in SpatiaLite, because my database contains data in various scripts (thus encoded in UTF8) and I have very big troubles to keep the non-latin scripts when exporting to shapefiles...

I guessed that my errors were rather odd: I haven't found any relevant information on the many forums... I don't know what is to blame? The 64 bits? the config of my computer? my database itself (but it is topologically clean)?...

Thanks again!

best,

Stéphane

--
"Le mot progrès n'aura aucun sens tant qu'il y aura des enfants malheureux" -- Albert Einstein

"Certes, un rêve de beignet, c'est un rêve, pas un beignet. Mais un rêve de voyage, c'est déjà un voyage" -- Marek Halter

Photos de voyages, photos de montagne: http://www.henriod.info

Skype: Skype name: marmotte_la_gueuse
Tajik mobile phone: +992 934 62 46 62     



On Mon, Aug 1, 2011 at 19:27, <a.fu...@lqt.it> wrote:
Hi Stéphane,

--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To post to this group, send email to spatiali...@googlegroups.com.
To unsubscribe from this group, send email to spatialite-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spatialite-users?hl=en.


Alex Mandel

unread,
Aug 1, 2011, 12:46:44 PM8/1/11
to spatiali...@googlegroups.com
Take a look at the Offline Editor plugins for QGIS. It does sync between
Postgis and Spatialite and might help solve your use case. It's also a
python script so you might be able to customize it for your needs.

Thanks,
Alex

On 08/01/2011 09:37 AM, St�phane Henriod wrote:
> Dear Sandro,
>
> thank you very much for your answer!
>
> Although I am by far not a specialist of these issues, let me know if I can
> help in any way, as a beta-tester of the new driver or whatever!
>
> What I am trying to achieve is basically to create a simple batchfile that
> will export certain tables of my PostGIS database into gml, shp and
> spatialite with no more than a double-click! So your interim solution will
> unfortunately not be completely appropriate for my case.
>
> Also, I was putting big hopes in SpatiaLite, because my database contains
> data in various scripts (thus encoded in UTF8) and I have very big troubles
> to keep the non-latin scripts when exporting to shapefiles...
>
> I guessed that my errors were rather odd: I haven't found any relevant
> information on the many forums... I don't know what is to blame? The 64
> bits? the config of my computer? my database itself (but it is topologically
> clean)?...
>
> Thanks again!
>
> best,
>

> St�phane
>
> --
> "Le mot progr�s n'aura aucun sens tant qu'il y aura des enfants malheureux"
> -- Albert Einstein
>
> "Certes, un r�ve de beignet, c'est un r�ve, pas un beignet. Mais un r�ve de
> voyage, c'est d�j� un voyage" -- Marek Halter


>
> Photos de voyages, photos de montagne: http://www.henriod.info
>
> Skype: [image: Skype name: marmotte_la_gueuse]
> Tajik mobile phone: +992 934 62 46 62
>
>
>
> On Mon, Aug 1, 2011 at 19:27, <a.fu...@lqt.it> wrote:
>

>> Hi St�phane,

Reply all
Reply to author
Forward
0 new messages