comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: controling a warped image: How to do it?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: controling a warped image: How to do it? [message #83118] Wed, 06 February 2013 11:00
robinson.inj is currently offline  robinson.inj
Messages: 32
Registered: August 2007
Member
On Wednesday, February 6, 2013 11:45:45 AM UTC-5, robins...@gmail.com wrote:
> Dear all,
>
> 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?
>
> Regards,
>
> Rob.

Hi David, thank you very much for your solution.
Re: controling a warped image: How to do it? [message #83122 is a reply to message #83118] Wed, 06 February 2013 09:55 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Can't find the end of a text file
Next Topic: Re: Mean and NaNs

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:31:41 PDT 2025

Total time taken to generate the page: 0.00453 seconds