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

Home » Public Forums » archive » converting xy to lon lat
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
converting xy to lon lat [message #94595] Wed, 19 July 2017 05:42 Go to previous message
rsori is currently offline  rsori
Messages: 5
Registered: November 2014
Junior Member
Hello,

I am trying to convert/plot a matrix of data from xy to lon lat coordinates. I am using this script which is available in the coyote web; but I have a problem with this line: latlon = map -> Inverse(xgrid, ygrid)

The message says: Object reference type required in this context: MAP.


I have no idea, because I declared before map as a matrix but the mistake remains...

Any help is appreciated !



pro leer_fich
datos2=BYTARR(304, 447, /NOZERO)

openw,1,'G:\Raquel\convert_xy_lonlat\mean.aug.1979-2015.n.tx t'
printf,1,datos2,FORMAT='(304(i0,2x))'
close,1

; Read the data, reverse the Y direction, and save the data dimensions;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;
; filename = 'usegriddata.dat'
; tempAnomaly= FltArr(144, 73)
; OpenR, lun, filename, /Get_Lun
; ReadU, lun, tempAnomaly
; Free_Lun, lun
; tempAnomaly = Reverse(tempAnomaly,2)
dims = Size(datos2, /DIMENSIONS)

; Set up the output map projection and create a projected meter grid.
x0 = -241043.0D
x1 = 500000.0D
y0 = 5653409.0D
y1 = 2035.0D
xdim = 304
ydim = 448
xscale = (x1 - x0) / xdim
yscale = (y1 - y0) / ydim
xvec = cgScaleVector(Findgen(xdim), x0+(xscale/2.0), x1-(xscale/2.0))
yvec = cgScaleVector(Findgen(ydim), y0+(yscale/2.0), y1-(yscale/2.0))
xgrid = Rebin(xvec, xdim, ydim)
ygrid = Rebin(Reform(yvec, 1, ydim), xdim, ydim)

map=strarr(304, 447)
; Convert the projected meter grids into the lat/lons of the data.
latlon = map -> Inverse(xgrid, ygrid)
longrid = Reform(latlon[0,*], xdim, ydim)
latgrid = Reform(latlon[1,*], xdim, ydim)

; Make sure longitudes are in the range 0 to 360.
longrid = (longrid + 360.0) MOD 360.0

; Create the fractional indices.
xindex = cgScaleVector(longrid, 0, dims[0], Min=0, Max=357.5)
yindex = cgScaleVector(latgrid, 0, dims[1], Min=-90.0, Max=90.0)

; Do the gridding.
nearestNeighbor = tempAnomaly[Round(xindex), Round(yindex)]
bilinear = Interpolate(tempAnomaly, xindex, yindex)
cubic = Interpolate(tempAnomaly, xindex, yindex, /Cubic)

; Display the data.
cgDisplay, 300, 450, /Free, Title='Nearest Neighbor Interpolation'
mapPosition = [0.05, 0.05, 0.95, 0.85]
map -> SetProperty, XRange=[x0,x1], YRange=[y0,y1], Position=mapPosition
map -> Draw
cgLoadCT, 22, /Reverse, NColors=10, Bottom=1, /Brewer
scaledImage = BytScl(nearestNeighbor, TOP=9, MIN=-7.5, MAX=7.5) + 1B
cgImage, scaledImage, Position=mapPosition
names = String(Findgen(11)*1.5-7.5, Format='(F0.1)')
names[indgen(5)*2+1] = " "
cgColorbar, NColors=10, Bottom=1, /Discrete, Range=[-7.5, 7.5], $
Ticknames=names, Position=[0.05, 0.9, 0.95, 0.93], Title='Temperature Anomaly', $
Charsize=0.75
Map_Grid, MAP=map->GetMapStruct(), Lats=Indgen(10)*10, Lons=Indgen(36)*10, Color=cgColor('black')
cgMap_Continents, Map=map

; Bilinear display.
cgDisplay, 300, 450, /Free, Title='Bilinear Interpolation'
map -> Draw
scaledImage = BytScl(bilinear, TOP=9, MIN=-7.5, MAX=7.5) + 1B
cgImage, scaledImage, Position=mapPosition
cgColorbar, NColors=10, Bottom=1, /Discrete, Range=[-7.5, 7.5], $
Ticknames=names, Position=[0.05, 0.9, 0.95, 0.93], Title='Temperature Anomaly', $
Charsize=0.75
Map_Grid, MAP=map->GetMapStruct(), Lats=Indgen(10)*10, Lons=Indgen(36)*10, Color=cgColor('black')
cgMap_Continents, Map=map

; Cubic display.
cgDisplay, 300, 450, /Free, Title='Cubic Interpolation'
map -> Draw
scaledImage = BytScl(cubic, TOP=9, MIN=-7.5, MAX=7.5) + 1B
cgImage, scaledImage, Position=mapPosition
cgColorbar, NColors=10, Bottom=1, /Discrete, Range=[-7.5, 7.5], $
Ticknames=names, Position=[0.05, 0.9, 0.95, 0.93], Title='Temperature Anomaly', $
Charsize=0.75
Map_Grid, MAP=map->GetMapStruct(), Lats=Indgen(10)*10, Lons=Indgen(36)*10, Color=cgColor('black')
cgMap_Continents, Map=map

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



print,'FIN'
end
[Message index]
 
Read Message
Read Message
Previous Topic: Auto-path finding when writing file
Next Topic: Problem (+solution) with make_rt

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

Current Time: Wed Oct 08 09:20:08 PDT 2025

Total time taken to generate the page: 0.00437 seconds