Missing Map Grid Lines

QUESTION: I'm using the Map_Proj_* routines to create maps in IDL, but I notice on many of my maps that portions of the map grid lines are missing when I draw the grids with Map_Grid. Is this something I am doing, or is this a problem with IDL?

Here is an example of such a map. Notice the missing grid line at latitude 15 degrees at the top of the figure. What's going on there?

Map is missing part of the 15 degree grid line.
Part of the 15 degree grid line is missing at the top of the map.

ANSWER: Yes, this is a problem with Map_Grid, but only indirectly. The real problem is with Map_Proj_Forward, which Map_Grid uses internally. There is a bug in Map_Proj_Forward (at least in the IDL 7.1.2 version of the software I am using) that causes it to return incorrect results when Map_Proj_Forward is called with the POLYLINES keyword. In fact, some of the points input to the function are simply missing on output. It is these points that are not being drawn on your map.

Fortunately, Map_Grid is an IDL library program and you can modify it to fix this problem.

Find the following two lines, found at lines 555 and 556 in my version of Map_Grid:

    uv = MAP_PROJ_FORWARD(REPLICATE(lon, N_ELEMENTS(lati)), lati, $
          MAP_STRUCTURE=mapStruct, POLYLINES=polylines) 

Replace these two lines with these three lines:

  uv = MAP_PROJ_FORWARD(REPLICATE(lon, N_ELEMENTS(lati)), lati, $
  polylines = [N_Elements(lati), Indgen(N_Elements(lati))] 

And do the same thing with lines 664 and 665. Replace these two lines:

   uv = MAP_PROJ_FORWARD(loni, REPLICATE(lat, N_ELEMENTS(loni)), $
          MAP_STRUCTURE=mapStruct, POLYLINES=polylines) 

With these three lines:

  uv = MAP_PROJ_FORWARD(loni, REPLICATE(lat, N_ELEMENTS(loni)), $
  polylines = [N_Elements(loni), Indgen(N_Elements(loni))] 

Recompile Map_Grid and you are good to go. Now your grid lines will be complete, as shown in the figure below.

The 15 degree grid line is now complete with a modified
 Map_Grid program.
The 15 degree grid line is now complete with a modified Map_Grid program.

If you are interested in more details, I've written a short IDL program that clearly demonstrates the problem with Map_Proj_Forward.


These and other problems with Map_Grid, especially having to do with drawing grid lines on map projections created with Map_Proj_Init, have been corrected in the Coyote Library procedure cgMap_Grid.

Version of IDL used to prepare this article: IDL 7.1.2

Web Coyote's Guide to IDL Programming