Plotting Right Ascension & Declination on Mercator Map

7 views (last 30 days)
I'm developing a program to do many different satellite orbit calculations. One of them involves plotting the ground tracks of a given satellite on a mercator (lat & long) map. I have the Right Ascension and Declination angles in a vector called "rad" in the following code. With Right Ascension in the first column, and declination in the second column. The plot is coming out okay, except that it is connecting the groundtrack line when the right ascension (width) resets from 360 to 0. I can't quite figure out how to plot the data without connecting the line when the right ascension resets to 0 degrees from 360.
rad(:,1) ranges from 0 to 360 (right ascension) rad(:,2) ranges from -90 to 90 (declination)
earth = imread('ImageOfEARTH');
hold on
F = earth(end:-1:1,:,:);
image([0 360],[-90 90],F)
plot(rad(:,1),rad(:,2),'red');
axis([0,360,-90,90])
daspect([1 1 1]);
This code outputs the following plot:
See how that line is connected through the middle? I need to eliminate that.
Thanks!
-Brandon

Accepted Answer

Star Strider
Star Strider on 30 Nov 2015
I don’t have ‘ImageOfEARTH’ so I can’t run your code. However, one way to deal with the ‘wrap-around’ problem is to add NaN at the end of each of your vectors. Those will ‘break’ the continuity of your plot, since NaN does not plot, and your line plot should no longer wrap.
  5 Comments
Brandon Johnson
Brandon Johnson on 30 Nov 2015
Beautiful, now I get this plot. But the problem is that now if I try to plot multiple periods of the satellite (multiple times around) I will have many discontinuities of this type. Is there a way to modify that code to handle multiple discontinuities?
Star Strider
Star Strider on 30 Nov 2015
First, thanks for the earth map link. The image is now in one of my MATLAB directories.
Second, it depends on how your data are stored and the lengths of the individual (Rx2) matrices for each satellite revolution. If there are N of them and if they are all the same lengths (that is 100 rows each so R=100), then you can use the reshape function to convert the long (R*Nx2) matrix into N (Rx2) matrices in the same matrix (so it would be (Rx2*N)), and then use the same code to insert a (2*N) row of NaN values in it.
Otherwise, you will have to test for the wrap-around (minimum) for each two-column section in your (Rx2) matrix. If the minima vary but are all <2, then use the find function to test for rad(:,1)<2, or whatever test is appropriate. You would likely have to use a loop to use my code with each section of the matrix. So if possible, make them all R rows long, use reshape, and avoid the complexity.
Third, if all the (Rx2) matrix segments ‘break’ at the same row, you can simplify my code a bit by using the circshift function to rotate your RxN*2 reshaped matrix so that all the vectors in your RxN*2 reshaped matrix begin at the same row. Then you simply add a 2*N row of NaN values to the end of the matrix and be done with it. That’s the easiest way. (I thought about doing it with your matrix here.) You would then use reshape again to create one long (N*(R+N)x2) matrix, now including the added NaN rows.
Also, the satellite track has to begin somewhere and the calculation end somewhere else, so some discontinuity is inevitable (unless it ends exactly over its launch site).

Sign in to comment.

More Answers (1)

Chad Greene
Chad Greene on 30 Nov 2015
As Star Strider mentioned, you can add a NaN where it wraps around. A faster and possibly less visually appealing way is to plot red dots instead of a red line:
plot(rad(:,1),rad(:,2),'r.');
A note unrelated to your question: Your map isn't actually a Mercator map. It's simply unprojected geographic coordinates where you've given all degrees longitude and latitude equal size. Mercator projections make Greenland appear larger than Africa.
  2 Comments
Brandon Johnson
Brandon Johnson on 30 Nov 2015
Yeah, I know the map isn't right. I just used it for sake of demonstration.
So you're saying I should write a routine to find the point where it wraps around (or multiple points) and then add the NaN to the third element? Or simply replace the value with NaN?
Brandon Johnson
Brandon Johnson on 30 Nov 2015
I've replaced a row with NaNs and I'm getting the same result.

Sign in to comment.

Categories

Find more on Reference Applications in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!