2. Import data - HenrikSpa/qgis-midvatten-plugin GitHub Wiki
This page needs to be updated to reflect imports method in version 1.3.10!
The old import methods (until plugin version 1.3.8) are described here.
Importing obs_points - obs_points triggers
(introduced in version 1.4)
The database contains triggers for table obs_points that automatically keeps the geometries and east and north field synced.
- Importing an obsid without east, north and geography will create an obsid with these columns as NULL without affecting anything else.
- Importing obsids with east and north will automatically calculate a geometry.
- Updating a geometry by moving an obsid will automatically calculate new east and north.
- Updating east or north will automatically calculate a new geometry.
Import data using general csv format
(introduced in version 1.4)
This import function is used to import data structured in tables into the database tables. The source table can either be an .csv file (Load data from file), or it can be the currently selected Qgis vector layer (Load data from all features from active layer/Load data from selected features from active layer).
Load data from file
Requirements for csv files:
- decimal separator can be point (.) or comma (,). The separator will be converted to point (.) automatically when importing to the database.
- a header is recommended but not needed (makes automatic detection of column separator easier)
- column separator is automatically interpreted from the first row: if number of semicolons (;) are more than number of commas (,) then semicolon are assumed to be the column separator in the file.
- Fields can not include ; at the moment.
Recommendation:
- use a header
- use semicolon as column separator
- never include commas or column separator in column names (header fields)
Load data from all/selected features from active layer
This function can be used to import from csv-files and possibly other layers as well that has been loaded into Qgis. The purpose is to be able to use Qgis internal "Add delimited text layer"-function to load csv-files that doesn't meet the requirements of the simpler "Load data from file".
Static value-setting
If the checkbox Static value has been checked, the string written in File column will be written to the current column for all imported rows. This feature can be used to give all imported rows the same comment, flowtype, parameter, unit or other value and is especially useful when importing using Load data from all/selected features from active layer.
A DB-browser is included in the left column for easy access of existing values in the database. Use the browser to find existing values and copy them into the File column fields.
Factor-setting
Multiply the values by a factor during import (useable for unit conversion).
Import logger data using Diver-Office csv-format
(introduced in version 1.4)
This feature is custom made for importing logger data from files using Diver-Office format (http://www.vanessen.com/products/software/diver-office). It supports selection of multiple files at once.
Import logger data using Levelogger csv-format
(introduced in plugin version 1.5)
Same functionality as the Diver-Office csv import but for Leveloggers.
Import w quality from lab data using interlab4 format
(introduced in version 1.4)
The interlab format is a standardized format for exchanging water quality data (http://www.svensktvatten.se/globalassets/dricksvatten/riskanalys-och-provtagning/interlab-4-0.pdf).
This import feature has a sparse dialog used for selecting which reports to import. When starting the import, the user will requested to give the obsid for each report. It supports selection of multiple files at once.
"Save metadata table to file" is a feature to easily extract metadata info from the interlab4 file, for further examination in a text editor.
Import data using FieldLogger format
(introduced in version 1.4)
This import function imports measurements from a result file from the FieldLogger android app (https://play.google.com/store/apps/details?id=nl.artesia.fieldlogger)
- In your QGIS project:
- Choose Midvatten - Import Data - Import data from FieldLogger format
- Choose file to import.
- In the Import data from Fieldlogger dialog:
- Select the staff who made the measurement or write initials.
- Shift dates if needed, (to compensate daylight savings for example).
- Select a period to import. All observations outside the chosen period will be excluded. (3a. future version: Click button "Filter dates")
- Select the sublocations to import. Click the column headers to sort the table if needed.
- Click "Update input fields".
- Specify how the input fields should be imported by...
- First select which import method (target table) to use.
- Import method comments. (Note: The value of the input field will be imported into w_levels, w_flow or w_qual_field if the date_time of the comment matches a date_time of an observation. If the date_time doesn't have a match, it will instead be imported automatically into table comments).
- Import method w_levels: Choose which of the columns meas or level_masl to put the values in.
- Import method w_flow: The value of the input field will be put into the table w_flow column reading. Choose a flowtype and unit which will be put in table w_flow column flowtype and unit. During the import, the user will be asked to give an instrumentid for each obsid.
- Import method w_qual_field: The value of the input field will be put into the table w_qual_field column reading_num. Choose parameter, unit and instrument which will be put in the corresponding w_qual_field columns. Select the input field that contains a depth value if it exists.
- Click "Start import".
Notes:
- The first part of the sublocation (the first column in the sublocation table in Import data from Fieldlogger dialog) is assumed to be the obsid and will be used as such.
- If a chosen sublocation doesn't exist as an obsid in table obs_points, the user will be requested to give the correct obsid, else it will not be imported.
- If the depth input field is given during import method w_qual_field, the user should not select another import method for that input field.
- All input field settings will be saved to the QGIS project when the user click "Start import" or "Save settings". All the chosen settings for the input fields will be prefilled automatically the next time the Fieldlogger import is started. All the settings can be cleared with the button "Clear settings" and restarting the import.