Fanning Software Consulting

Map Projection Clips Image

Facebook Twitter RSS Google+

QUESTION: I am trying to display an image on a map projection created with the new map object using the Map function. Unfortunately, there appears to be a bug in the code, because the first column and row of my image is completely clipped or cut off.

Let me illustrate what I mean. First, let's create an example image and plot it normally.

   img = Bindgen(3,5,4) * 21B 
   i0 = Image(img, Axis_Style=2, Image_Dimensions=[100,80], Image_Location=[-50,-40], $
           Layout=[2,2,1])

Now, set the Grid_Units keyword to 2 to define a latitude and longitude coordinate system and display the image on a Geographic map projection.

   i1 = Image(img, Axis_Style=2, Image_Dimensions=[360,180], Image_Location=[-180,-90], $
           Layout=[2,2,2], /Current, Grid_Units=2, Map_Projection='Geographic')

Whoops! The left-most column and the bottom row are missing!

We see the same problem for a sinusoidal map projection (and, really, for any map projection you care to use).

   i2 = Image(img, Axis_Style=2, Image_Dimensions=[360,180], Image_Location=[-180,-90], $
           Layout=[2,2,3], /Current, Grid_Units=2, Map_Projection='Sinusoidal')

One way to fix the problem is to pad the orginal image with an extra column and row.

   paddedImg = BytArr(Size(img, /Dimension)+[0,1,1])*0B + 255B
   paddedImg[*,1:*,1:*] = img
   i3 = Image(paddedImg, Axis_Style=2, Image_Dimensions=[360,180], Image_Location=[-180,-90], $
           Layout=[2,2,4], /Current, Grid_Units=2, Map_Projection='Sinusoidal')

You see the results in the figure below.

Map projections clip the first column and row of the image.
Map projections clip the first column and row of the image.
 

ANSWER: Yes, the folks at ExelisVis acknowledge this is a bug in the software up through at least IDL version 8.3.

Just a warning. This bug (and the work-around suggested) will almost certainly throw off the navigation of the image by some amount. The damage done is probably inversely proportional to the size of your image. If you have a small image, the navigation could potentially be thrown off enough to matter a great deal.

Version of IDL used to prepare this article: IDL 8.2.3.

Written: 2 February 2014