Create Declination Diagram (North Arrow) with Python

Update: An update to the World Magnetic Model (WMM) released in the year 2015 causes errors when executing the python tool available with this template. This is addressed in the recent patches for Esri Production Mapping as fixes to the Magnetic Calculator tool. Based on the installed version of Production Mapping, please download and install the latest patch from the Esri support site before using this template.

A declination diagram shows the angular relationship between grid, magnetic, and true north using a series of graphic arrows. A previous blog article on declination diagrams with ArcMap discussed what declination diagrams/north arrows are, and the different options for adding them to ArcMap.

Esri Production Mapping’s Topo North Arrow surround element (a USGS-style declination diagram) is mentioned in the blog. However, this element cannot be configured to change the diagram’s graphic appearance (such as font, arrow style, line length, color, etc.).  Many users want the ability to change the styles of their diagrams, allowing them to meet their organization’s custom graphic specifications.

The just released Create Declination Diagram Template provides you with the ability to do just that!  The provided map document has graphics that can be modified to change the look of the diagram. The Python tool updates those graphics to show the appropriate angles and values based on the current data frame extent using Production Mapping’s Magnetic Calculator geoprocessing tool.

With this Python-based approach of creating declination diagrams the graphics can be easily modified without any coding. The standard drawing tools in ArcMap can be used to make any necessary updates and the Python tool will still continue to work with the updated graphics. However, if you do want see how the magic works and/or change some of the dynamic behavior of the tool, the code is there for you to modify! All it takes is basic Python and arcpy knowledge.

Happy mapping!

This entry was posted in Cartographic Design, Defense, Mapping, Python and tagged . Bookmark the permalink.

Leave a Reply

11 Comments

  1. kdoss_guilford says:

    I followed the instructions for the template, but nothing changed/updated on the declination diagram. Can anyone help?

  2. jmsprung says:

    The declination diagram script fails for me. It appears the magnetic declination direction creates an exception…

    Magnetic Declination Angle in Decimal Degrees = None
    Annual Drift = None
    Magnetic Declination = W
    Exception: int() argument must be a string or a number, not ‘NoneType’
    Completed Script
    CreateDeclinationDiagram…
    Failed to execute
    (CreateDeclinationDiagram).

    • mphaterpekar says:

      What is the version of production mapping you have installed? From the description it sounds like you may need to install the latest patch to get the latest world magnetic model. The model was update in early 2015 and the updates were shipped with patches to production mapping subsequently.

  3. jmsprung says:

    The Production Mapping version used was 10.2; Build Number 2714

  4. jmsprung says:

    I have routed this inquiry to our help desk. I’m on a network and so cannot install this patch

  5. dri24@nau.edu says:

    Is there a version of this or a declination arrow for 10.3? It will not work in 10.3 and that is all I have access to.

    • ProductionMappingTeam says:

      An update to the World Magnetic Model (WMM) released in the year 2015 causes errors when executing the python tool available with this template. This is addressed in the recent patches for Esri Production Mapping as fixes to the Magnetic Calculator tool. Based on the installed version of Production Mapping, please download and install the latest patch from the Esri support site before using this template.

  6. nzgeocad says:

    Are there plans to update the Topo North Arrow to show the Grid to Mag angle for UTM maps? And can someone explain the requirement to use the Lambert Conformal Conic projection to generate a GRID_VARIATION value? Why not simply a UTM (WGS84) projection? (The value when using the best version for my location in UTM 60S is the ‘Asia South Lambert Conformal Conic’ projection….I’ve no idea if this is the correct one and it returns incorrect grid variations)

  7. dri24@nau.edu says:

    The code works after installing the World Magnetic Model (WMM) coefficient update 2015-2020. I am trying to use this within data driven pages along a trail and the tool doesn’t appear to change based on a different page/location. Any ideas for how to make this a dynamic element to change with each data driven page? Thanks!

    • mphaterpekar says:

      The sample modifies a collection of static graphic element to draw the north arrow. As a part of the modification it discards graphics not needed. If you want to use this in a dynamic way I believe there are 2 options you could explore.

      1. Use the Topographic North Arrow (available out of the box with Production Mapping Extension). This is a dynamic element that can stay on your layout and update as you change the extent or switch between data driven pages. The design of the North arrow cannot be greatly customized as you can for the declination diagram sample. Also if you share this mxd with other folks they will need to have Production mapping installed first. This is definately the easy option.
      See help for this element http://desktop.arcgis.com/en/arcmap/latest/extensions/production-mapping/inserting-the-topo-north-arrow-element.htm

      2. Write a python add-in extension to update the declination diagram each time the page changes. You will need to implement the pageIndexExtentChanged method to achieve this. Here are some help topics to get started with.
      http://desktop.arcgis.com/en/arcmap/10.3/guide-books/python-addins/creating-an-add-in-application-extension.htm
      http://desktop.arcgis.com/en/arcmap/10.3/guide-books/python-addins/extension-class.htm

      At a high level I think you will need to follow these workflow
      - Always have the entire collection of graphics in the mxd. The declination diagram consists of 22 elements with fixed prefix (‘PM_’) and element names. You can place them outside the layout so they are not on your map. Also you may need to rename them to something else so the original set doesn’t get modified by the Create Declination Diagram tool. Page 3 in the Getting Started document of this template discussed this collection and how it gets used.
      - Using a python addin after each data-driven page change, Remove any modified elements, Clone the original collection of elements, rename to run the declination diagram tool and move the cloned set that inside the layout.
      This might be a bit more involved and tedious compare to 1st option but its totally do-able.

      At this point if you are wondering why should you use the sample vs the out of the box topographic tool then you are correct in doing so. The primary difference is that if you need a different appearance for the Topo North Arrow or its parts then you cannot use that with the out of the box element. For e.g you cannot convert the line for the Grid North in the Topo North Arrow from a solid line to a dashed line. But you can easily do this with the Declination Diagram Sample.

      So hopefully this helps.