qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.07k stars 2.92k forks source link

Allow use of Layer_Properties() Function in graphical models #31971

Open josephholler opened 4 years ago

josephholler commented 4 years ago

The only inputs for which the field calculator layer_property() function is working in QGIS graphical modeler are for all features. In the attached model, I input layers, point layers, polygon layers, features, point features, and polygon features, and try to find the CRS for each input. The result is NULL unless the input is of the type features and the 'selected features' option is not used.

  1. load the project
  2. select one point from CBD layer and one or more tracts from tracts2010 layer
  3. run the test input layer properties model, using the 'selected features only' option when available
  4. note the outputs are all null, except for features inputs for which you may have forgotten to exercise the 'selected features only' option.

I thought that any of these inputs would have layer properties, including CRS metadata, and that the layer_property() function would be able query that metadata. It's necessary, e.g. in order to use the field calculator transform() function correctly. test_layerproperties.zip

I suspect the same pattern of errors exists for using the Execute SQL algorithm, but need to do more testing.

QGIS Version 3.8.2 on Windows 10

nyalldawson commented 4 years ago

This is actually a feature request -- the function is not designed for use in models, and it's just chance that it works occassionally.

kannes commented 2 years ago

Is this still the case? I made a model that works on many installations but not on others (e.g. works on 3.24.3 on Linux but not on Windows nor in 3.20.x on Linux, on different machines, all with fresh profiles) where I try to use layer_property(@raster_layer_input, 'id') or ..., 'crs').

Is there any way of knowing which functions are guaranteed to work in models and which are not?

bchartier commented 1 year ago

Any answer or clue for this question would be greatly appreciated:

Is there any way of knowing which functions are guaranteed to work in models and which are not?