I have a set of maps that intensively utilizes virtual layers, but last week our boss updated from QGis 3.10/3.18 to 3.20.3 in all PCs, and now the layers are not loading.

Normally they would refresh on startup and start showing my data automatically, but now they show as broken data links. When I reload the main layer, It shows properly; I think its because its a simple SELECT with a where statement.

But when I reload the layers that depend on spatial query (ST_UNION), they are calculated (I can see the data in their tables) but with no visible geometry. I did note that Geometry option changes automatically to "Autodetect" when opening the map in QGis 3.20.3 from it previous type MultiPoligon, but if I try to change it back and test the layer, it shows an alert saying "Cannot find the specified geometry field!" (it did not happen in QGis 3.10 or 3.18.1).

Already tried naming the calculated geometry with another name both in SQL and in Geometry options below, with no result. Giving it a CRS, though I didn't need it before, also doesn't fix the problem.

I don't know what else can I try, browsed some forums but didn't find anyone with this problem, and due to burocratic times, getting 3.18 back is not an easy option.

Example 3.18.1
Example 3.20.3

  • 1
    Is it okay that on the second image the Point was chosen as Geometry type, on the first image it is MultiPolygon? Can you try either the same or changing to the the Autodetect?
    – Taras
    Oct 5, 2021 at 12:26
  • My mistake on the photo, I was doing that only to take the image and forgot to change it to multipolygon. Anyway, changing it to autodetect throws no error but the resulting layer has no geometry, but it has a field called geometry with a weird code in it
    – Opazo
    Oct 5, 2021 at 13:42
  • 1
    Can you please correct your question? And also can you please show the error to us? Did you try using your expression without an alias, with ` AS geom` and with AS geometry? Maybe using an alias for "VIRTUAL_ORIGEN_PARCELAS" AS par and then par.geometry can help, or it will is not sufficient for you?
    – Taras
    Oct 5, 2021 at 13:50
  • tryed SELECT par.ejido, par.circ, par.radio, par.mzna, par.cc, par.ten, par.registrado, RANK() OVER (ORDER BY CalcRegistrado(par.TEN,par.REGISTRADO)) AS color, st_buffer(st_union(par.geometry),0.05) AS geometry FROM "VIRTUAL_ORIGEN_PARCELAS" as par WHERE registrado IS NOT NULL AND registrado <> '' GROUP BY par.circ, par.radio, par.cc, par.ten <> 'S', par.mzna, CalcRegistrado(par.ten,par.registrado) but with no results
    – Opazo
    Oct 5, 2021 at 14:03
  • 1
    VIRTUAL_ORIGEN_PARCELAS seems to also be a virtual layer, have a look at its name/alias for the geometry column
    – JGH
    Oct 5, 2021 at 14:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.