Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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