使用附件¶
在QField中,带有 附件 控件的字段可用于:
- Show and take photos
- Show and record videos
- Listen and record sound clips
- Show links to external files like PDFs or documents
To configure the Widget, please refer to the Attributes Form Documentation
为要素添加多张图片¶
桌面端筹备工作
It is also possible to add more pictures to the feature either by having several attachment field attributes or by creating a relation to a separate table where the image paths are shown. In this section we will show you an example how this is done. A relation to a second layer needs to be set in the QGIS properties so that when adding images or other formats, these are stored in the related table.
Workflow
-
Create two two tables following the style as shown below. One table where the features are stored and one with a list of pictures.
Apiary:
Field Type id
Text (UUID) geometry
Geometry ...
Apiary_pictures:
Field Type id
Text (UUID) apiary_id
Text (UUID) path
Text ...
关系¶
创建关系如下:
apiary
被引用图层id
被引用字段apiary_picture
引用图层apiary_id
引用字段strength
组合
Attribute Form configuration¶
Once you have created the relation the relation can be properly configured in the feature layer's attribute forms. In the apiary layer we have to specify a default value to create a unique id. For the apiary_picture layer, you will have to change the widget type to Attachment
Workflow
Apiary
- Direct to Properties > Attribute Form
- For the uuid field choose between the Text Edit or UUID Generator widget.
- Set the default value to
uuid('WithoutBraces')
. - Hide it from the view as it should not be edited by the user.
将关系控件设置为 多对一关系 并将关系添加到表单
**Apiary_picture**
1. Direct to *Properties* > *Attribute Form*
2. Set the widget type of the field `path` to *Attachment*
3. Add it to the form layout.
Drawing and sketching¶
QField has an in-app drawing and sketching functionality enabling you to directly sketch over and annotate images captured while in the field as well as drawing on top of a blank canvas or over a template.
Drawing templates¶
On top of annotating captured images, QField supports drawing from image templates. The following two methods are available to add templates:
- The first method is to create a
drawing_templates
folder located alongside a project file and populate it with images. Whenever that project is loaded, QField will register all images within that folder as drawing templates. - Alternatively, you can add images into the
drawing_templates
folder found inside your QField app folder. If you are not familiar with that app folder, its location is shown at the bottom of the About QField overlay.
Templates shipped alongside projects as well as the QField app folder will be shown when users choose "Draw a sketch" by pressing the (⋮) menu icon of the attachment widget.
地理标记¶
QField界面
QField's internal; camera will automatically geotag your pictures.
Information about location and direction of the pictures will therefore be baked into the image file.
Note
While with older Android versions it was possible to use other apps like the amazing OpenCamera app for taking pictures and preserving EXIF information from there, this is no longer with recent Android versions. Is recommended to disable Use native Camera in the settings to preserve EXIF information.
Image Stamping¶
QField allows you to add image stamping. This is configured directly from the QFieldSync plugin in QGIS. With this functionality you can add detailed and formatted information when taking photos in the field.
Styling Settings¶
桌面端筹备工作
Navigate to the Project > Properties > QField > Attachments and Directories sub-panel and click on "Settings" for "Customize image stamping details".
You can add the following settings:
-
Font and Alignment: You have full control over the appearance of the stamped text, including the font style (color, size, drop shadow) and horizontal alignment (left, center, or right).
-
Image Decoration: Add a custom image overlay, such as a logo or a watermark, on top of the captured image.
-
Force Stamping: This option enforces image stamping, ensuring that all images collected for the project have the required information overlaid, regardless of the individual QField app settings.
-
Stamp Details: Craft a multiline string using QGIS expressions to define the information stamped on the image. A default template is provided to get you started, which includes common variables like date, time, and GNSS information.
Default Template:
[% format_date(now(), 'yyyy-MM-dd @ HH:mm') %]
Latitude [% coalesce(format_number(y(@gnss_coordinate), 7), 'N/A') %] | Longitude [% coalesce(format_number(x(@gnss_coordinate), 7), 'N/A') %] | Altitude [% coalesce(format_number(z(@gnss_coordinate), 3) || ' m', 'N/A') %]
Speed [% if(@gnss_ground_speed != 'nan', format_number(@gnss_ground_speed, 3) || ' m/s', 'N/A') %] | Orientation [% if(@gnss_orientation != 'nan', format_number(@gnss_orientation, 1) || ' °', 'N/A') %]
Example
将图像文件中的地理标签 (EXIF) 提取到属性表¶
桌面端筹备工作
Sometimes you might be interested in automatically storing Geotags such as the latitude, longitude, orientation, etc. This information is also known as EXIF tags.
要存储EXIF信息,请执行以下步骤:
- 在包含图片的表中为每个EXIF标签添加属性。
- 在图片表单中,将每个属性的默认值配置为相应的 EXIF expression See QGIS EXIF function, 并确保 更新时应用 已激活。
- QGIS文档列出了QField可以捕获的EXIF标签 (上面的链接)。 However, this list might slightly vary depending on the mobile characteristics.
- Capturing EXIF tags requires accessing the full physical path of the picture.
Be sure to reflect this in the QGIS expression.
For example, the expression
exif(@project_folder + '/' + "path", 'Exif.Image.Orientation')
retrieves the orientation of the picture stored in path. For more tags visit the QField EXIF reference documentation and the exiv library documentation. - Completed! QField now captures and stores the EXIF tags in the pictures table while taking pictures.
最大图片尺寸¶
桌面端筹备工作
The advanced settings allow rescaling the photos to a maximum width/height in Project > Properties > Attachments and Directories
配置附件路径¶
桌面端筹备工作
QFieldSync provides the possibility to configure the path and the file names of picture attachments.
- Go to Vector Layer Properties > QField
- 选择图层、字段并配置表达式
Use expressions to specify the path of the attachments. By default, pictures are saved into the "DCIM" folder, audio are saved into the "audio" folder and videos are saved into "video" with a timestamp as name.
Additional directories can be synchronized with pictures or other attachments. Extra paths can be configured in Attachment and Directories tab in the QFieldSync settings under Project > Properties > QField. All paths are relative to the project directory.