📄 mapug.html
字号:
spherical 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> <pre><a name="p5.3">m_contour(LONG,LAT,VALUES)<br>m_contourf(LONG,LAT,VALUES)<br></a></pre> <a name="p5.3">Again, these functions will return handles to graphicsobjects, allowing (for example) the drawing of labelled contours: </a> <pre><a name="p5.3">[cs,h]=m_contour(LONG,LAT,VALUES)<br>clabel(cs,h,'fontsize',6);<br></a></pre> <p> <a name="p5.3">Fancy arrows (i.e. with width, head shape, andcolour specifications) can be generated using <code> m_vec.m </code>.See the on-line help for more details about the use of <code>m_vec</code>. </a></p> <p> You can also get hatched areas by calling <code>m_hatch</code>: </p> <pre> m_hatch('single',LONG,LAT,...hatch properties) % Interior Single Hatches. <br> m_hatch('cross',LONG,LAT,...hatch properties) % Interior Crossed Hatches. <br></pre>Note that this call does not generate the edge lines (an additional <code>m_line</code>is required for this. In addition, we can speckle the inside edges ofpatches using: <pre> <br> m_hatch('speckle',LONG,LAT,...speckle properties) % Speckled edges.<br></pre>See the on-line help and/or <a href="../map.html#12._Speckle">Example13</a> for more details about using <code>m_hatch</code>. <center><a name="p5.3"> <img src="./extspeckle.gif"> </a></center> <h3><li><a name="p5.2new"></a>Drawing images and p_color </li> </h3> <p><a name="p5.4"></a><tt>m_pcolor</tt> is a drop-in replacement for <tt>p_color,</tt> but you must be careful with its use near map boundaries. Ideallyone would want data to extend up to (but not across) a map boundary(i.e. polygons are clipped). However, due to the way in which matlabhandles surfaces this is not easily done. Instead - unless you areusing a simple cylindrical or conic projection - you will probably geta ragged edge for the coloured surface. <br> </p> <p>There is no <tt>m_image</tt>. the <tt>image()</tt> functionplots data in rectangular pixels only, and in general projected datawill NOT appear as rectangular pixels. If you want to display a largepixel image on your map, there are several options:<br> </p> <ol> <li>If your georeferenced image is in lat/long coordinates (i.e.each data row is along a line of constant latitude, each column a lineofequal longitude), then you can use <tt>m_pcolor</tt> with <tt>shadingflat</tt>. This is reasonably satisfactory (although it can be slow forlarge images), but you MUST remember to offset your coordinates byone-half of the pixel spacing. This is because of the differentbehaviors of <tt>p_color</tt> and <tt>image</tt> when given the samedata. </li> <ol> <li><tt>image</tt> will center the drawn (i,j) pixel onthe (i,j)th entry of the X/Y matrices. </li> <li><tt>p_color</tt> with shading flat will draw a panel betweenthe (i,j),(i+1,j),(i+1,j+1),(i,j+1) coordinates of the X/Y matriceswith a color corresponding to the data value at (i,j). Thus everythingwill appear shifted by one half a pixel spacing.</li> </ol> <p>Satellite data from mid-latitudes is sometime amenable to thissolution. See the <a href="../map.html#satellite_examples">examples ofsatellite data manipulation</a>. </p> <li> If your figure has already been placed in some projection, andif you know the exact parameters of that projection, you can probablyuse a straight image call and then overplot an M_Map map. For example,polar satellite images are often in a polar stereographic projection.In this case you should use m_ll2xy to get the screen coordinates ofthe image corners, then use those points in an image() call beforeoverplotting your data. See in particular <a href="../map.html#3._Aerial_photos"> This example </a>. <p> HINT - check to see that coastlines overplot to make surethis is working correctly. </p> </li> </ol> <h3> <a name="p5.4"><li>Drawing tracklines<br> </li> </a></h3> <a name="p5.4"> </a> <a name="p5.4">It is sometimes useful toannotate linesrepresentingthe time-varying location of a ship, aircraft, or satellite with timeand date annotations. This can be done using <code> m_track</code>. </a> <pre><a name="p5.4">m_proj('UTM','long',[-72 -68],'lat',[40 44]);<br>m_gshhs_i('color','k');<br>m_grid('box','fancy','tickdir','out');<br><br>% fake up a trackline<br>lons=[-71:.1:-67];<br>lats=60*cos((lons+115)*pi/180);<br>dates=datenum(1997,10,23,15,1:41,zeros(1,41));<br><br>m_track(lons,lats,dates,'ticks',0,'times',4,'dates',8,...<br> 'clip','off','color','r','orient','upright'); <br></a></pre> <center><a name="p5.4"> <img src="./track1.gif"> </a></center> <a name="p5.4"> <br>See the on-line help for more details about the use of <code>m_track</code>,and the different options for setting fontsize, tick spacing, dateformats, etc. </a> <p> <a name="p5.4">While fiddling with the various parameters, itisoften handy to be able to erase the plotted tracks without erasing thecoastline and grid. This can be done using </a></p> <pre><a name="p5.4">m_ungrid track<br></a></pre> <a name="p5.4">or </a> <pre><a name="p5.4">m_ungrid('track')<br></a></pre> <h3><a name="p5.4"> </a> <a name="p5.5"><li> Drawing range ringsand geodesics</li> </a></h3> <a name="p5.5">One nifty thing that is sometimes useful is theability to draw circles at a given range or ranges from a specificlocation. This can be done using <code> m_range_ring</code>, which has3 required calling parameters: LONG, LAT, RANGE, followed by any numberof (optional) line specification property/value pairs. </a><a href="../map.html#e11">Example 11</a> illustrates how to use <code>m_range_ring</code>. <p> If you want to plot circular geodesics (i.e. curves which areperpedicular tothe range rings at all ranges), <code>m_lldist</code> can find bothdistances andpoints along the geodesics between points. <a href="../map.html#e13">Example13</a> illustrates how to use <code>m_lldist</code>.<br> </p> <p>If you care about the difference between great circle andellipsoidal geodesics (a very very small proportion of users I wouldbet) then <code>m_fdist</code> (which computes the position at a givenrange/bearing from another), <code>m_idist</code> (distance andbearings between points), and <code>m_geodesic</code> (points alongthe geodesic) can be used with a variety of (user-specified) ellipses.The calling sequence for these is different than for <code>m_lldist</code>for historical reasons.<br> </p> <h3> <a name="p5.1"><li> Converting longitude/latitude toprojectioncoordinates </li> </a></h3> <a name="p5.1">If you want to use projection coordinates (perhapsyouwant to compute map areas, or distances, or you want to make a legendin the upper left corner), the following command convertslongitude/latitude coordinates to projection coordinates. </a> <pre><a name="p5.1">[X,Y]=m_ll2xy(LONG,LAT, ...optional clipping arguments )<br></a></pre> <a name="p5.1">where LONG, LAT, X, and Y are matrices of the samesize. Projection coordinates are equal to true distances near thecenter of the map, and are expressed as fractions of an earth radius.To get a distance, multiply by the radius of the earth (about 6370km).The exception is the UTM projection which provides coordinates ofnorthing and easting in meters. </a> <p> <a name="p5.1">The possible clipping arguments are </a></p> <h4><a name="p5.1"> <code> 'clip','on' </code> </a></h4> <a name="p5.1">This is the default. Columns of LONG and LAT areassumed to form lines, and these are clipped to the map limits. Thefirstpoint outside the map is therefore moved to the map edge, and all otherpoints are converted the NaN. </a> <h4><a name="p5.1"> <code> 'clip','off' </code> </a></h4> <a name="p5.1">No clipping is performed. This is sometimes usefulfordebugging purposes. </a> <h4><a name="p5.1"> <code> 'clip','point' </code> </a></h4> <a name="p5.1">Points are tested against the map limits. Thoseoutside the limits are converted to NaN, those inside are converted toprojection coordinates. No points are moved. This option is useful forpoint data(such as station locations). </a> <h4><a name="p5.1"> <code> 'clip','patch' </code> </a></h4> <a name="p5.1">Points are tested against the map limits. Thoseoutside the limits changed into a point exactly on the limits. Thoseinside are converted to projection coordinates. This option may beuseful when trying to draw patches, however it probably won't workwell. </a> <h3><a name="p5.1"> </a><a name="p5.2"><li> Converting projectioncoordinates to longitude/latitude </li> </a></h3> <a name="p5.2">Conversion from projection coordinates tolongitude/latitude is straightforward: </a> <pre><a name="p5.2">[LONG,LAT]=m_xy2ll(X,Y)<br></a></pre> <a name="p5.2">There are no options. </a> <h3><a name="p5.2"> </a><a name="p5.6"><li> Computing distancesbetween points </li> </a></h3> <a name="p5.6">Geodesic (great circle) distances on a sphericalearthcan be computed between pairs of either geographic (long/lat) or map(X/Y) coordinates using the functions <code>m_lldist</code> and <code>m_xydist</code>.For example, </a> <pre><a name="p5.6">DIST=m_lldist([20 30],[44 45])<br></a></pre> <a name="p5.6">computes the distance from 20E, 44N to 30E, 45N.Alternatively, if you want to compute the distance between two pointsselected by the mouse: </a> <pre><a name="p5.6">[X,Y]=ginput(2);<br>DIST=m_xydist(X,Y)<br></a></pre> <a name="p5.6">will return that distance. Because of theinaccuraciesimplicit in a spherical earth approximation the true geodesic distancesmay differ by 1% or so from the computed distances. </a></ol><hr><h2><a name="p5.6"> </a><a name="p6">6. More complex plots </a> </h2><p> For ideas on how to make more complex plots, see the <a href="../map.html#examples">Examples</a>. These plots are alsoincludedin the function <code>m_demo</code>. </p><hr><h2> <a name="p13">7. Removing data from a plot </a> </h2><p> </p><p> Once a given map includes several elements a certain amount offiddling is usually necessary to satisfy the natural human urge to givethe image a certain aesthetic quality. If the image includescomplicated coastlines which take a long time to draw (e.g. thosediscussed below) than clearing the figure and redrawing soon becomestedious. The <code>m_ungrid</code> command introduced above can beused to selectively remove parts of thefigure. For example: </p><pre>m_proj('lambert','long',[-160 -40],'lat',[30 80]);<br>m_coast;<br>m_range_ring(-123,49,[1e3:1e3:10e3],'color','r');<br></pre>draws range rings at 1000km increments from my office. But I amunsatisfied with this, and want to redraw using only 200km increments.I can remove the effects of <code>m_range_ring</code> and redrawusing:<pre>m_ungrid range_ring<br>m_range_ring(-123,49,[200:200:2000],'color','r');<br></pre>In general the results of <code>m_ANYTHING</code> can be deletedby calling <code>m_ungrid ANYTHING</code>.<p> <code>m_ungrid</code> can recognize and delete specific elementsby searching the <code>'tag'</code> property of all plot elements,which is set by the various different M_Map routines. </p><hr><h2> <a name="p7">8. Adding your own coastlines </a> </h2><p> If you are interested in a particular area and want ahigher-resolution coastline than that used by <code>m_coast</code>,the best procedure is to </p><ol> <li> Get a subset of points from some high-resolution database, and </li> <li> convert to screen coordinates using <code>m_ll2xy</code>, andplot. </li></ol>One place where high-resolution coastline data can be obtained is <a href="http://rimmer.ngdc.noaa.gov/mgg/coast/getcoast.html"> TheCoastlineExtractor</a>. Follow the instructions there to get coastline data ina matlab-readable file, and download to your computer. If the file issaved as "coast.dat", you can plot it (as lines) using the following:<pre>load coast.dat<br>m_line(coast(:,1),coast(:,2));<br></pre>Filled coastlines will require more work. You should first read theinstructions there on joining the coastline data into continuoussegments. If you are lucky, (i.e. no lakes or anything else), you <em>may</em>achieve success with<pre>load coast.dat<br>[X,Y]=m_ll2xy(coast(:,1),coast(:,2),'clip','patch');<br>k=[find(isnan(X(:,1)))];<br>for i=1:length(k)-1,<br> x=coast([k(i)+1:(k(i+1)-1) k(i)+1],1);<br> y=coast([k(i)+1:(k(i+1)-1) k(i)+1],2);<br> patch(x,y,'r');<br>end;<br></pre>If this does not work, read the comments in <code>private/mu_coast</code>,orient the curves in the desired fashion, and use <code>m_usercoast</code>to load your own data.<ol> <h3> <a name="p7.1"><li><br> </li> </a> DCW political boundaries </h3> <p> Files containing political boundaries for various countries andUSstates can be downloaded from <a href="http://www.maproom.psu.edu/dcw">http://www.maproom.psu.edu/dcw/</a>. Select an area and choose the"downloadpoints" option (rather than "download data"). Once downloaded to yourmachineuse <code>m_plotbndry</code> to access and plot the desired boundary.Forexample, if you downloaded various US states into a subdirectory"states:, </p> <pre>m_plotbndry('states/arizona','color,'r')<br></pre>would plot arizona on the current map.</ol><hr><h2> <a name="p8">9. Adding your own topography/bathymetry </a> </h2>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -