--
You received this message because you are subscribed to the Google Groups "SpatiaLite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spatialite-use...@googlegroups.com.
To post to this group, send email to spatiali...@googlegroups.com.
Visit this group at https://groups.google.com/group/spatialite-users.
For more options, visit https://groups.google.com/d/optout.
SELECT r.PK_UID as rowid, r.ID_CELLA as id_cella, r.geometry as geom, p.COD_90 as cod_90, p.COD_00 as cod_00, p.COD_08 as cod_08FROM iuti_punti as p, iuti_reticolo as rWHERE
( -- filter out all rows that are out of the question, returning only candidates [fast]
r.ROWID IN ( SELECT rowid FROM SpatialIndex WHERE
( (f_table_name = 'iuti_reticolo') AND
-- you are searching for a geometry in p (search_frame = p.geometry) ) ) AND -- check if candidates are contained in p.geometry [slow] (ST_CONTAINS (r.geometry, p.geometry) = 1));
Your search frame should be 'p' not 'r'.ie: search_frame = p.geometryAlso you should be able to remove the WHERE ST_CONTAINS statement, if they are squares then you shouldn't need this.
* when yes, does 'iuti_reticolo' have a second geometry?
* --> if yes: add (f_geometry_column = 'geometry')
On Thursday, 20 September 2018 10:20:31 UTC+2, ludovico frate wrote:Hi,I have two dataset, one representing 1.200.000 points and the other 1.200.000 square cells, where each point falls inside one square (a kind of 1:1 relationship). I would like to perform a spatial join between the two datasets, using spatial index.
The query that I used to perform a simple spatial join was:SELECT r.PK_UID as rowid, r.ID_CELLA as id_cella, r.geometry as geom, p.COD_90 as cod_90, p.COD_00 as cod_00, p.COD_08 as cod_08FROM iuti_punti as p, iuti_reticolo as rWHERE ST_CONTAINS (r.geometry, p.geometry) = 1but this takes a lot of time (not sure if the process will be completed).Thus, I've tried to implement spatial index into my query (after creating the index), but without success:SELECT r.PK_UID as rowid, r.ID_CELLA as id_cella, r.geometry as geom,p.COD_90 as cod_90, p.COD_00 as cod_00, p.COD_08 as cod_08FROM iuti_punti as p, iuti_reticolo as rWHERE ST_CONTAINS (r.geometry, p.geometry) = 1AND r.ROWID IN (SELECT rowid FROM SpatialIndexWHERE f_table_name = 'iuti_reticolo'AND search_frame = r.geometry)Any suggestions?
CREATE VIEW iuti_join as
SELECT r.PK_UID as rowid,
r.ID_CELLA as id_cella,
r.geometry as geom,
p.COD_90 as cod_90,
p.COD_00 as cod_00,
p.COD_08 as cod_08
FROM iuti_punti as p, iuti_reticolo as r
WHERE ST_CONTAINS (r.geometry, p.geometry) = 1
AND r.ROWID IN (
SELECT rowid FROM SpatialIndex
WHERE f_table_name = 'iuti_reticolo'
AND search_frame = p.geometry
)
INSERT INTO views_geometry_columns VALUES
('iuti_join', 'geom', 'rowid', 'iuti_reticolo', 'geometry', 1)
I have another problem.The query works well.I created a view form that query with the following script:
CREATE VIEW iuti_join as
SELECT r.PK_UID as rowid,
r.ID_CELLA as id_cella,
r.geometry as geom,
p.COD_90 as cod_90,
p.COD_00 as cod_00,
p.COD_08 as cod_08
FROM iuti_punti as p, iuti_reticolo as r
WHERE ST_CONTAINS (r.geometry, p.geometry) = 1
AND r.ROWID IN (
SELECT rowid FROM SpatialIndex
WHERE f_table_name = 'iuti_reticolo'
AND search_frame = p.geometry
)
and then, I've registered the geometry
INSERT INTO views_geometry_columns VALUES
('iuti_join', 'geom', 'rowid', 'iuti_reticolo', 'geometry', 1)I ve tried to perform a simple query on the view but is very slow.
In addition, even if I'am able to see the geometry in spatialite gui, when I load the view in qgisthrough the DB manager the geometry is not recognized (even if in the table the field geom is present).
On Thursday, 20 September 2018 11:28:15 UTC+2, ludovico frate wrote:I have another problem.The query works well.I created a view form that query with the following script:
CREATE VIEW iuti_join as
SELECT r.PK_UID as rowid,
r.ID_CELLA as id_cella,
r.geometry as geom,
p.COD_90 as cod_90,
p.COD_00 as cod_00,
p.COD_08 as cod_08
FROM iuti_punti as p, iuti_reticolo as r
WHERE ST_CONTAINS (r.geometry, p.geometry) = 1
AND r.ROWID IN (
SELECT rowid FROM SpatialIndex
WHERE f_table_name = 'iuti_reticolo'
AND search_frame = p.geometry
)
and then, I've registered the geometry
INSERT INTO views_geometry_columns VALUES
('iuti_join', 'geom', 'rowid', 'iuti_reticolo', 'geometry', 1)I ve tried to perform a simple query on the view but is very slow.You should read through the new Cookbook topic about the SpatialIndex then