David Fanning writes:
> I am actually making progress on this now, using something very much
> like this. I'm writing it up. Should be ready in an hour or so.
> It only took me two full days of effort. A new speed record for
> a function graphics plot!
Success at last! Praise God Almighty! Success at last!
Don't know why I'm channeling Martin Luther King, Jr,
except that it has been a LONG day and I'm ready for
a Friday afternoon beer! Have I mentioned how much I
love Function Graphics.
If you want to skip to the bottom line, you can run the
code you find here:
http://www.idlcoyote.com/tip_examples/mapnogrid.pro
If you want to read all the gory details of how I figured
this out, you can read this article:
http://www.idlcoyote.com/ng_tips/mapnogrid.php
If you just want to see the final result, here is the
code:
; Get the image.
googleStr = "http://maps.googleapis.com/maps/api/staticmap?" + $
"center=40.6,-105.1&zoom=12&size=600x600" + $
"&maptype=terrain&sensor=false&format=png32"
netObject = Obj_New('IDLnetURL')
void = netObject -> Get(URL=googleStr, FILENAME="googleimg.png")
Obj_Destroy, netObject
googleImage = Read_Image('googleimg.png')
; What I am trying to reproduce in Function Graphics, displayed
; with Coyote Graphics.
centerLat = 40.6D
centerLon = -105.1D
scale = cgGoogle_MetersPerPixel(12)
map = Obj_New('cgMap', 'Mercator', ELLIPSOID='WGS 84', /OnImage)
uv = map -> Forward(centerLon, centerLat)
uv_xcenter = uv[0,0]
uv_ycenter = uv[1,0]
xrange = [uv_xcenter - (300*scale), uv_xcenter + (300*scale)]
yrange = [uv_ycenter - (300*scale), uv_ycenter + (300*scale)]
map -> SetProperty, XRANGE=xrange, YRANGE=yrange
cgDisplay, 700, 700, Title='Google Image with Coyote Graphics'
cgImage, googleImage, Margin=0.1
map -> Draw
cgMap_Grid, MAP=map, /BOX_AXES
cgPlotS, -105.1, 40.6, PSYM='filledstar', SYMSIZE=3.0, $
MAP=map, COLOR='red'
; The code I used to do what I wanted to do. (Needs some
; of the code from above.)
ll = map -> Inverse(xrange, yrange)
limits = [ll[0,0], ll[1,0], ll[0,1], ll[1,1]]
xdim = Abs(xrange[1] - xrange[0])
ydim = Abs(yrange[1] - yrange[0])
xloc = xrange[0]
yloc = yrange[0]
obj = Image(googleImage, MAP_PROJECTION='mercator', $
ELLIPSOID='WGS 84', GRID_UNITS=1, $
XRANGE=xrange, YRANGE=yrange, LIMIT=limit, $
DIMENSIONS=[700,700], POSITION=[0.1, 0.1, 0.9, 0.9], /BOX_AXES, $
IMAGE_DIMENSIONS=[xdim,ydim], IMAGE_LOCATION=[xloc,yloc])
sym = Symbol(centerLon, centerLat, 'star', /DATA, $
SYM_COLOR='red', SYM_SIZE=3, SYM_FILLED=1)
obj.mapprojection.mapgrid.BOX_AXES = 1
obj.mapprojection.mapgrid.BOX_THICK = 10
obj.mapprojection.mapgrid.LINESTYLE = 1
obj.mapprojection.mapgrid.GRID_LONGITUDE = 0.04
obj.mapprojection.mapgrid.GRID_LATITUDE = 0.03
obj.mapprojection.mapgrid.LABEL_POSITION = 0
obj.mapprojection.mapgrid.LONGITUDE_MIN=-105.18
obj.mapprojection.mapgrid.LATITUDE_MIN=40.54
There is, apparently, no way to get box axes on the plot,
but to get even this far in two days time is a major
achievment! I'm going for a beer.
I learned after I wrote the article that the LIMIT
keyword is not needed. (I wouldn't have thought so,
but I was throwing the kitchen sink at the problem!)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|