# Brazilian polyline GMS map for Echoes project

**URL:** <https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177>\
**Category:** PyGMT Q&A\
**Created:** [August 28, 2025, 2:39pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177 "2025-08-28T14:39:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucasacreis](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/lucasacreis/32/5000_2.png) [@lucasacreis](https://forum.generic-mapping-tools.org/u/lucasacreis)\
**Post date:** [August 28, 2025, 2:39pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/1 "2025-08-28T14:39:11Z")

</div>

Indra and Startical Echoes project needed a Brazilian map to show their test software working in Brazilian coast area.  
Looking the tutorials and chating with copilot I made this small project. Maybe it could be good for someone else.

**Creating polyline GMS file for Brazilian borders**

# Download and Install

[https://github.com/GenericMappingTools/gmt/releases/latest](https://github.com/GenericMappingTools/gmt/releases/latest)

**Download packages**  
DCM - [https://github.com/GenericMappingTools/dcw-gmt/releases/latest](https://github.com/GenericMappingTools/dcw-gmt/releases/latest)  
GSHHG - [https://github.com/GenericMappingTools/gshhg-gmt/releases/latest](https://github.com/GenericMappingTools/gshhg-gmt/releases/latest)

**Brazilian Coast**  
gmt pscoast -R-74/-28/-34/6 -Df -A1000 -W -M \> costa\_raw.txt

**Brazilian Border**  
gmt pscoast -R-74/-28/-34/6 -Df -N1 -M \> fronteira\_raw.txt

- ´-R´: Defines Brazil(R)
- ´-74/-28/-34/6´: Defines geographic region boundries = West(-74)/East(-28)/South(-34)/North(6)
- ´-Df´: Full resolution
- ´-A1000´: Ignore islands smaller than 1000 km²
- ´-W´: Draw coast lines
- ´-M´: Exports as polylines

**Join data**  
Just copy the values and paste in a unique file.  
Exemple: brasil\_complete.map

**Check the data**  
Run a python script with matplotlib.

```auto
import matplotlib.pyplot as plt

def gms_to_decimal(gms):
    direction = gms[-1]
    gms = gms[:-1]

    if len(gms) == 6: # Latitude
        degrees = int(gms[:2])
        minutes = int(gms[2:4])
        seconds = int(gms[4:6])
    else: # Longitude
        degrees = int(gms[:3])
        minutes = int(gms[3:5])
        seconds = int(gms[5:7])

    decimal = degrees + minutes / 60 + seconds / 3600
    if direction in ['S', 'W']:
        decimal *= -1
    return decimal

def ler_polilinhas(arquivo):
    polilinhas = []
    cor = (0, 0, 0) # Cor padrão

    with open(arquivo, 'r') as f:
        linhas = f.readlines()

    i = 0
    while i < len(linhas):
        linha = linhas[i].strip()

        if linha.startswith("ColorLinea"):
            partes = linha.split()
            cor = tuple(int(p)/255 for p in partes[1:4])

        elif linha.startswith("Polilinea"):
            qtd = int(linha.split()[-1])
            coords = []
            for j in range(i+1, i+1+qtd):
                lat_gms, lon_gms = linhas[j].strip().split()
                lat = gms_to_decimal(lat_gms)
                lon = gms_to_decimal(lon_gms)
                coords.append((lon, lat))
            polilinhas.append((coords, cor))
            i += qtd # pula as coordenadas lidas

        i += 1

    return polilinhas

print('Iniciando')

polilinhas = ler_polilinhas('brasil_complete.map')

plt.figure(figsize=(8, 6))
for coords, cor in polilinhas:
    x, y = zip(*coords)
    plt.plot(x, y, color=cor, linewidth=2)

plt.title("Costas e Fronteiras do Brasil")
plt.xlabel("Longitude")
plt.ylabel("Latitude")
plt.grid(True)
plt.axis("equal")
plt.show()

```

 ![brazil_map](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/cf6059fc9c43bce870b642e1dc684e0b0f4cad3e.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [August 28, 2025, 3:16pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/2 "2025-08-28T15:16:40Z")

</div>

But this is a poor quality figure as compared to what you’d obtained if you had used GMT to do the plot!

---

<div class="post-metadata">

**Author:** ![lucasacreis](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/lucasacreis/32/5000_2.png) [@lucasacreis](https://forum.generic-mapping-tools.org/u/lucasacreis)\
**Post date:** [August 28, 2025, 5:46pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/3 "2025-08-28T17:46:30Z")

</div>

Yes, Joaquim, this is enough for the application. The goal is to visualize the countour of the country for satellite tracking purposes.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [August 28, 2025, 5:55pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/4 "2025-08-28T17:55:34Z")

</div>

OK Lucas, sem problemas, but it’s just that this is a showcase for GMT figures and yours is … matplotlib. You could, if you feel like so, improve it by replacing the plot part by a nicely projected GMT figure. Others are certainly willing to help in case you need it (not me, I’m not a Py user).

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [August 29, 2025, 7:35pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/5 "2025-08-29T19:35:13Z")

</div>

As long as I am concerned: this topic is far away from the Showcase quality level. It is a beginner Q&A level topic: it sets a simple question and provides some sort of below average-looking though definitely working answer. It can simply be moved to Q&A.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [August 30, 2025, 2:31pm UTC](https://forum.generic-mapping-tools.org/t/brazilian-polyline-gms-map-for-echoes-project/6177/6 "2025-08-30T14:31:18Z")

</div>

Lucas, I’m afraid I agree with @mkononets and so moved your post to Q&A(PyGMT)
