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 made a polygon in a SpatiaLite 4 database as follows:

INSERT INTO test_pg (id, name, geom) VALUES (3, 'test', ST_PolyFromText('POLYGON((8.556824 47.185269, 8.611009 47.185269, 8.611009 47.218568, 8.556824 47.218568, 8.556824 47.185269))', 4326));

I assume that the order of coordinates is always LON LAT - is that correct?

When I do SELECT ST_AsText(geom) FROM test_pg it correctly outputs the polygon coordinates.

Now in QGIS, I add the SpatiaLite layer but the polygon does not get displayed (even after clicking on this zoom to layer thing). Geometry seems to be valid, I checked it with the QGIS tool. I also found out that when moving the cursor on the map in the east direction, 47.xxx (LAT in this case) gets increased, when moving the cursor in the north direction, 8.xxx gets increased. This should be reversed, shouldn't it?

Where are my errors?

EDIT: I also INSERTED a polygon with LON LAT coordinates reversed. This polygon actually gets displayed in QGIS, but again, 47.xxx is displayed as LON and 8.xxx as LAT where it should be the opposite actually.

EDIT2: Consider this question as closed. For some reasons, it suddenly works. Don't ask me why, maybe restarting QGIS several times helped...

share|improve this question
add comment

closed as too localized by underdark Feb 15 '13 at 9:26

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

The coordinate format is not SpatiaLite specific - its WKT, and the meaning depends on the spatial reference system. In this case you're using EPSG:4326 which is WGS84 Longitude - Latitude. So the first coordinate is degrees of longitude and second is degrees of latitude, referenced from the WGS-84 origin.

The insert looks OK, but something is obviously wrong from your descriptions - there isn't enough information to tell. Perhaps you've created the table incorrectly (e.g. added the geometry column using some dubious technique). You might not have the coordinate reference system set in QGIS. A bug in QGIS is also possible, but highly unlikely.

share|improve this answer
    
Let's try to sort this out. I added the geometry column according to the recommended way: SELECT AddGeometryColumn('test_pg', 'geom', 4326, 'POLYGON', 'XY') and adding a polygon with 47.x 8.x instad of 8.x 47.x worked, as described above. Secondly, please consider my (now edited) emphasis in the question -isn't that weird? I really think there is a setting in QGIS that I have wrong. What else information do you need? Btw I compiled the latest QGIS from source. Please also consider my various posts in the SpatiaLite group for more information... –  wnstnsmth Feb 15 '13 at 9:13
    
This question can be closed, please look at my EDIT2, +1 for helping me nonetheless. –  wnstnsmth Feb 15 '13 at 9:25
add comment

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