2

I'm using Spatialite (2.3.1, binary from the website) on Windows XP via Java ("Xerial Driver"). SQLite loads fine, also Spatialite seems to be loading successfully. I can even do SELECT-statements. But I can't do SELECT's on geometries. E.g.

SELECT link_id, SRID(GEOMETRY), AsText(GEOMETRY) FROM streets1

returns only null columns except for link_id. How can that be? By the way, I imported this data originally from MapInfo files using ogr2ogr:

ogr2ogr -clipsrc 8.6688 50.1018 8.6794 50.1082 -f "SQLite" streets1.SQLite ~/Desktop/G2AM10101EG2000MAADT/Streets1.TAB

Also I tried:

ogr2ogr -clipsrc 8.6688 50.1018 8.6794 50.1082 -f "SQLite" streets1.SQLite Streets1.TAB nlt GEOMETRY

This also gives the same result...

Thanks, Philip

4

Found the solution:

The tables are in FDO-Ogr format, you can see that when opening the db with spatialite-gui. Then you need to do:

SELECT AutoFDOStart();

and

SELECT link_id, SRID(GEOMETRY), AsText(GEOMETRY) FROM fdo_streets1

instead of

SELECT link_id, SRID(GEOMETRY), AsText(GEOMETRY) FROM streets1

C.f. here: http://groups.google.com/group/spatialite-users/browse_thread/thread/6750ad7013689a3d

0

returning NULL and not an error means that the columns are empty or GEOMETRY is in WKB or WKT format and not in SPATIALITE.

WKB is the default for ogr2ogr, see here, so it's probably the problem.

Solutions:
1)use: SELECT AsText(GeomFromWKB(GEOMETRY))

or

2)put layer creation option FORMAT=SPATIALITE in ogr2ogr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.