Project Swiss Water Ressources

Introduction

This project organizes data about Swiss water resources for researchers and data anlaysts. Multiple collaborators will analyse datasets that are centrally hosted and organised by your project team. Geographical information about rivers, stations as well as regional surface information is tightly coupled to measurements and publicly available sensor data. The relevant open data will be processed, stored and managed in a suitable manner in a database management system such as PostgreSQL/PostGIS. Additionally you will create and store spatial and non-spatial information yourself.

Description

Description, requirement analysis, instructions and tasks are found in this project document on the server.

Reporting

How long should the report be (approximate page number)?

Should we read relevant literature about the topic and mention them in the project description?

Data analysis for ER and DB design

We recommend to you having a close look at datasets later to be imported to the database. Find more information in the previously mentioned project document. We used the following tools and methods to to this and to create an ER-model. We used this template file (Powerpoint) to draw our spatial ER model.

1) Starting the analysis (based on source data files alone)

  1. Download the data needed (csv, xlsx, shape, gpkg, ...);
  2. Visualise spatial data in a new QGIS project
  3. Open .csv files in Notepad++ or similar text editor
  4. Check information (metadata) on website(s)
  5. Try to find out the potential datatypes used in these datasets
  6. Check values and consistency for each field/column in the records/rows. Convenient functionality:
    • QGIS -> Choose Layer -> Properties -> Fields
    • QGIS -> Choose Layer -> Open Attribute Table: Sort each attribute to see what kind of data we really have.
    • Texteditor NotePad++: header text, data rows, sorting, missing or NULL or N/A values (which all means the same).
  7. Do you have troubles with special characters such as ä, ü, not displaying correctly as part of a shape file column? Solution: Add a another text file with file extension .cpg to your other 'shape files' (such as .shp, .dbf, .prj, ...). This .cpg file must have the same name as the other files. Open the .cpg file, type UTF-8, save and close.

2) During dataset analysis (still file based)

3) Based on this analysis and project description and requirement

Importing spatial data to the database

1) Reproject your file based spatial datasets if necessary

2) Import file based spatial datasets to temporary spatial database tables

3) Transfer and convert the data from the temporary tables to the destination spatial tables

4) Generate your own spatial data with attributes in your destination spatial tables

Importing flat (non-spatial) data to the database

1) Convert your source data (e.g from Excel) to .csv files

2) Use DBeaver's Import Data to import .csv files

  1. Under your userxx/projectxx connection rightclick Tables folder in the DBeaver GUI --> Import Data
  2. Source Type and Format --> Next
  3. Input File(s) --> Click on the source to add your .csv file --> Next
  4. Adjust the Column delimiter
  5. Tables mapping --> Click the New... button to create a new database table --> e.g. tmp_contmeasurements
  6. Tables mapping --> Click the Columns...button to create the columns --> Give simple names (no special characters) to target columns or skip (drop down) unneeded ones. Use varchar datatype with sufficient length (e.g. 256) for strings. Use varchar strings for date/datetimes, too. For numbers use datatype numeric. Don't worry about these generic datatypes in your temporary table! You can later CAST these string/number types (the data respecively) from this table to the desired datatypes in your destination table. --> Next
  7. Settings --> Next
  8. Confirm --> Start
  9. All this will create a new table tmp_contmeasurements with varchar/numeric fields filled with your data from the .csv file.

3) Generate data in your (non-spatial) destination tables