I have a point layer ('points') and a polygon layer ('multipolygons') . I want to load the points layer combined with the centroids of the polygon layer.
Im using GeoPackage and tryed to go a SQL way by inserting the centroids into the points table:
insert into points
select ST_Centroid(geom) as geometry, *
from multipolygons where "tourism"!='NULL'
This returns that error:
table points has 27 columns but 28 values were supplied
Im using the DB-Manager of QGIS:
The GeoPackage was generated from osm.pbf by using ogr2ogr
I need to have the centroids and the points into one place. Also other solutions would be nice (virtual layer?)
Add: According to the answer of user30184, I wrote the following query, resulting in a expected attribute table but without relating geometries:
insert into points (geom, osm_id, name, amenity, historic, leisure, man_made, natural, office, place, sport, tourism)
select st_centroid(geom) as geom, osm_id, name, amenity, historic, leisure, man_made, natural, office, place, sport, tourism
from multipolygons
where tourism in ('attraction','museum','camp_site','caravan_site','hostel','zoo','information','viewpoint')
!= 'NULL'
rather thanis not NULL
? Or do you actually have the string 'null' instead of an actual null value?