I have a point feature (Pontos_de_monitoramento) and another non-spatial table (ficha_campo). I am adding new features to the non-spatial table (ficha_campo) and one of the fields to be filled in is the NAME_POINT field from the feature in Pontos_de_monitoramento, figure below.

Example of QGIS project

I prepared a form as shown in the figure below, using the Value Relation widget relating the NAME_POINT field from the ficha_campo table with the NAME_POINT field from the Pontos_de_monitoramento table, so that all the values from features in the Pontos_de_monitoramento table are listed for me to choose from, but the list is very large.

I would like to know if the list can be reduced, showing only the points that are visible on the screen when filling out the table.


list of names to be chosen

1 Answer 1


As far as I know there isn't an in-built function to get the canvas extent just yet, but you could create a custom function to do so.

  1. Follow the instructions in step 1 of JGH's answer to Selecting features visible in canvas extent to create a custom function to get the canvas extent.

  2. Then under the Filter section of your Value Relation widget, use the expression intersects($geometry,currentExtent())

enter image description here

Please note though performance can be slow on large datasets. You may need to create a custom Python function that can perform the intersection more efficiently.

Example below is with a point dataset of 45000 features.

enter image description here

  • Will this created function "currentExtent" work on any machine where I open the QGZ project, or only on the machine where I created it? How can I get it incorporated into QGZ so it can work anywhere?
    – Denilson
    Commented Nov 30, 2023 at 20:33
  • I think it's possible to save the custom function into the project instead of user profile by moving the script into the startup macros section per github.com/qgis/QGIS/issues/39330 - although this is from a few years ago. Each device would also need to enable macros in qgis settings I think. To use the function script in macros it might need slight tweaking, I haven't tried it myself
    – she_weeds
    Commented Nov 30, 2023 at 22:54
  • I tried but I couldn't Associate custom Python functions with a project instead of a user profile. Is there any other way to do what was suggested in the channel github.com/qgis/QGIS/issues/39330 so that it works in any QGIS project? ​
    – Denilson
    Commented Dec 12, 2023 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.