Wednesday, March 25, 2020

2D earthquake beachball diagrams in QGIS

Earthquake focal mechanism solution (FMS) diagrams (a.k.a. beachball diagrams) allow the quick visualization of the attitudes of the two possible fault planes (i.e. the nodal planes: the fault plane that moved, and the auxiliary plane) and the slip sense (i.e. normal, reverse, strike-slip, or oblique) associated with an earthquake event, as determined from waveform data. This article will guide you in displaying beachball diagrams in QGIS.

Some background on the concepts used for the visualization

As stated above, FMS diagrams show the two nodal planes and their associated slip senses. An important relationship between the two nodal planes is that they are perpendicular to each other. As such, we only need information on one of the nodal planes to construct the beachball diagram. Specifically, we need the attitude of the fault (strike and dip) as well as the slip sense (rake). We would also need the location (latitude and longitude) of the earthquake epicenter for plotting. The data source that we will be using for this tutorial is the Global Centroid Moment Tensor (GCMT), using the psvelomeca output option. Of course, other data sources may be used, provided they have the minimum required information (latitude, longitude, strike, dip, and rake).

To display the beachball diagrams in QGIS, we need a way to associate the correct symbology for every possible combination of strike, dip, and rake values. To do this, the following techniques are employed: 
  1. Representation of all possible strike values through the data defined override option for rotation in the symbology panel in layer properties. This is applicable since the strike value only rotates the FMS diagram.
  2. Following (1), we need to create FMS diagrams for all possible combinations of dip and rake values for a north-striking fault plane (strike = 0 degrees). Obviously, this is a lot, since dip values range from 0 to 90 degrees, and rake values from -180 to 180 degrees. For the purposes of this tutorial, I opted to create symbology for all dip and rake value combinations in 5-degree increments. In total, I have created 1,387 FMS diagrams, which you may download here.

Let's start!

Step 1: Copy the FMS svg symbology in your QGIS svg directory. Make sure to extract the content of the .rar file, which is a folder named zfocmech. If you installed QGIS using the Standard Installation option using OSGEO4W Network Installer, the svg directory would likely be located in: C:\OSGeo4W64\apps\qgis\svg. After copying, the 1,387 FMS diagrams should be located in C:\OSGeo4W64\apps\qgis\svg\zfocmech.

Figure 1. FMS diagrams in the zfocmech folder within the QGIS svg directory.

Step 2: Download your data. If you want to use GCMT data for your area, click here. Make sure to select the GMT psvelomeca input option, which gives the strike, dip, and rake values of the nodal planes. You may also opt to follow this tutorial using the same data set that I'm using.

Figure 2. The GCMT search web page.

Step 3: Prepare the data. Open the file in Excel (or other spreadsheet). We have to create a column which will reference the appropriate FMS svg symbol for each earthquake.

Figure 3. The sample data set in MS Excel.

Since our FMS diagrams are for dip and rake value combinations in 5-degree increments, we have to round up the dip and rake values into the nearest 5-degree increment. For this tutorial, I will be using the strike, dip, and rake values for nodal plane 1 (str1, dip1, r1), although using nodal plane 2 should produce similar results.

To round the dip values (dip1) to the neares 5-degree, I used the formula: 

=ROUND(dip1/5,0)*5

Similarly, for the rake values (r1), I used the formula:

=ROUND(r1/5,0)*5

Figure 4. The sample data set with new columns for the dip (Column L) and rake (Column M) values in 5-degree increments.

Create a new column containing the corresponding svg symbology, by using the CONCATENATE function. For the sample data set, I used this formula for the first earthquake, and applied it to all the events in the data set:

=CONCATENATE("C:\OSGeo4W64\apps\qgis\svg\zfocmech\",L2,"_",M2,".svg")

The result of which is the directory of the corresponding FMS svg symbology:

C:\OSGeo4W64\apps\qgis\svg\zfocmech\40_-75.svg


Figure 5. The sample data with the new column for the corresponding svg symbol (Column N).

Save the file as a tab delimited text file (.txt). Here is a sample spreadsheet of the data set with the data preparation outlined above.

Step 4: Open the file in QGIS. Go to Layer > Add Layer > Add Delimited Text Layer... or use Ctrl+Shift+T to open the file. Make sure to toggle the necessary options, such as the delimiter used (for the sample data, we are using Tab),  and the geometry (point coordinates) and the X and Y field (longitude and latitude, respectively). For the sample data, see Figure 6.

Figure 6. The Data Source Manager dialog box for opening delimited text file. 

The opened file should show the earthquakes plotted with default symbology (simple marker).

Figure 7. The sample data set rendered with simple markers. The basemap is OSM Standard WMS layer, obtained using the QuickMapServices plugin.

Step 5: Edit the symbology. In the Layers Panel, right click the data layer and select Properties. Then click the Symbology tab to open the Symbology Editor window.

Figure 8. The symbology editor.

Change the symbol layer type to SVG Marker. Scroll down until you reach the bottom of the window. We need to perform a data-defined override to assign the correct svg file (as we assigned in Step 3) for each earthquake event. Click on the Data-defined Override icon > Edit... (See Figure 9).

Figure 9. The data-defined override icon (see red arrow).

The Expression String Builder window should appear. In the central panel, double click on the field name you assigned for the svg directory (see Step 3), under the Fields and Values. The output preview, which is shown at the bottom left corner of the window, should show an example of the svg file directory. Click OK.

Figure 10. The expression string builder window.

We also need to apply a data-defined override for the symbol rotation, in order to account for the strike values (see Background). Click on the Data-defined Override icon > Assistant beside the Rotation field.


Figure 11. The rotation data-defined override


Set the source field to the field name which contains the strike values (str1 for this tutorial). Set the values to range from 0 - 360 degrees for both input and output. Click OK.

Figure 12. The rotation data-defined override assistant. 1) the field name for the strike values; 2) and 3) are the settings for the input range.


Finally, add another marker below the SVG markers we have already set up, by clicking the + button. Feel free to play with the stroke width and the fill color and transparency settings. For example, you may also use the data-defined override for the fill color to visualize depth variation among the earthquake hypocenters. 

For this tutorial, I opted for a 4 mm size for the SVG, while a 3.8 mm size, a 0.2 mm stroke width, and a solid white fill for the simple marker. Click OK.

Figure 13. The symbology editor window.

The results should look like something like this.

Figure 14. Earthquake beachball diagrams in QGIS!

Other tips

  1. Background colors that visualize depth variation of the earthquake hypocenters. This may be achieved by applying data-defined override for the color of the underlying simple marker, if you have depth data (The GCMT psmeca output includes depth values).
  2. Size that reflects the magnitude of the earthquake. This may also be achieved by applying a data-defined override for the size of the layer symbology.

Future works

I am currently working on visualizing 3D beachball diagrams in QGIS, using the qgis2threejs plugin.

4 comments:

  1. bakit yung sakin hindi beachball yung itsura po? Like white fill and black background lang po

    ReplyDelete
    Replies
    1. I would need more information for troubleshooting. You may contact me through email. Thank you.

      Delete