Main Content


Trim lines to latitude-longitude quadrangle


[lat,lon] = maptriml(lat0,lon0,latlim,lonlim)


[lat,lon] = maptriml(lat0,lon0,latlim,lonlim) returns filtered NaN-delimited vector map data sets from which all points lying outside the desired latitude and longitude limits have been discarded. These limits are specified by the two-element vectors latlim and lonlim, which have the form [south-limit north-limit] and [west-limit east-limit], respectively.


collapse all

It is not unusual for vector data to extend beyond the geographic region currently of interest. For example, you might have coastline data for the entire world, but are interested in mapping Australia only. In this and other situations, you might want to eliminate unnecessary data from the workspace and from calculations in order to save memory or to speed up processing and display. You can trim line data by simply removing points outside the region of interest by clipping lines at the map frame or to some other defined region. The maptriml function returns variables containing only those points that lie within the defined region.

Load the coastlines MAT-file. This file contains data for the entire world.

load coastlines

Define a region of interest centered on Australia.

latlim = [-50 0]; 
lonlim = [105 160];

Delete all line data outside these limits, producing line vectors, by using the maptriml function.

[linelat,linelon] = maptriml(coastlat,coastlon,latlim,lonlim);

Examine the variables to see how much data has been reduced. The clipped data is only 10% as large as the original data set.

  Name             Size            Bytes  Class     Attributes

  coastlat      9865x1             78920  double              
  coastlon      9865x1             78920  double              
  latlim           1x2                16  double              
  linelat        977x1              7816  double              
  linelon        977x1              7816  double              
  lonlim           1x2                16  double              

Plot the trimmed line data using a Miller projection.

axesm('MapProjection', 'miller', 'Frame', 'on',...
'FlatLimit', latlim, 'FlonLimit', lonlim)

Version History

Introduced before R2006a