So although I have used GIS for a number of years, still struggle with most of its intricacies.
A colleague wants to take a tablet out to inspect trees in the local authority which we work. I have followed the instructions here and set up a points layer (workspace1 — trees) and a related text layer for repeated inspections (workspace1 — repeat_inspections).
Two fields in the trees layer are linked to a text layer (workspace1 — tree_species) which has tree varieties on it. I use this to autopopulate the trees layer via a dropdown. This works fine. What I would like to do is pull through these two populated fields from the workspace1 — trees layer to the workspace1 — repeat_inspections layer so my colleagues don’t have to fill them in again.
I have also put in another eastings a northings field on the workspace1 — trees layer and id like to pull these through to the workspace1 — repeat_inspections layer as well.
I have had a go by playing in the default value layer but googles suggestions haven’t helped and I have not managed to pull them through. Can anyone help?
Could you explain more what you want to do with the repeated_inspections layer? What is it used for? What is each row representing? Is this layer being edited in the field, or in the office?
Is this layer being used to populate certain fields in your worksspace1 - trees layer?
I think your main intention is to have a dynamic list of possible tree varieties, while allowing to add more options in the field, is that right?
If so, I think you’re on the right track. But it might be easier to achieve by holding all your data in a single layer. Check this other video from the same guy, particularly at “method 3”, this might be closer to what you want. In short, the idea is to create a ‘Value map’ widget type that is autopopulated with all the options available on a certain field of the same layer (this is achieved by the “Load data from layer“ option). I haven’t tried it myself, but you might need to combine this with the next video tutorial in that series, since the ‘Autocomplete’ widget might allow you to manually type a non-existent value.
I’m not sure I get the reason for this? You should already have the northing an easting data of a feature in the geometry data of the workspace1 – trees layer? If you need them in text form to further process, maybe exporting the layer with the actual geometry to a spreadsheet format (.csv, .ods, etc.) might be a good alternative?
My colleague is wanting to inspect trees. He will go out, inspect a tree and populate the form. This info is the workspace1 — trees layer.
At a later date he will wish to go out and reinspect the tree. This data will go into the workspace1 — repeat_inspections layer.
What I want is for some fields in this repeat inspections layer to automatically populate with info from the workspace1 — trees layer.
Ath the moment I want the Species and Common name to automatically populate and also the x and y fields.
In the end I am hoping to be able to show the workspace1 — trees layer and on top of that show the workspace1 — repeat_inspections layer on a GIS. My colleague will then be able to view the original inspection along with any subsequent ones.
I am sure there are better ways of doing this but my knowledge of GIS and QGIS in particular is limited.
There is an advanced way of doing this, and that is to create a one-to-many relation between the trees layer and the repeat_inspections layer, similar to the method of having multiple photo’s attached to a single tree . There are some great youtube video’s on creating this relation for photo’s.
However, a less advanced (so probably more easy) way is to just ‘fill the fields’.
What you need is a field in your repeat_inspections layer that contains a unique id for the tree to be reinspected and this id has to be the same unique id the tree has in the trees layer.
Based on that you can fill any additional field by referencing this id, using a default value expression in your attributes form. The Default Value expression for the field Species in the repeat_inspection layer is something like this:
In this expression:
get_feature is locating the feature (the tree) in the trees layer where the tree_id value is the same as the inspect_tree_id value in your repeat_inspection_layer
attribute (get_feature(), ‘tree_species’) will give you the value in the field tree_species in your trees layer for the resulting feature from get_feature
Please pay attention to the correct use of single and double quotes. And make sure the tree_id’s in your trees layer are unique, otherwise get_feature() will always return the first match found.
Ok! I propose a different approach, let me know if this works for you colleague’s use case. This is mainly based on my limited experience with GIS, but I think that achieves the same goal while simplifying things:
To use a single dataset, a single file.
This layer should contain all tree inspections, not just the repeated ones (original repeat_inspections) and not only a list of indiviual trees (original trees layer). There would be no distinction, a priori, between the trees and inspections; this layer would only contain “inspections”, to put it in another way.
To make two layers of this only dataset. For example, by drag ‘n drop of the dataset on QGIS to create the first layer, and then right clicking on this layer and choosing “Duplicate layer”. The original layer will become the equivalent of your “repeat_inspections”.
To make this duplicated layer a “filtered” view of the original (right click on the layer, and then Filter), on which you only show the first instance of a record that shows a particular tree specimen. This should effectively work as your “trees” layer.
In regards to having the northing and easting values of each tree as plain attributes, to me the best alternative would be to create two extra fields on your layer (one for “northings”, other for “eastings”, of course) and on the Attribute Form, set the “Default value” (typically at the bottom of the configuration page) of those layers to y(@position_coordinate) and x(@position_coordinate) respectively. Check this documentation and this other one to learn more about Default Values and QField.