robinson.inj@gmail.com writes:
> I was wondering if you could help me with the following. I would like to use the world image available in IDL: Filepath(SubDirectory=['examples', 'data'], 'avhrr.png') . I need to warp it in a mercator projection but also I would like to have control on it. For instance I would like to display a specific region (let's say latmin=-40, latmax=-5, lonmin=100, lonmax=160 or any other region)in a lat/lon map. Could you show me how to do it?
I would do it like this. You can see the result here:
http://www.idlcoyote.com/misc/warped_avhrr.png
Cheers,
David
;------------------------------------------------------
file = Filepath(SubDir=['examples', 'data'], 'avhrr.png')
image = Read_PNG(file, r, g, b)
palette = [ [r],[g],[b] ]
mapOrig = Obj_New('cgMap', 'Equirectangular')
mapMercator = Obj_New('cgMap', 'Mercator', XRange=[100, 160], $
YRange=[-40, -5], Position=[0,0,1,1], /LatLon_Ranges, $
Center_Longitude=130, True_Scale_Latitude=-20)
dims = Size(image, /Dimensions)
lons = Scale_Vector(Findgen(dims[0]), -180, 180)
lats = Scale_Vector(Findgen(dims[1]), -90, 90)
lonindices = Value_Locate(lons, [100,160])
latIndices = Value_Locate(lats, [-40,-5])
subimage = image[lonIndices[0]:lonIndices[1]-1, $
latIndices[0]:latIndices[1]-1]
warpedImage = Map_Proj_Image(subimage, [100, -40, 160, -5], $
Image_Structure=mapOrig->GetMapStruct(), $
Map_Structure=MapMercator->GetMapStruct())
cgDisplay, Aspect=warpedImage, 800, 800
cgImage, warpedImage, Palette=palette
mapMercator -> Draw
cgMap_Continents, Map=mapMercator
cgMap_Grid, /cgGrid, /Label, Map=mapMercator
END
;------------------------------------------------------
--
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.")
|