I told you that I made such a plug-in
Plugin file from github Animations are only available from QGIS version 3.14, so please use 3.14 or above when using plugins
Grid Point Value. It stores the data of the physical quantity of the atmosphere for each grid point several hours ahead, which was obtained by running a forecast program called a numerical weather prediction model using the results of meteorological observation. The weather forecast is made based on this GPV.
There are several types of GPV forecast models depending on the type of weather forecast to be forecast, and the main ones are as follows.
Model type | Forecast area | Lattice spacing | Main forecast |
---|---|---|---|
Full holiday model(GSM) | The whole earth | About 20km(0.2 degrees x 0.25 degrees) | Prefectural weather forecast, Weekly weather forecast, etc. |
Meso model(MSM) | Around Japan | About 5km(0.1 degree x 0.125 degrees) | Precipitation short-term forecast, Disaster prevention weather information, etc. |
Local model (LFM) | Around Japan | About 2km (0.02 degrees x 0.025 degrees) | Precipitation short-term forecast, Disaster prevention weather information, etc. |
These GPVs are provided by the Japan Meteorological Agency, and if you want to use them for business, you need to purchase them through the Meteorological Business Support Center, but this time, plug them using sample data (the ground surface of the MSM model). I verified the inn. List of GPV sample data from Japan Meteorological Agency
In the case of MSM, it is "Z__C_RJTD_yyyyMMddhhmmss_MSM_GPV_Rjp _Lsurf_FHhh-hh_grib2.bin", MSM is the mesomodel, Lsurf is the ground surface, and FH is the forecast period. What is L-pall instead of Lsurf indicates that it is pressure level data. For Lsurf, the predicted value is stored every hour, and for L-pall, the predicted value every 3 hours (up to 15 hours ahead) is also stored.
GPV data is provided in Grib2 format, and I use wgrib2 etc. to retrieve the data while hitting a command. Do you know that you can open it with QGIS without any complicated things? Yes, just drag and drop what to hide.
This GPV data. If you add it in QGIS, it will be treated as multi-band raster data, and in the first state you add it, the rendering will be set to multi-band. Values such as barometric pressure, wind, and temperature for each altitude are stored in each band. You can see what element values are stored in the GPV sample data list page above. This time, I am using GPV on the ground surface of MSM, so elements such as sea level correction pressure, wind vector, and temperature are packed, but I can not understand anything by looking at the band.
Therefore, if you look at the "information" of the property, you can see the information of each band. For example, in band 1, it can be seen that Pressure reduced to MSL (sea level correction pressure). Also, as you can see that there is FORECAST_SECONDS in the information, the predicted value is also stored in another band. In the case of sea level correction pressure, band 1 (initial value), 11 (1 hour ahead), 23 (2 hours ahead), 35 (3 hours ahead), 47 (4 hours ahead), and so on, up to 14 hours ahead. It is designed to include forecast values.
So, I made contour lines for each of the initial and predicted values for a specific element in QGIS, and then made a plug-in that makes it easy to create animations using the Temporal Controller installed in QGIS ver.3.14.
--Download the plugin from github and install it by specifying the zip from "Manage and install plugins" in QGIS.
--The icon will be added when you install it. It ’s a contour-like icon.
--Click the icon to launch the plugin.
--Select the target GPV data and the element to create the contour. At present, you can specify the sea level correction pressure and ground pressure for the ground surface, and each pressure level altitude for the pressure level.
--When executed, contours are created. Since all the contours for each predicted time are output, it may be difficult to mess up something.
--Start the Temporal controller installed from QGIS ver.3.14 and set the animation. If you set Step to 30 minutes for Lsurf and 1.5 hours for L-pall, you will get a nice animation.
--Press the play button to play the animation.
The layer name of the output contour is as follows.
You can create contours by selecting "Raster"-> "Extract"-> "Contours" on the QGIS toolbar, but if you write in pyQGIS it will look like this.
processing.run("gdal:contour", {'INPUT':Input raster layer, 'BAND':Band to contour, 'INTERVAL': interval, 'FIELD_NAME': 'Contour','CREATE_3D': False, 'IGNORE_NODATA': False, 'NODATA': None, 'OFFSET': 0, 'EXTRA': '', 'OUTPUT': 'TEMPORARY_OUTPUT'})
Processing is executed by looping the band specified by BAND with the band of the initial value and the predicted value of the element to be contoured. For example, in the case of the mesomodel ground surface Sea level correction pressure band 1,11,23,35,47,59,71,83,95,107,119,131,143,155,167,179 Ground pressure band 1,11,23,35,47,59,71,83,95,107,119,131,143,155,167,179 In the case of barometric pressure I am trying to specify the band 1,93,185,277,369,461 at an altitude of 1000hPa.
The output contour is set to Temporal Controller.
vlayer =Specify layer
mode = QgsVectorLayerTemporalProperties.ModeFixedTemporalRange
tprops = vlayer.temporalProperties()
tprops.setMode(mode)
tprops.setFixedTemporalRange(QgsDateTimeRange(
QDateTime(QDate(YYYY, MM, DD), QTime(start hh, 0, 0, 0), Qt.UTC),
QDateTime(QDate(YYYY, MM, DD), QTime(end hh, 0, 0, 0), Qt.UTC)))
tprops.setIsActive(True)
In addition to ModeFixedTemporalRange (Fixed Time Range in Configuration), mode can be specified such as ModeFeatureDateTimeInstantFromField (Single Field with Date/Time) and ModeFeatureDateTimeStartAndEndFromFields (Separate Fields for Start and End Date/Time).
Labels are set every 20hPa for the isobars and every 60m for the contour lines of the barometric pressure surface.
# set labeling
pal_layer = QgsPalLayerSettings()
pal_layer.isExpression = True
pal_layer.fieldName = labelSetting[0]
pal_layer.enabled = True
pal_layer.placement = QgsPalLayerSettings.Line
# Create and append a new rule
root = QgsRuleBasedLabeling.Rule(QgsPalLayerSettings())
rule = QgsRuleBasedLabeling.Rule(pal_layer)
rule.setDescription('Label description')
rule.setFilterExpression(Specify label field)
root.appendChild(rule)
# Apply label configuration
vlayer.setLabelsEnabled(True)
rules = QgsRuleBasedLabeling(root)
vlayer.setLabeling(rules)
vlayer.triggerRepaint()
The contour lines are set to light gray. Currently, all contour lines have the same thickness, but in the future we would like to make the contour lines thicker every 20hPa.
# set symbol
single_symbol_renderer = vlayer.renderer()
symbol = single_symbol_renderer.symbol()
# Set stroke colour
symbol.setColor(QColor.fromRgb(100, 100, 100))
# Refresh
vlayer.triggerRepaint()
iface.layerTreeView().refreshLayerSymbology(vlayer.id())
If you want to use GPV properly for business, you have to purchase it from the Meteorological Business Support Center, but for research purposes, you can use it from the following.
In addition to atmospheric pressure, GPV contains wind vectors, temperature, cloud cover, and various values, so I would like to implement visualization of these values as well.
Recommended Posts