I am trying to populate a column in a table from another table using Spatialite. My query will not populate the column, and I can't seem to identify what is wrong. I modeled the query from the following post: http://www.surfaces.co.il/wp-content/uploads/2012/05/SL_update3.png
What I would like to achieve is to have the corresponding values from lu_grid.gridid to populate lu_geophotos.gridid where lu_geophotos intersects with lu_grid. (A column in a point layer should get the values from a polygon where the points intersect the polygon)
Here is my code:
UPDATE lu_geophotos SET gridid = (SELECT GRIDID
FROM lu_grid AS s
WHERE ST_WITHIN (s.Geometry, lu_geophotos.Geometry)
AND s.ROWID IN (SELECT ROWID
FROM SpatialIndex
WHERE f_table_name = 'lu_grid' AND search_frame = lu_geophotos.Geometry)
);
SELECT GRIDID FROM lu_grid WHERE ST_Within(lu_grid.Geometry, lu_geophotos.Geometry) LIMIT 5;
give you? The spatial index probably isn't needed because you probably don't have enough entries (10K+) to make it worth the effort.SELECT lu_geophotos.GRIDID FROM lu_geophotos, lu_grid WHERE ST_Within(lu_grid.Geometry, lu_geophotos.Geometry) LIMIT 5;
SELECT AsEwkt(Geometry) FROM lu_grid LIMIT 5;
andSELECT AsEwkt(Geometry) FROM lu_geophotos LIMIT 5;
show? You might want to add that to the question.