I’m plotting a map of great circle ray paths from set of co-ordinates to another set, so initially I’m assigning a region to the grid. In the final output I need the same result but just for subset of the region/cropping the map to a new region within the grid. How should I approach this?
Repeat the first plot call with the new « region » (with a shift of the picture of course)?
Actually I’m unable to dow that, once after the things get plotted and I crop it to new region the great circle lines are disappearing because the cropped region I’m interested in doesn’t contain the other end of co-ordinates which form the ray paths
Hello @anirudh,
Welcome to the GMT forum !
Unfortunately, I am having difficulty understanding your issue. I feel it would helpful if you could provide a code example demonstrating your issue.
Based on your last post, it sounds a bit like setting the no_clip
parameter of Figure.plot
to True
could be helpful for you. However, no_clip
actually does not apply to lines and polygons (for GMT 6.4.0, https://docs.generic-mapping-tools.org/6.4/plot.html#n).
Maybe OP doesn’t know how to play with -Bafg
parameters in python ?
Actually I’m new to PyGMT itself and not well versed in GMT. Yeah I will provide you the example code
import numpy as np
import pygmt
import pandas as pd
fig = pygmt.Figure()
grid = pygmt.datasets.load_earth_relief(resolution="10m", region = [lat1, lon1, lat2, lon2])
fig.grdimage(grid=grid, projection="M15c", frame="a", cmap="geo")
#reading excel file
for i in range(0, len(rows)): #plotting ray paths
if df.Final[i] == 'yes':
point_1 = []
point_1.insert(0, df.Lon[i])
point_1.insert(1, df.Lat[i])
main_point = main_cord[j]
data = np.array([point_1 + main_point])
fig.plot(data=data, style="=1c+a+s", pen="1p,red", fill="red3")
fig.show()
Like this is the code format so after the ray paths are plotted I need canvas to show me only the desired region extent which is
region2 = [lat’1, lon’1, lat’2, lon’2]
But,
- I’m unable to specify the fig to the region2 at end of the code - Its just overlaying new grid on the original region.
- If I specify region2 directly in the beginning of the code, ray path vectors are not plotted as the other set of co-ordinates exist outside region2
@anirudh thanks providing an code example!
Can you please try option 2 together with setting the no_clip
parameter to True
in fig.plot
:
fig.plot(data=data, style="=1c+a+s", pen="1p,red", fill="red3", no_clip=True)
If this dose not fix your issue we also need your input data (i.e., what is read into the pandas DataFrame df
) to have a more detailed look at your problem.
One comment regarding your study area set via the region
parameter: You have to give it in the order lon1, lon2, lat1, lat2
.
Thank you very much, no_clip=True
worked