View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
scalebar for maps

4.0 | 1 rating Rate this file 11 Downloads (last 30 days) File Size: 40.3 KB File ID: #43500 Version: 1.3
image thumbnail

scalebar for maps


Chad Greene (view profile)


16 Sep 2013 (Updated )

A simpler alternative to the built-in Mapping Toolbox function scaleruler.

| Watch this File

File Information

The scaleruler function in the Mapping Toolbox is clunky and difficult to work with. The scalebar function presented here is simple and intuitive. See the documentation file to the right for function Syntax, Description, and Examples.


This file inspired Antarctic Mapping Tools, Circlem, Gdistm, and Landsat.

Required Products Mapping Toolbox
MATLAB release MATLAB 8.0 (R2012b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
12 Oct 2016 Chad Greene

Chad Greene (view profile)

Hi Thomas,

Thanks for the feedback. The difference you see between scalebar and scaleruler is not an indication that either function is correct or incorrect. Rather, it just means the different scales are referenced to different places in the map. Each one is correct somewhere in the map, so as a general rule of thumb, if scalebar and scaleruler do not agree, the map is probably too big to include either.

Some GIS style guides say every map should include a graphical reference scale, but you've found the reason that's bad advice. Maps of large areas contain tremendous distortion yet a graphical reference scale implies the scale is true everywhere in the map. Africa is 14 times the size of Greenland, yet Mercator maps give the impression that Greenland is larger.

I suspect you may have found a fudge factor to make scalebar and scaleruler agree when neither should be used.

Comment only
10 Oct 2016 Thomas G


I could observe large scale length difference between your proposal and the function in the mapping tool... especially if the mapped area is far from the projection origin and combined with a global projection (like mercator).

I could manage this error changing the way you estimate the dstpermapunit on lines 143 and 144 to this proposal:
[lat2,lon2]=minvtran(xl(1) + 0.1,mean(yl));


30 Jul 2015 Chad Greene

Chad Greene (view profile)

Shoot, I neglected to mention--As of the July 25, 2015 update, scalebar now requires the pathdist function, which can be found on the File Exchange site here:

Comment only
20 Aug 2014 1.1

Inclusion of example file.

25 Jul 2015 1.3

Added automatic length scaling, and now supports just about any length unit.

Contact us