0

i have three stations named as A, B, C. I want to plot them on a map using matplotlib basemap.

station A: latitude=17.8 longitude=74.48
station B: latitude=-25.02 longitude=25.60
station C: latitude=44.58 longitude=-123.30

As i am new to python and that to matplotlib, i am confused how should i plot it.

i tried the code:

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap

plt.figure(figsize=(8, 8))
m = Basemap(projection='ortho', resolution=None, lat_0=50, lon_0=-100)
m.bluemarble(scale=0.5);

But it doesnot plot any of my stations.so i hope experts may help me.Thanks in advance.

manas
  • 479
  • 2
  • 14
  • Of course since there's no command in your code to plot the stations. You only plot the "raw" map without any additional objects. Have you tried to use [PyGMT](https://www.pygmt.org/latest/tutorials/plot.html) for plotting your stations? It's quite easy to do what you want. – mgrund Nov 18 '21 at 15:37
  • noygmr @mgrund can you please suggest a code for the same baed on pygmt – manas Nov 19 '21 at 11:12

1 Answers1

1

Here's an example based on your data with which you might play around:

import pygmt
import pandas as pd

# create df with station information
data = {'lon':[74.48, 25.60, -123.30],
        'lat':[17.8, -25.02, 44.58],
        'station':['A', 'B', 'C']}

df = pd.DataFrame(data)

fig = pygmt.Figure()
pygmt.config(MAP_GRID_PEN = '0.25p,gray')

fig.grdimage("@earth_day_10m", region="g", projection="G130/50/12c", frame="g")
fig.plot(x = df.lon, y = df.lat, style = "t1c", color = "red3", pen = "1p,white")
fig.show()

The tutorials in the User Guide and the gallery examples are a good starting point when working with PyGMT the first time!

enter image description here

mgrund
  • 1,415
  • 8
  • 10
  • sir, Why another station is not visible? does it require to extend lat lon, i need to display all the station in global map with inverted triangles – manas Nov 20 '21 at 04:56
  • Look at your coordinates. Using an orthographic projection (like you selected in your example code) does not allow to show all three locations together, simply because of the spherical shape of Earth. E.g. try ``projection="Cyl_stere/30/-20/12c"`` and you will see all three locations, however, based on another map projection. Inverted triangles can be generated using ``style = "i1c"`` – mgrund Nov 22 '21 at 10:25