2

I'm not good at all with SQL, so maybe the question is trivial.

I have a polygon loaded in a SpatiaLite DB and I'm using DB Manager in QGIS.

What I'm trying to do is to rotate the polygon by a given number (in degrees) using the RotateCoords function. The syntax should be:

CREATE TABLE rotated as 
SELECT RotateCoords(Geometry, 45) AS Geometry from my_table

It seems to work, but I have to major issues:

  1. How can I select all the fields from my_table in the same query? I'd like to maintain the same table, just rotate it. Another option could be to update the Geometry column of the existing table

  2. The query of above creates a simple table, when I try to update the Geometry column and make the table as a spatial table it seems that nothing happens:

SELECT RecoverGeometryColumn(‘rotated’, ‘Geometry’, 3003 , ‘MULTIPOLYGON’, ‘XY’)

Am I missing something?

  • You must pick also all the attributes into the new table with SELECT. Another option is to select only primary key and geometry and join the attributes from the original table. About registering the new table, I am not sure if RotateCoords can change one part multipolygons into single part but I would try if 'GEOMETRY' works instead of 'MULTIPOLYGON'. Spatialite-gui may be a better tool for this. – user30184 Nov 2 '16 at 11:54
  • can i do it in the same query? or should I select the geometry and PK columns, perform the rotation with this table and then join all the attributes? – matteo Nov 2 '16 at 11:58
  • I recommend just to sit down and write select RotateCoords(Geometry, 45) AS Geometry, attr_1, attr_2, attr_3, attr_4 ... from... – user30184 Nov 2 '16 at 12:01

Your Answer

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

Browse other questions tagged or ask your own question.