Code covered by the BSD License  

Highlights from
Automatic Map Scale Generation

5.0

5.0 | 1 rating Rate this file 23 Downloads (last 30 days) File Size: 3.97 KB File ID: #33545
image thumbnail

Automatic Map Scale Generation

by

 

31 Oct 2011 (Updated )

Intelligently creates and places a scale on a figure based on the lat/lon limits.

| Watch this File

File Information
Description

MAKESCALE creates a scale for map data.

  MAKESCALE creates a scale on the current axis based on the current axis
      limits. The scale is made to occupy 1/5th of the map. It is placed
      in the southeast corner of the map. The units will either be in
      milimeters, meters or kilometers, depending on the size of the map.

  MAKESCALE(H_AXIS) creates a scale on the axis specificed by the handle
      H_AXIS based on the its axes limits. H_AXIS must be a scalar.

  MAKESCALE(SCALE) creates a scale made to occupy 1/SCALE of the map.
      SCALE must be a scalar, and is bounded to be between 1.1 and 10. If
      a larger value is passed in, 10 will be used. If a smaller value is
      passed in, 1.1 will be used.

  MAKESCALE(LOCATION) places the scale in the location specified by
      LOCATION. Acceptable values for location are as follows
          'northeast' 'ne'
          'northwest' 'nw'
          'southeast' 'se'
          'southwest' 'sw'
          'north' 'n'
          'south' 's'

  MAKESCALE('units',UNITS) changes the units systems from SI to imperical
      units. UNITS should be either 'si' or 'imp.' The units displayed
      are automatically switched between milimeters, meters, and
      kilometers for the SI system, or between inches, feet, and statuate
      miles for the imperical system.

  H = MAKESCALE(...) outputs H, a 3x1 containing the handles of the of
      box, line, and text.

  Any number of these input sets may be passed in any order.

  The map scale will automatically be updated as the figure is zoomed,
      panned, resized, or clicked on. It will not, however, be updated
      upon using the commands "axis", "xlim", or "ylim" as these do not
      have callback functionality.

  Example:
      load conus
      figure
      plot(uslon,uslat);
      makeScale

  Example: Placed in the south
      load conus
      figure
      plot(uslon,uslat);
      makeScale('south')

  Example: Half the size of the Window
      load conus
      figure
      plot(uslon,uslat);
      makeScale(2,'south')

  Example: Use Imperical Units
      load conus
      figure
      plot(uslon,uslat);
      makeScale(2,'south','units','imp')

  Example: Zooming In
      load conus
      figure
      plot(uslon,uslat);
      makeScale(2,'south')
      zoom(2)

  Note: This assumes axis limits are in degrees. The scale is sized
      correctly for the center latitude of the map. As the size of
      degrees longitude change with latitude, the scale becomes invalid
      with very large maps. Spherical Earth is assumed. Ideally, the map
      will be proportioned correctly in order to reflect the relationship
      between a degree latitude and a degree longitude at the center of
      the map.

By Jonathan Sullian - October 2011

Acknowledgements

This file inspired Gdistm.

MATLAB release MATLAB 7.12 (R2011a)
Other requirements To run the examples, the mapping toolbox is required, but no toolbox is needed to run makescale.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
08 Nov 2011 Jonathan Sullivan

Thanks for the heads up Aurelien. I've made the change to the code so as to not require the toolbox. It should be approved soon.

08 Nov 2011 Aurelien Queffurust

this is required when you do not have Mapping Toolbox

08 Nov 2011 Aurelien Queffurust

reading the doc I have seen that I can write:
earthRadius = 6371000

31 Oct 2011 Mike Sheppard  
Updates
08 Nov 2011

Added earthRadius = 6371000; so as to not require the mapping toolbox.

Contact us