In the previous article we discussed How to integrate free marine and terrestrial weather forecasts into ArcGis.
In this article we will discuss how to integrate weather forecasts into a QGis project . We will use marine forecast data for 8 days. These data is provided by the companies NASCA and ACTIMAR , via the products enav-forecast . Besides the software that employs and shares these forecasts for consultation and analysis ( enav-viewer , enav-forecast , enav-forecast for iPhone , enav -Pilot ), these companies also provides you with access to data via a WFS connection.
What data is available?
Regarding the data type, you access the 8- day forecasts, every 3 hours, for the following parameters:
- height (in meters) , direction (in °) and wave period (in sec)
- crossed sea (wave direction in ° , direction of the swell in °)
- speed (in knots ) and direction (in °) of the average wind
- speed (in knots ) of wind gusts
- speed (in knots ) and direction (in °) of the surface current
- temperature (in ° C) of the sea surface water
- temperature (in ° C) of the air
- rainfall (in mm)
Which data grid?
The grid of free forecasts is of 0.5 °. Other grids are available but subject to subscription (see subscriptions).
The forecasts cover the whole world.
The forecasts are updated four times a day.
How to set up the WFS connection
To set up a WFS connection you click on the button “Add a WFS layer”, then click on the button “New” to create the connection parameters.
For the name type a high tech option: NASCA Marine Weather, for example.
For the URL, enter the following string:
Click OK to close the configuration.
The connection now appears in the list of possible connections.
Before you log in
Open a project with the WGS84 Geographic SCR. Display a base map that allows you to zoom in on the area of interest. When you connect to the WFS server, QGis will send a query with the coordinates of the four corners of your current display. The server will send the available forecasts inside this rectangle to your machine.
If you are working in projection mode (and not geographical), neither QGis nor the server will make a coordinates transformation. You will have no result in return, often, not even an error message.
Therefore it must be verified that what you are going to transmit are latitude and longitude coordinates in degrees. To do that, simply, look at the status bar at the bottom of the QGis window: you have a field called “coordinates”. The values in this field must be between -180 and 180. If this is the case, you are working with geographic coordinates.
If you are working with geographical coordinates but if you do not zoom in on the area of interest, you may have an area too big for the query. In addition to being time consuming, WFS servers always have a limit for the number of records. When this limit is reached, the server sends the records found and then stops. You will not have a warning message, just the data will be cut.
Logging in to the WFS server
Then, a new connection appears in the list of proposed connections when you click on the button “Add a WFS layer”. Click on the button “Log in”.
You will only use the layer: view_meteo99
Click on this line to select it. Uncheck the box “Cache feature”.
Click on “Add”.
Displaying forecast data
After a few moments, the new layer is added to the QGis map window.
Each “point” of the forecast is, actually, an array of 66 points. To be able to view the forecasts for a given hour, you will have to make a selection on all the data for each point. Performing this job for all the requests is rather complicated and not worth it. The most efficient method is to display all the data in QGis and create a new layer on your workstation.
You can perform this task directly by clicking on the legend of the layer and selecting “Save as …» But do not rush, there are other little things to fix, and we’ll do it all at once.
The WFS connections with QGis have a small flaw: according to the first value found for an attribute field of the table, it defines the data type. Often we are left with numeric fields in the original table of the server, but QGis reads them as text strings. When working with marine forecasts, the problem does not arise for the values of force and speed, which are always values with a decimal point. On the other hand, for direction values, which are depicted by natural numbers, the problem arises.
You will have direction values as a text string. While for a simple display it does not change much, when displaying oriented arrows (currents, waves, wind) it is impossible to request a rotation of the symbol with a text field. It is imperative that the direction field be numeric.
To solve this problem, you must create a new numeric field and use the calculator field to work out the values from the text strings for, and repeat this task for the three direction fields (wave, wind, current).
Tedious work. So, a simpler solution must be found. We have to build a processing model with the QGis “Graphic modeler”. This is a small file that you can download by clicking here .
Unzip the file into a directory of your choice.
Open the Chart Modeler:
In the Modeler window, click the first button to open the downloaded template. Point to the meteoNasca.model file.
The model loads.
To execute it, click on the right button “Launch the model”.
Check that the input file is the layer “view_meteo99”.
Browse the directories to define the location and name of the shape file that will be created on your computer. Select “Save to file”
Click on Run
The new layer is loaded in the map window. You can now delete the WFS layer, it avoids loadings each time you change the grip of the view.
Symbology of forecast data
For simple data (temperature, rainfall, …) the only thing to remember is that you have 66 points superimposed on each forecast location. You must go through a “subset query” in order to show just one step at a time :
Layer properties -> ” General »-> Subset (click on query builder)
You have two attributes, the first for today’s date, the second for the time of day. WARNING! Time is depicted as GMT not in local time.
Before applying the symbology, do not forget to define the selection request. If not, you will have a stack of symbols on each point.
For complex data (wind, waves, current) you have at least two associated values: direction and strength. The classic way to display this type of data is to use an arrow oriented in the direction of the phenomenon and to assign it either a size or a different colour depending on the force.
First thing to know: How is the direction of the phenomenon coded?
All directions present in the attributes of the table indicate the direction from which the phenomenon originates (the direction from which it comes).
To position the arrows, it is necessary to apply a rotation to the symbol. If you choose a symbol “up arrow” and you enter as rotation field only the name of the direction field, your arrows will indicate the opposite direction! In this case, use an expression, for rotation, such as [direction field] – 180.
We have prepared three layer files with standard symbology that should do the trick. You can download them in here .
In the compressed file, you have three Qgis layer style files (wind, current and waves) and a folder with the symbols used for the wind in the weather charts (barbules).
The first three can be extracted in the directory of your choice. On the other hand, the file “barbules” has to be copied in the QGis / apps / qgis / svg installation directory. Otherwise, the symbols will not be accessible for style files.
The symbology for the wind is as follows:
The symbols used are standard barbules, with increments of knots up to 65 knots.
The rotation field is already corrected to depict the correct orientation of the barbules.
The symbology for the current is as follows:
The symbols used are arrows, with increments of 1 knot. The size of the arrows increases according to the speed. Moreover speeds up to 3 knots are in blue, between 3 and 5 are in orange and from 6 knots in red.
The rotation field is corrected by 180 ° to have the correct direction of the arrows.
Remember to add in the selection request, besides date and time, a filter on direction and speed so as not to display the null values at ground level ( CourantVal <> 0 ANDICurDir <> 0 ).
The symbology for the waves is as follows:
The symbols used are arrows, with increments of 1 meter. Heights of up to 3 meters are green, between 4 and 7 are yellow and from 7 knots are orange-red.
The rotation field is corrected by 180 ° to have the right direction of the arrows.
Remember to add in the selection request, besides date and time, a filter on the direction and speed so as not to display the null values at ground level ( HsVal <> 0 AND IHsDir <> 0).
The labels indicate the significant height of the waves in meters, and the wave period in seconds.
If you have any doubt, do not hesitate to leave a comment!