# Map of seismic stations using pygmt

**URL:** <https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828>\
**Category:** Showcase\
**Created:** [August 29, 2020, 11:42pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828 "2020-08-29T23:42:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joleonar](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joleonar](https://forum.generic-mapping-tools.org/u/Joleonar)\
**Post date:** [August 29, 2020, 11:42pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/1 "2020-08-29T23:42:11Z")

</div>

This the python code for plotting a map of seismic stations using PyGMT .

- Ubuntu 18.04, Python 3.7.8, GMT 6.0.0 and pygmt 0.1.2

```python
#!/usr/bin/env python3
"""
Created on Wen Aug 26 15:10:59 2020
Script python plot seismic stations
Files required:
1. ESTACIONES.txt (National stations)
2. ESTACIONES_NOFUNV.txt )(international stations)
3. etopo1_bedrock.grd (topography)
4. verde.cpt (color palette)
5. legend_estaciones.txt (legend)
6. fallas2015.txt (file with faults)
"""

import pandas as pd
import pygmt

#Seismic stations
national=pd.read_csv("ESTACIONES.txt", sep='\s+')
internat=pd.read_csv("ESTACIONES_NOFUNV.txt", sep='\s+')

#Map generation wit PYGMT
KWARGS = dict(grid='etopo1_bedrock.grd', region=[-76,-59,5,15], projection='M10i', 
                      cmap='verde.cpt', frame=0)

fig = pygmt.Figure()

#plot topography
fig.grdimage(shading=True, **KWARGS) # Add illumination!

#plot map (pscoast)
fig.coast(shorelines=True, borders=['1/0.8p','2/0.1p'],frame=True,
              map_scale='-68.0/7.0/7.0/200 ', resolution='f')
 
#Plot seismic faults
fig.plot(data="fallas2015.txt",pen="1,red")

#stations
fig.plot(x=national.Lon, y=national.Lat,style="t0.8c",color='yellow',
        pen="black") 

fig.text(textfiles=None,x=national.Lon-0.1, y=national.Lat+0.3, position=None,text=national.COD,  
 angle=0, font='10p,Helvetica-Bold,black', justify='LM')

fig.plot(x=internat.Lon,y=internat.Lat,style="t0.8c",color='green', pen="black")

fig.text(textfiles=None,x=internat.Lon-0.1, y=internat.Lat+0.3, position=None,text=internat.COD,
angle=0, font='10p,Helvetica-Bold,black', justify='LM')

#text 
fig.text(x=-68.0, y=13.5,position=None,text='Caribbean Sea', angle=0,
        font='28p,Helvetica-Bold,white', justify='LM')

#Legend
fig.legend(spec='estaciones_legend.txt', position='JTL+jTL+o0.5c+w6.3/3.2',
       box='+glavender+p2p+r')
 
fig.savefig('stations_map.png')

```

> ![stations_map(1)](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/e2bd90c8a9814bbb4ef34e26deebe6b365f1397b.png)

---

<div class="post-metadata">

**Author:** ![seismiclover](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@seismiclover](https://forum.generic-mapping-tools.org/u/seismiclover)\
**Post date:** [January 31, 2021, 2:19pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/2 "2021-01-31T14:19:37Z")

</div>

Hi, can you share estaciones\_legend.txt, because i just want to make like this legend.

---

<div class="post-metadata">

**Author:** ![Joleonar](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joleonar](https://forum.generic-mapping-tools.org/u/Joleonar)\
**Post date:** [February 1, 2021, 12:04pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/3 "2021-02-01T12:04:59Z")

</div>

H 12 1 Estaciones sismológicas  
D 0.2c 1p  
G 0.15c  
S 0.25c t 0.5c yellow thin 1.0c Nacionales  
G 0.1c  
S 0.25c t 0.5c green thin 1.0c Internacionales  
G 0.1c  
S 0.25c - 15p - 2.0p,red 1.0c Fallas  
G 0.3c  
M 1 1 200+u

---

<div class="post-metadata">

**Author:** ![Joleonar](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joleonar](https://forum.generic-mapping-tools.org/u/Joleonar)\
**Post date:** [February 1, 2021, 12:06pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/4 "2021-02-01T12:06:05Z")

</div>

This the file estaciones\_legend.txt

---

<div class="post-metadata">

**Author:** ![rendezvousjane](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rendezvousjane/32/1128_2.png) [@rendezvousjane](https://forum.generic-mapping-tools.org/u/rendezvousjane)\
**Post date:** [April 1, 2021, 7:26am UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/6 "2021-04-01T07:26:05Z")

</div>

Hi, can you share all the ingredient files in making this plot? A google drive link?

---

<div class="post-metadata">

**Author:** ![Joleonar](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joleonar](https://forum.generic-mapping-tools.org/u/Joleonar)\
**Post date:** [April 8, 2021, 3:17pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/7 "2021-04-08T15:17:31Z")

</div>

The files required and the code are located in [https://github.com/joleonar/stations\_map](https://github.com/joleonar/stations_map).

Regards.

---

<div class="post-metadata">

**Author:** ![Biruk](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/biruk/32/2163_2.png) [@Biruk](https://forum.generic-mapping-tools.org/u/Biruk)\
**Post date:** [April 10, 2022, 6:30am UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/8 "2022-04-10T06:30:12Z")

</div>

Thank you for sharing your code.  
Can you explain how you prepare your fault file (“fallas2015.txt”)?

---

<div class="post-metadata">

**Author:** ![Joleonar](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joleonar](https://forum.generic-mapping-tools.org/u/Joleonar)\
**Post date:** [April 10, 2022, 3:30pm UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/9 "2022-04-10T15:30:48Z")

</div>

Hello Biruk

As you can see “fallas2015.txt” is a text file where the lines that represent the faults are two columns (lon, lat) separated by “\>” symbol.

This file was prepared by digitizing the map with the faults to generate a shape file (I don’t digitized the map but I think Arcgis or Qgis was used). Then they gave me a shape file (.shp) and I used Qgis to convert the shape file to text file (fallas2005.txt).

Also Python has libraries to convert shape files to text file one of this is **geopandas**.

I hope this information is useful for you

---

<div class="post-metadata">

**Author:** ![Biruk](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/biruk/32/2163_2.png) [@Biruk](https://forum.generic-mapping-tools.org/u/Biruk)\
**Post date:** [April 11, 2022, 6:38am UTC](https://forum.generic-mapping-tools.org/t/map-of-seismic-stations-using-pygmt/828/10 "2022-04-11T06:38:03Z")

</div>

Hi Joleonar,

Thank you for your fast response.  
Great work!!!
