3

I have 2 layers and I want to make a clip of layer 1 with layer 2 in SpatiaLite (I'm using the DB Manager within QGIS).

That's the code I'm using:

create table clipped_lines as
select * from lines, estensione
where st_intersects(lines.GEOMETRY, extension.geom)

The table is created but it is not a geographical object so I cannot add it to the QGIS map canvas.

The problem (I think) is that the geom column is seen as a normal column and not as a GEOMETRY column. I've tried to update the column with:

ALTER TABLE clipped_lines
ALTER COLUMN geom TYPE GEOMETRY(LineString,4326);

but nothing happened.

I thought that the st_intersects function updates automatically the geom column.

  • 1
    What type of geometry is lines (I guess a LINESTRING) and extension (or estensione, whichever one it really is)? – BradHards Dec 28 '14 at 23:55
  • Hi @BradHards, yep lines is a LINESTRING while estensione is a MULTIPOLYGON. – matteo Jan 2 '15 at 17:48
2

Try to use RecoverGeometryColumn. The syntax is:

SELECT RecoverGeometryColumn('test_geom', 'the_geom',
4326, 'POINT', 'XY');

For more info see http://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/new-geom.html

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.