Limiting Map Boundaries in Matlab for Scientists

  • MATLAB
  • Thread starter Frank Einstein
  • Start date
  • Tags
    Map Matlab
In summary, the conversation discusses the generation of a world map by plotting coastlat and coastlon and the desire to plot data over the map within a specific range. The question of how to limit the map to the desired area is raised, and potential solutions are suggested, including using the axesm function or the axis function. The code for the map and data is also provided.
  • #1
Frank Einstein
170
1
Hello everyone. I have generated a world map by plotting coastlat and coastlon. I have done it because I want to plot some data that I have over said map. The problem is that my data goes only from 70N to 40 S and from 45E to 125W, thanks to that, I have a figure which looks like in the adjoint image (made with token data instead of the actual one).

Is there a way to limit the map to the colored area or do I have to manually crop it with paint?

Thanks for your answers.
mapa1.png
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
How are we to help you if you don’t show us your code?
 
  • #3
Orodruin said:
How are we to help you if you don’t show us your code?
My code is as follows:
Matlab:
    figure
    contourf(Y,X, proxy_data_1)
    hold on
    axesm mercator;
    plot(coastlon,coastlat,'k','LineWidth',2)
<Moderator's note: code tags added. Please use them.>

While X and Y are defined as: [X,Y] = meshgrid(70:-0.25:-40,-125:0.25:45);

Proxy data is a matrix of size X*Y.
 
Last edited by a moderator:
  • #4
Did you look up the help for the axesm function?
 
  • Like
Likes Frank Einstein
  • #5
I am afraid it doesn't work since i am workng with plot instead of plotm; however, you gave me an idea, I have tried to use axis instead of axesm and it does the job. Thank you very much.
 

Related to Limiting Map Boundaries in Matlab for Scientists

1. How do I crop a map in Matlab using coordinates?

In order to crop a map in Matlab using coordinates, you can use the "xlim" and "ylim" functions. These functions allow you to specify the desired range of coordinates for the cropped map. For example, if you want to crop a map to only show the area between x=0 and x=10 and y=0 and y=8, you would use the following code:
xlim([0 10])
ylim([0 8])

2. Can I crop a map in Matlab without losing the resolution?

Yes, it is possible to crop a map in Matlab without losing resolution. This can be achieved by using the "imcrop" function. This function allows you to specify the desired size and position of the cropped map, while maintaining the original resolution. Additionally, you can also use the "imresize" function to resize the cropped map to the original size if needed.

3. How can I crop a map in Matlab to only show a specific region?

To crop a map in Matlab to only show a specific region, you can use the "mapshow" function. This function allows you to specify the desired latitude and longitude coordinates for the region you want to show. Additionally, you can use the "xlim" and "ylim" functions to further refine the cropped area.

4. Is it possible to crop a map in Matlab and save the cropped image?

Yes, you can save the cropped map image in Matlab by using the "saveas" function. This function allows you to specify the file format (such as png or jpg) and the desired file name for the cropped image. You can also use the "imwrite" function to save the image in a specific format.

5. Can I crop a map in Matlab based on a specific data range?

Yes, you can crop a map in Matlab based on a specific data range by using the "logical indexing" technique. This involves creating a logical matrix based on the desired data range, and then using this matrix to select the corresponding data points in the map. You can then use the "mapshow" function to display the cropped map using the selected data points.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Introductory Physics Homework Help
Replies
14
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
945
Back
Top