7. Setup the survey layers

7.1. Setup the Survey point layer

The default project already has a Survey point layer. You can use any vector layer for surveying, but here we'll add fields to the existing Survey point layer.

1. Open the attribute table of the Survey layer: in the Layers panel right-click on the Survey layer and choose Open Attribute Table from the context menu.

You can see that it already has some attributes: fid, date, notes, photo. Let's add a few more, related to crop mapping.

2. Click to switch to editing mode.

3. Click to add a new field.

Let's add a field for an observation number.

4. In the Add Field dialog type Obs for the Name, use Text (string) for type (in that way we can add alphanumeric codes for our observation numbers) and use a Length of 5 characters.

5. Click OK to add the new field to the attribute table.

6. Repeat this for the following attributes:

Field name
Type Length
Name Text (string)
50
LandCover Text (string)
50
Crop Text (string)
50
WaterSource Text (string) 50
IrriMethod Text (string)
50
Coverage Decimal number (real)
 3

7. Click to toggle off editing and save the changes.


Now let's create the widgets for the observation form.

Mergin Maps supports many widgets. You can check them here.

8. To setup the Form Widgets, right-click on the Survey layer in the Layers panel and choose Properties... from the context menu.

9. In the Layer Properties dialog go to the Attributes Form tab and choose Drag and Drop Designer from the drop-down menu.

In this dialog we can interactively create our field form with the widgets.

10. First, we don't want to use the fid field. Select fid from the Form Layout panel and click the icon.

11. Lets rearrange the items. You can drag and drop the items rearrange. Here we use this order:

Now we'll configure the form widgets.

12. Click on Obs in the Form Layout panel.

Now you can see the widget settings in the right panel of the dialog.

13. We can give more human readable names to the fields using and alias. In the Alias field of Obs type Observation number.

14. Under Constraints we check the boxes for Not null and Unique, to make sure that a value is filled in and that the code is unique. Also check the boxes to enforce the constraints. Keep the rest as default.

15. Now click the date field in the Form Layout panel.

16. For Alias type Date/Time.

17. For Widget Display choose Custom and type dd-MM-yyyy HH:mm:sss for the format You can see the result in the Preview.

18. Set the Contraints to Not null.

19. Under Defaults we can set an expression so the current date and time are used. Type

$now



20. Now choose Name from the Form Layout. Use the following settings:


21. For the photo field we should keep the default settings, so the relative path to the picture is stored and the Integrated Document Viewer is used to show the image. Only type Picture at Alias.


22. For LandCover type the Alias Land cover type.

For the land cover types we would like to use a drop-down menu. We can define that with the Value Map widget.

23. Under Widget Type choose Value Map and use the following Value/Description combinations:

Value Description
Cropland Cropland
Tree Cover Tree Cover
Shrubland Shrubland
Grassland Grassland
Wetland Wetland
Artificial Artificial
Bare soil Bare soil
Fallow land Fallow land
Seasonal water Seasonal water
Permanent water Permanent water


24. Use the Not Null Constraint.

25. For Crop use the Alias Crop type.

26. Also here use the Value Map widget. Use the following Value/Description combinations:

Value
Description
Wheat Wheat
Maize Maize
Rice Rice
Barley Barley
Soy beans Soy beans
Pulses Pulses
Cotton Cotton
Potatoes Potatoes
Alfalfa Alfalfa
Sorghum Sorghum
Other Other

27. We only want the crop type when the land cover type is crops. Therefore, we'll add an Expression under Constraints. Click  to open the Expression Dialog.
28. In the Expression Dialog compose the following expression:
"LandCover" = 'Cropland'
Note that you can double click on the field name in the middle panel to add the field name to the expression with double quotes. Single quotes are used for strings.

29. Click OK.




30. For WaterSource use the following settings:


Note that you can add the same expression for the constraint as was used for the crop type by choosing the expression under Recent in the Expression Dialog.



32. For IrriMethod use the following settings:


You can compose expression in the Expression Dialog in the following way:

33. For Coverage we're going to use a slider. Use the following settings:


34. For notes, use Alias Notes and set the Text Edit widget to Multiline.


On your mobile device you can see a preview of the survey point. We can setup this preview so we can see the observation number and the picture.

36. Go to the Display tab.

37. Under Display Name, use the drop-down list to choose the Observation number.

38. Under HTML Map Tip write the following expression:

# image
file:///[%@project_folder%]/[% "photo" %]
This refers to the image path in the photo field in the attribute table.


39. Click OK to apply and close the dialog.

Don't forget to regularly save the project.

The field form for the Survey point layer is now ready. We'll now add a second survey layer where we can update the parcel layer with the crops we see in the field.