QGIS 3.14|Earthquake data animation effect actual combat (three) progress bar setting

In the previous version, QGIS's processing of time was realized through the Time Manager plug-in. QGIS 3.14 introduced Temporal Controller into the overall software framework to natively support the processing of time dimensions of various data sets.

 

Friends who have used Time Manager know that Time Manager provides time labels by default, showing the time of the current map, as shown below:

 

 

However, Temporal Controller does not provide time stamps by default.

 

 01 Add time stamp

 

For the Temporal Controller lack of the default time label, you can set the point layer label to achieve an effect similar to the Time Manager label. The steps are as follows:

 

First, create a new point layer. Click the [New Temporary Draft Layer] button on the [Data Source Manager] toolbar. In the dialog box that opens, select "Point" for [Geometry Type] and click [OK] to add the new temporary draft to the map window in. Here, you can also create other data sources such as Shapefile, GeoPackage, SpatiaLite, and save the time stamps in other data sources.

 

 

Then, add a point to the new layer and associate the time attribute with the label of the point. In the [Layer] panel, right-click the newly added "New Sketch Layer", and select [Switch Edit State] from the pop-up menu to set the layer to editable state.

 

 

Click the [Add Point Element] button on the [ Digitalization] toolbar, and click on the appropriate position in the map window to add a point element.

 

 

Next, set the point symbolic expression. Click the [Open Layer Style Panel] button above the [Layer] panel , and open [Layer Style] on the right. Click to switch to the label setting page.

 

 

Select "Single label" and click the [Ɛ] button to the right of [Value] to open the expression dialog box.

 

Enter in the expression code editing area:

format_date(@map_start_time,'yyyy-MM-dd')

 

 

This expression formats the map time and draws it on the map as a point label:

 

format_date: String function, output date type in the specified format.

 

@map_start_time: Variable, indicating the start time of the current map frame.

 

'yyyy-MM-dd': format string, follow the Qt date/time format, please refer to the document: https://doc.qt.io/qt-5/qdatetime.html#toString.

 

Close the expression dialog and return to the QGIS map window. You can see that according to the expression, a time label appears to the right of the point. Adjust the font and size of the label until you are satisfied.

 

 

 

If you don't want to see the point next to the time label displayed on the map, you can switch the [Layer Style] panel to the page, and set the symbol to "Unsigned", as shown in the figure below.

 

 

 

At this point, when playing the animation, it is found that the label does not change with the progress of the map animation. This is because the Temporal Controller intelligently determines whether each layer needs to be redrawn during the animation playback process. The layer does not have the Temporal property set, so It will not be redrawn, and the time label will not change.

 

Right-click [New Sketch Layer] to open the layer properties dialog box. Switch to the Temporal page, check the [Temporal] checkbox, and select "Redraw Layer Only" in the [configuration] drop-down box, which means that the layer is redrawn during the animation.

 

 

 

Click the button in the Temporal Controller panel to play the animation and check the effect.

 

 

As you can see, as the animation plays, the time label is always updated to the current map time, which has the same effect as the Time Manager time label.

 

 02 Add progress bar

 

In order to make the map animation effect more vivid, you can add a progress bar to the animation:

 

 

 

First, create a new point layer to store the progress bar. The parameters of the new layer are set as follows:

 

 

 

Edit the "progress bar" layer and add points representing the progress bar.

 

 

 

Next, symbolize the "progress bar" layer.

 

In the [Layer Style] panel, switch to the page and select "Single Symbol". Click [Mark] -> [Simple Mark], select "Ellipse Mark" for [Marker Layer Type] below, and "Left" for [Anchor Point] to make the progress bar grow from left to right. Set the mark type to square. As shown below:

 

 

 

Then, use an expression to set the width of the symbol so that the width gradually increases over time, showing the effect of a progress bar.

 

Click the [ Reload by Data Definition] button on the right side of [Symbol Width] , and select [Assistant] in the pop-up menu to open the symbol width setting panel.

 

 

 

Click the [Ɛ] button on the right side of [Input] -> [Source] to open the expression dialog box.

 

Enter in the expression code editing area:

 

second(@map_start_time  -  @animation_start_time)/second( @animation_interval )

 

 

This expression normalizes the symbol width with a time function and related variables, where:

 

Second: Time function, which calculates the number of seconds between two time intervals.

 

@map_start_time: Variable, indicating the start time of the current map frame.

 

@animation_start_time: Variable, animation start time.

 

@animation_interval: Variable, the total duration of the animation.

 

"@Map_start_time-@animation_start_time" is the difference between the current map frame and the animation start time, divided by the total time of "@animation_interval" to get the progress value, the value range is [0,1].

 

Set other parameters in the [input] section. [Value from] Fill in 0, which means the minimum value of the above expression. [To] Fill in 1 to indicate the maximum value of the above expression.

 

In the [Output] section, fill in 0 in [Output Form], which means the minimum width of the progress bar drawn on the map, and [To] fill in 200, which means the maximum width of the progress bar on the map.

 

 

 

At this point, the foreground color of the progress bar is set, click the button above to return to the [Layer Style] panel, and start to set the background color of the progress bar.

 

Select [Mark] -> [Ellipse Mark], click the [Create Symbol Layer Copy] button on the right to copy the symbol.

 

Select the [ellipse mark] you just copied, fill in the [Symbol Width] with 200, click [Reload by Data Definition] on the right , and select [Deactivate] in the pop-up menu to make the expression no longer related to the value of the symbol width Joint.

 

 

Set the background color to dark gray.

 

 

Finally, set the Temporal property of the layer to "Redraw Layer Only".

 

 

Click the button in the Temporal Controller panel to play the animation and check the effect.

 

 

As you can see, as the animation plays, the progress bar slider and time label also change according to the current progress.

 

 03 Summary

 

This is the end of the actual operation process of seismic data animation effects.

 

Compared with the Time Manager that has been in use for 10 years, as a new time plug-in, Temporal Controller still has some shortcomings, such as support for time field types, low efficiency in refreshing large amounts of data, and lack of default time labels. I believe that in subsequent versions, the development team will gradually make corresponding improvements and upgrades to Temporal Controller, let us wait and see.

 

Wu Jianling

August 31, 2020


 

Copyright Notice

 

This article welcomes reprinting, please indicate the source when reprinting.

 

This article is compiled with reference to Nyall Dawson's video. Nyall Dawson is a member of the QGIS development team and has 10 years of experience in QGIS development. His live broadcast is clearly organized and innovative. Interested friends can watch related videos at the address:

https://www.youtube.com/watch?v=vgDg5cRwPRw。

 

 

 

Guess you like

Origin blog.csdn.net/QGISClass/article/details/108403845