On Tuesday, August 20, 2013 3:29:24 PM UTC-4, David Fanning wrote:
> Scott Ozog writes:
>
>
>
>> Hi I'm still new to IDL, and I'm trying to learn it for grad school. I'm trying to navigate images from NASA's AVIRIS platform. If anyone has experience in this it would be greatly appreciated.
>
>> I have a file that has Lons in band 1, Lats in band 2, and a elevation model image in band 3.
>
>> The arrays are [677, 3068] and the resolution of each pixel is unknown. The image is in UTM using WGS84.
>
>>
>
>> The actual image file is larger in both sample and lines, but I'm at least trying to learn how the MAP_PATCH or Fanning's WarpToImage procedures work. I still can't quite get them to work yet with my image.
>
>
>
> I wouldn't waste too much time with cgWarpToMap. I am THIS close to the
>
> IDL Holy Grail and I've got cgWarpToMap all torn apart right now. I've
>
> been searching for 10 years to find a fast way to convert a MODIS swath
>
> file to a navigable image and I am very, very close. (In fact, I woke up
>
> at 2AM and worked on it last night, when I had a new idea.)
>
>
>
> If this image is already projected, though, as you indicate, I doubt
>
> very much that you will need to bother with either Map_Patch or
>
> cgWarpToMap. Rather, you will need the UTM zone number, which you can
>
> obtain from cgUTMZone by passing in any lat/lon pair you have laying
>
> around in your lats and lons arrays.
>
>
>
> zone = cgUTMZone(lon[0,0], lat[0,0])
>
>
>
> Then, you need a map object:
>
>
>
> map = Obj_New('cgMap', 'UTM', ELLIPSOID='WGS84', Zone=zone)
>
>
>
> Make sure the longitudes are in the range -180 to 180.
>
>
>
> lons = ((lons + 180) MOD 360) - 180
>
>
>
> Convert these values to XY projected meter space:
>
>
>
> xy = map -> Forward(lons, lats)
>
>
>
> Find the min and max of the X and Y space:
>
>
>
> x = Reform(xy[0,*])
>
> y = Reform(xy[1,*])
>
> xmin = Min(x, MAX=xmax)
>
> ymin = Min(y, MAX=ymax)
>
>
>
> Find the size of your image:
>
>
>
> s = Size(image, /Dimensions)
>
>
>
> Calculate the X and Y scales:
>
>
>
> scale_x = (xmax - xmin) / (s[0]-1)
>
> scale_y = (ymax - ymin) / (s[1]-1)
>
>
>
> Calculate the XY ranges and set the map object appropriately:
>
>
>
> rect = [xmin-(scale_x/2.), ymin-(scale_y/2.), $
>
> xmax+(scale_x/2.), ymax+(scale_y/2.)]
>
> xrange = rect[[0,2]]
>
> yrange = rect[[1,3]]
>
> map -> SetProperty, XRANGE=xrange, YRANGE=yrange
>
>
>
> Display your image and navigate it.
>
>
>
> cgDisplay, Aspect=image, 800, 800
>
> cgImage, image
>
> cgMap_Continents, Map=map, Color='red6'
>
> cgMap_Grid, Map=map, Color='blu6'
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Thank you Dr. Fanning!
That helped a lot. Combining this with the last part of your warptomap.php I was able to get something like what I'm trying to do. However, I know that my image is not oriented N-S and that is how it is being displayed on the map... Just confined to its x and y min/max. I'm not sure how to upload a photo to show you what I mean. The image is a small swath only about 10km x 50km in southern New Mexico.
Thanks,
Scott Ozog
University of Maryland
Department of
Earth and Atmospheric Science
|