3

I have a point layer (xyz_coordinates_UTM33N) and a polygon layer (section1) in a SpatiaLite database.

My SpatialLite database

I wish to extract the points within the polygon to a new layer, and I want that layer stored in the database. Section 1

I know I can create a new layer by using the Intersection tool, but how can I save the new point file without first saving it as a shapefile and then importing it into the database?

Intersection settings

Using the "Save to SpatiaLite table" only creates a new database! How can I accomplish this without all the extra steps?

  • I tried and set the sqlite db as output, and I get an error ProgrammingError: Cannot operate on a closed database. is it same as you ? – Hugo Roussaffa - GeoDatup Nov 1 '17 at 11:28
  • No. When I chose the sqlite db as output I did get an output that appears in the Layers Panel but no points are visible in the Map View. – Alexander B Nov 1 '17 at 11:57
  • which version of QGIS are you using ? – Hugo Roussaffa - GeoDatup Nov 1 '17 at 11:59
  • 2.18.13. No features from the original point file is in the new one. – Alexander B Nov 1 '17 at 12:07
1

You use the QspatiaLite plugin for QGIS. If will handle the creation of the spatial view. I use a building as an example of a polygon.

enter image description here

In the dialog you can write the SQL code doing the spatial join:

select *
from point p
inner join building b on st_within(p.geometry, b.geometry);

enter image description here

The spatiale view is dynamic in regard to it base layers. If you add point or a building the spatial view will be updated when you hit the QGIS refresh button.

enter image description here

0

You got to create a view (="dynamic" query corresponding to your intersection) directly in the spatialite database.

Check Can QGIS read spatialite views ?

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.