📄 mapug.html
字号:
subplot(122);<br>m_coord('geographic'); % Define all in geographic<br>m_proj('stereographic');<br>m_coast;<br>m_grid;<br>m_line(lon,lat,'color','c');<br>m_coord('IGRF2000-geomagnetic'); % Now assume that values are ingeomagnetic<br>m_line(lon,lat,'color','r');</code><br> <br> <br> </a></p> <a name="p2.7"> </a> <p><a name="p2.7"> </a><a name="p2.6">Note that this option is notused very much, hence is not fully supported. In particular, filledcoastlines may not work properly. </a></p></ol><a name="p2.7"> </a><hr><a name="p2.7"><br><br></a><h2> <a name="p3"> 3. Coastlines and Bathymetry </a> </h2><p> M_Map includes two fairly simple databases for coastlines andglobal elevation data. Highly-detailed databases are not included inthis release because they are a) extremely large and b) extremelytime-consuming toprocess (loops are inherently involved). If more detailed maps arerequired,<a href="#p9"> section 9 </a> and <a href="#p9.5"> section 10 </a>give instructions on how to add some freely-available high-resolutiondatasets. Read <a href="#p7"> section 7 </a> and <a href="#p8">section 8 </a> if you want to add your own coastline/bathymetry data. </p><ol> <h2> <a name="p3.1"> <li> Coastline options </li> </a> </h2> <p> M_Map includes a 1/4 degree resolution coastline database. Thisis suitable for maps covering large portions of the globe, but isnoticeably coarse for many large-scale applications. Users notsatisfied with their regional map are directed to <a href="#p7">section 7 </a> and/or <a href="#p9.5"> section 10 </a> for moreinformation on creating and using high-resolution coastlines. The M_Mapdatabase is accessed using the <code> m_coast </code> function.Coastlines can be drawn as simple lines,using </p> <pre>m_coast('line', ...optional line arguments );<br></pre>or <pre>m_coast( optional line arguments );<br></pre>where the optional arguments are all the standard arguments forspecifying line style, width, color, etc. Coastlines can also be drawnas filledpatches using <pre>m_coast('patch', ...optional patch arguments );<br></pre>where the optional trailing arguments are the standard patchproperties. For example, <pre>m_coast('patch',[.7 .7 .7],'edgecolor','g');<br></pre>draws gray land, outlined in green. When patches are being drawn, lakesand inland seas are given the axes background colour. <p> Many older (ocean) maps are created with speckled landboundaries, which looksvery nice in black and white. You can get a speckled boundary with </p> <pre>m_coast('speckle', ....optional m_hatch arguments);<br></pre>which calls <code>m_hatch</code>. This only looks nice if there aren'ttoo manyvery tiny islands and/or lakes in the image (see <a href="../map.html#12._Speckle">Example 13</a>). <p> Note that line coastlines are usually drawn rather rapidly.Filledcoastlines take considerably more time to generate (because map limitsarenot necessarily rectangular, clipping must be accomplished in m-files). </p> <h2> <a name="p3.2"> <li> Topography/Bathymetry options </li> </a> </h2> <p> M_Map can access a 1-degree resolution global elevation database(actually, this database is is included in the Matlab distribution,used by of <code>$MATLAB/toolbox/matlab/demos/earthmap.m</code>). Acontour map of elevations at default levels can be drawn using </p> <pre>m_elev;<br></pre>Different levels can also be specified: <pre>m_elev('contour',LEVELS, optional contour arguments);<br></pre>For example, if you want all the contours to be dark blue, use: <pre>m_elev('contour',LEVELS,'edgecolor','b');<br></pre>Filled contours are also possible: <pre>m_elev('contourf',LEVELS, optional contourf arguments);<br></pre>Finally, if you want to simply extract the elevation data for your ownpurposes, <pre>[Z,LONG,LAT]=m_elev([LONG_MIN LONG_MAX LAT_MIN LAT_MAX]);<br></pre>returns rectangular matrices for depths Z at locations LONG,LAT.</ol><hr><h2> <a name="p4"> 4. Customizing axes </a> </h2><p> </p><ol> <h3> <a name="p4.1"><li> Grid lines and labels </li> </a></h3> <a name="p4.1">In order to get the perfect grid, you may want toexperiment with different grid options. Two functions are useful here,M_GRID which draws a grid, and M_UNGRID which erases the current grid(butleaves all coastlines and user-specified data alone). Try </a> <pre><a name="p4.1">m_proj('Lambert');<br>m_coast;<br>m_grid;<br></a></pre> <a name="p4.1">to get a Lambert conic projection of North America.Now try </a> <pre><a name="p4.1">m_ungrid<br></a></pre> <a name="p4.1">The coastline is still there, but the grid hasdisappeared and the axes shows raw X/Y projection coordinates. Now, trythis: </a> <pre><a name="p4.1">m_grid('xtick',10,'tickdir','out','yaxislocation','right','fontsize',7);<br></a></pre> <a name="p4.1">The various options that can be changed are: </a> <h4><a name="p4.1"> <code> 'box',( 'on' | 'off' | 'fancy' ) </code> </a></h4> <a name="p4.1">This specifies whether or not an outline box is drawn.Three types of outline boxes are available: <code>'on'</code>, thedefault, is a a simple line. Two types of fancy outline boxes areavailable. If <code>'tickdir'</code> is <code>'in'</code>, thenalternating black and white patches are made (see </a><a href="../map.html#e2">example 2</a>). If <code>'tickdir'</code> isset to <code>'out'</code>, then a more complex line pattern is drawn(see <a href="../map.html#e6">example 6</a>). Fancy boxes are ingeneral only available for maps bounded by lat/long limits (i.e. notfor azimuthal projections), but if this option is choseninappropriately a warning message is issued. <h4> <code> 'xtick',( num | [value1 value2 ...])</code> </h4>This specifies the number/location of the longitude grid. If a singlenumber is specified, grid lines/values are drawn for approximately thatnumber of equally-spaced locations (the number is only approximatebecause the M_GRID attempts to find "nice" intervals, i.e. it rounds toeven increments). Exact locations can be specified by using a vector oflocation values. There is an analagous <code> 'ytick' </code>property. <h4> <code> 'xticklabels',[label1;label2 ...]</code> </h4>Special labels can be specified. Labels can either be numerical values(which are then formatted by M_GRID), or string values which are usedwithout change. There is an analagous <code> 'yticklabels' </code>property <h4> <code> 'xlabeldir', ( 'middle' | 'end' )</code> </h4>Longitude labels are either middled onto the ends of their prespectivegrid lines (and drawn perpendicular to those lines), or are drawnextending outwards fro the ends of those lines. There is an analagous <code>'ylabeldir' </code> property. <h4> <code> 'ticklen',value</code> </h4>Specifies the length of tickmarks (as a fraction of plot width) <h4> <code> 'tickdir',( 'in' | 'out' )</code> </h4>Specifies whether tickmarks point inwards or outwards. If <code>'box'</code>is set to <code>'fancy'</code>, this specifies the form of the fancyoutline box. <h4> <code> 'color',colorspec <br>'linewidth', value <br>'linestyle', ( linespec | 'none' ) <br>'fontsize',value <br>'fontname',name</code> </h4>Specify various line/text properties for the grid and its labels. <h4> <code> 'XaxisLocation',( 'bottom' | 'middle' | 'top' ) </code></h4>Specifies where the X-axis will be drawn, either at the bottom(southermost) end, at the top (northernmost) end, or in the middle. <h4> <code> 'YaxisLocation',( 'left' | 'middle' | 'right' ) </code> </h4>Specifies where the Y-axis will be drawn, either at the left(westernmostmost) end, at the right (easternmost) end, or in themiddle. <h3> <a name="p4.2"><li> Titles and x/ylabels </li> </a></h3> <a name="p4.2">Titles and x/ylabels can be added to maps using the <code>title</code>and <code>x/ylabel</code> functions in the usualway (this is a change from v1.0 in which the 'visible' property had tobeexplicitly set to 'on'; this is now done within m_grid). </a> <h3><a name="p4.2"> </a><a name="p4.3"><li> Legend Boxes </li> </a></h3> <a name="p4.3">A legend box can be added to the map using <code>m_legend</code>.Only some of the functionality of <code>legend</code> is currentlyincluded. The legend box can be dragged and dropped using the mousebutton. </a></ol><hr><h2><a name="p4.3"> </a><a name="p5">5. Adding your own data </a> </h2><p> The purpose of this package is to allow you to map your own data!Once a suitable grid and (possibly) a coastline have been chosen, youcan add your own lines, text, or contour plots using built-in M_Mapdrawing functions which handle the conversion from longitude/latitudecoordinates to projection coordinates. These drawing functions are verysimilar to the standard Matlab plotting functions, and are described inthe <a href="#p5.3">next section</a>. </p><p> Sometimes you may want to convert between longitude/latitude andprojection coordinates without immediately plotting the data. Thismight happen if you want to interactively select points using <code>ginput</code>,or if you want to draw labels tied to a specific point on the screenrather than a particular longitude/latitude. Projection conversionroutines are described in sections <a href="#p5.1">5.2</a> and <a href="#p5.2">5.3</a>. Once raw longitude/latitude coordinates areconverted into projection coordinates, standard Matlab plottingfunctions can be used. </p><p> Maps are drawn to fit within the boundaries of the plot axes. Thustheir scale is somewhat arbitrary. If you are interested in making amap toa given scale, e.g. 1:200000 or something like that, you can do so byusing the <code>m_scale</code> primitive, see <a href="#p2.6">section 2.6</a>. The data units are the projection coordinates, which aredistancesexpressed as a fraction of earth radii. To get a map "distance" betweentwo points, use the Cartesian distance between the points in theprojectioncoordinate system and multiply by your favourite value for the earth'sradius, usually around 6370 km (exception - the UTM projection usescoordinatesof northing and easting in meters, so no conversion is necessary). </p><p> Caution: One problem that sometimes occurs is that data does notappear on the plot due to ambiguities in longitude values. For example,if plot longitude limits are [-180 180], a point with a longitude of,say, 200,may not appear in cylindrical and conic projections. This is not a bug.Handling the clipping in "wrapped around" curves requires adding points(rather than just moving them) and is therefore incompatible withvariousother requirements (such as keeping input and output matrices the samesizein the conversion routines described below). </p><ol> <h3> <a name="p5.3"><li> Drawing lines, text, arrows, patches,hatches, speckles andcontours </li> </a></h3> <a name="p5.3">For most purposes you do not need to know what theprojection coordinates actually are - you just want to plot somethingat a specified longitude/latitude. Most of the time you when you wantto plot something on a map you want to do so by specifyinglongitude/latitude coordinates, instead of the usual X/Y locations. Todo so in M_Map, replace calls to <code> plot, line, text, quiver,patch, contour, and contourf </code> with M_Map equivalents thatrecognize lontgitude/latitude coordinates by prepending "m_" to thefunction name. For example, </a> <pre><a name="p5.3"><br> m_plot(LONG,LAT,...line properties) % draw a line on a map (erase current plot) <br> m_line(LONG,LAT,...line properties) % draw a line on a map <br> m_quiver(LONG,LAT,U,V,S) % A quiver plot <br> m_text(LONG,LAT,'string') % Text <br> m_patch(LONG,LAT,..patch properties) % Patches. <br> </a></pre> <a name="p5.3">Each of these functions will handle the coordinateconversion internally, and will return a vector of handles to thegraphic objects if desired. The only difference between these functionsand thestandard Matlab functions is that the first two arguments MUST belongitudeand latitude. </a> <p> <a name="p5.3">One caveat applies to <code>m_patch</code>. Forcompatibility reasons this uses the same code that applies to coastlinefilling. Coastlines come either as either "islands" or "lakes", andM_Map keeps track of the difference by assuming curves are oriented sothat the filled area ("land") is always on the right as we go aroundthe curve. This is slightly different than the convention used in <code>patch</code>which always fills the inside. Keeping track of this difference isrelatively straightforward in a Cartesian system, but not so easy inspherical coordinates. In the absence of other information <code>m_patch</code>tries to do the right thing, but (especially when the patch intersectsa map boundary) it can get confused. If a patch isn't fillingcorrectly, try reversing the order of points using <code>flipud</code>or <code>fliplr</code>. </a></p> <p> <a name="p5.3">Data gridded in longitude and latitude can alsobe contoured: </a></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -