Plot lat and lon grid on a world map using Matlab - matlab

Can anyone help me how to plot latitude and longitude on a world map using matlab. I have the mapping toolbox and have been trying to use the function geoshow, however I canĀ“t get it right. I plot the world map using plot_google_map:
plot(lon,lat,'.k','MarkerSize',6)
hold on
plot_google_map('maptype','roadmap')
This is the figure I get:
However I am not able to get the latitude and longitude grid on this picture.

I'm not sure is this going to help, but try reversing the order of your plot statements - its possibly that the map plot may be overwriting all the data of the lon and lat data.
Alternatively, if the function allows for it, plot the map as the back layer.

Related

Create circle around user inputted point and plot on map with custom latlon points

I have a question about if something is possible using Tableau.
I already have a coastline plotted on one map using custom LatLon coordinates and I would like to take a user inputted Lat and Lon and plot a circle around it with let's say radius 10 and display it on the same map.
I was using this tutorial before to plot a circle:
https://www.crowdanalytix.com/communityBlog/customers-within-n-miles-radius-analysis-using-tableau
But I don't think the same approach can work with user-inputted fields because then it would require restructuring the data..
Okay, a (much smarter LOL) coworker helped me figure this out....
So my goal was to graph distance band (like a distance of 5 miles around a coast) . In order to do this we can use the distance between two coastline points since they are connected by a line, not a curve...From there we can find the perpendicular point a certain distance away and connect those points. Much easier than my circle idea...

Creating a Position Grid from Latitude and Longitude Points

I have two data sets: one of latitude and one of longitude. Both of these datum are 336x264 in size.
I would like to use MATLAB to turn this data into a grid of of position points.
So basically from this:
to this:
I don't want to reinvent the wheel here if there is a standardized method of going about this so I figured I should see if the community had any pre-existing resources for this sort of task!
Thank you and best,
Taylor
If you have the mapping toolbox, you can do this with the projfwd function:
% First, create the projection struct
mstr = defaultm('mercator'); %Or whatever projection you want to use
% Then, project your points
[x,y] = projfwd(mstr,lat,lon);

Plot bilinear interpolated gridded data spatially on a map

I am using the following code to plot gridded data on a map over a region but I would like to know how to plot the interpolated data so that I get continuous data plotted over the region and the data does not look gridded. 'lat' and 'lon' are vectors (1x21 and 1x33) containing the latitude and longitude coordinates respectively.
ax = worldmap(latlim, lonlim);
S = shaperead('landareas','UseGeoCoords',true);
surfacem(lat, lon, ans');
geoshow([S.Lat], [S.Lon],'Color','black');
I am seeing a lot of documentation on using interp2 but I am not getting mine to work even when I try to create a meshgrid using lat and lon (cannot attach the data). I do the following with interp2:
LON,LAT] = meshgrid(unique(lon),unique(lat));
interp2(lon, lat, testdata', LON, LAT);
That gives me a result but I then want to plot it over a region without it looking gridded. testdata is a 33x21 matrix. Any ideas? I have seen some examples here on interpolation but I am not sure how to apply it conveniently with the data I have. I am surprised that there is not more information on this or why I am just sucking at finding the answer!
Thanks,

How to change longitude label locations in matlab worldmap

I am trying to generate some contour plots using data in netCDF format in Matlab. I've managed to load in the data and retrieve latitude, longitude information, but got bit stuck in making the plot looks right. The thing I want to change is the locations of the longitude labels. Now they are labelled along the equator (see Fig below), making them difficult to read. I want to move them to the bottom of the plot. Please give me some clue how to control this.
Here is the block of code that I am developing that creates the plot:
latax=-89:1:89;
lonax=0:1:360;
figure
axesm('braun','MLabelParallel',-60);
worldmap([latax(1),latax(end)],[lonax(1),lonax(end)]);
hold on;
load coast;
plotm(lat,long,'k-');
where latax and lonax are the latitude and longitude vectors, respectively. I thought the line axesm('braun','MLabelParallel',-60); sets the latitudinal location for the longitude labels but it didn't seem to make any difference.
The position of these labels can be controlled with the setm command (I'm using 2015a). If your worldmap axes are defined as:
ax = worldmap([latax(1),latax(end)],[lonax(1),lonax(end)]);
to put the labels at the bottom of the plot, do
setm(ax,'mlabelparallel',-90)
the 'plabelmeridian' is the equivalent property for the latitude labels.

time series plot on google earth using matlab

I have three sets of data:
time
longitude
latitude
I would like to plot this on google earth using google earth toolbox for matlab, what i need is when i move the time slider a line should be drawn on google earth.
I tried this
x = [longitude, latitude];
y = time;
kmlStr = ge_plot(x,y);
But an error occured.
On the other hand ge_gplot does not make sense for this.
Is there a way i can do this timeseries plot using google earth toolbox?
Create two vectors: one for x (longitude), one for y (latitude). ge_plot(x,y) will draw a line connecting each pair of (x,y) points in these vectors.
If you want to draw the line as a slider advances, then you need to make use of a callback function. In this function, do ge_plot(x(1:ind), y(1:ind) ) where ind is determined by the "time" value of the slider.